/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et tw=80 : */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsHttp.h" #include "mozilla/net/NeckoParent.h" #include "mozilla/net/HttpChannelParent.h" #include "mozilla/net/CookieServiceParent.h" #include "mozilla/net/WyciwygChannelParent.h" #include "mozilla/net/FTPChannelParent.h" #include "mozilla/net/WebSocketChannelParent.h" #include "mozilla/net/RemoteOpenFileParent.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/TabParent.h" #include "mozilla/dom/network/TCPSocketParent.h" #include "mozilla/dom/network/TCPServerSocketParent.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/LoadContext.h" #include "mozilla/AppProcessChecker.h" #include "nsPrintfCString.h" #include "nsHTMLDNSPrefetch.h" #include "nsIAppsService.h" #include "nsEscape.h" #include "RemoteOpenFileParent.h" using mozilla::dom::ContentParent; using mozilla::dom::TabParent; using mozilla::net::PTCPSocketParent; using mozilla::dom::TCPSocketParent; using mozilla::net::PTCPServerSocketParent; using mozilla::dom::TCPServerSocketParent; using IPC::SerializedLoadContext; namespace mozilla { namespace net { // C++ file contents NeckoParent::NeckoParent() { // Init HTTP protocol handler now since we need atomTable up and running very // early (IPDL argument handling for PHttpChannel constructor needs it) so // normal init (during 1st Http channel request) isn't early enough. nsCOMPtr proto = do_GetService("@mozilla.org/network/protocol;1?name=http"); if (UsingNeckoIPCSecurity()) { // cache values for core/packaged apps basepaths nsAutoString corePath, webPath; nsCOMPtr appsService = do_GetService(APPS_SERVICE_CONTRACTID); if (appsService) { appsService->GetCoreAppsBasePath(corePath); appsService->GetWebAppsBasePath(webPath); } // corePath may be empty: we don't use it for all build types MOZ_ASSERT(!webPath.IsEmpty()); LossyCopyUTF16toASCII(corePath, mCoreAppsBasePath); LossyCopyUTF16toASCII(webPath, mWebAppsBasePath); } } NeckoParent::~NeckoParent() { } static PBOverrideStatus PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized) { if (!aSerialized.IsNotNull() && aSerialized.IsPrivateBitValid()) { return aSerialized.mUsePrivateBrowsing ? kPBOverride_Private : kPBOverride_NotPrivate; } return kPBOverride_Unset; } const char* NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized, PContentParent* aContent, uint32_t* aAppId, bool* aInBrowserElement) { *aAppId = NECKO_UNKNOWN_APP_ID; *aInBrowserElement = false; if (UsingNeckoIPCSecurity()) { if (!aSerialized.IsNotNull()) { return "SerializedLoadContext from child is null"; } } const InfallibleTArray& browsers = aContent->ManagedPBrowserParent(); for (uint32_t i = 0; i < browsers.Length(); i++) { nsRefPtr tabParent = static_cast(browsers[i]); uint32_t appId = tabParent->OwnOrContainingAppId(); bool inBrowserElement = aSerialized.IsNotNull() ? aSerialized.mIsInBrowserElement : tabParent->IsBrowserElement(); if (appId == NECKO_UNKNOWN_APP_ID) { continue; } // We may get appID=NO_APP if child frame is neither a browser nor an app if (appId == NECKO_NO_APP_ID) { if (tabParent->HasOwnApp()) { continue; } if (UsingNeckoIPCSecurity() && tabParent->IsBrowserElement()) { //