/* -*- 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/TabParent.h" #include "mozilla/dom/network/TCPSocketParent.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::TabParent; using mozilla::net::PTCPSocketParent; using mozilla::dom::TCPSocketParent; using IPC::SerializedLoadContext; namespace mozilla { namespace net { // C++ file contents NeckoParent::NeckoParent() { 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, PBrowserParent* aBrowser, uint32_t* aAppId, bool* aInBrowserElement) { if (UsingNeckoIPCSecurity()) { if (!aBrowser) { return "missing required PBrowser argument"; } if (!aSerialized.IsNotNull()) { return "SerializedLoadContext from child is null"; } } *aAppId = NECKO_UNKNOWN_APP_ID; *aInBrowserElement = false; if (aBrowser) { nsRefPtr tabParent = static_cast(aBrowser); *aAppId = tabParent->OwnOrContainingAppId(); *aInBrowserElement = tabParent->IsBrowserElement(); if (*aAppId == NECKO_UNKNOWN_APP_ID) { return "TabParent reports appId=NECKO_UNKNOWN_APP_ID!"; } // We may get appID=NO_APP if child frame is neither a browser nor an app if (*aAppId == NECKO_NO_APP_ID) { if (tabParent->HasOwnApp()) { return "TabParent reports NECKO_NO_APP_ID but also is an app"; } if (UsingNeckoIPCSecurity() && tabParent->IsBrowserElement()) { //