mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 890570 - PCookieService doesn't need PBrowser r=jduell
This commit is contained in:
parent
cda5964d4a
commit
09549d7ffd
@ -4,13 +4,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/net/CookieServiceChild.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsITabChild.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
@ -118,22 +116,10 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
URIParams uriParams;
|
||||
SerializeURI(aHostURI, uriParams);
|
||||
|
||||
nsCOMPtr<nsITabChild> iTabChild;
|
||||
mozilla::dom::TabChild* tabChild = nullptr;
|
||||
if (aChannel) {
|
||||
NS_QueryNotificationCallbacks(aChannel, iTabChild);
|
||||
if (iTabChild) {
|
||||
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
||||
}
|
||||
if (MissingRequiredTabChild(tabChild, "cookie")) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Synchronously call the parent.
|
||||
nsAutoCString result;
|
||||
SendGetCookieString(uriParams, !!isForeign, aFromHttp,
|
||||
IPC::SerializedLoadContext(aChannel), tabChild, &result);
|
||||
IPC::SerializedLoadContext(aChannel), &result);
|
||||
if (!result.IsEmpty())
|
||||
*aCookieString = ToNewCString(result);
|
||||
|
||||
@ -163,21 +149,9 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
URIParams uriParams;
|
||||
SerializeURI(aHostURI, uriParams);
|
||||
|
||||
nsCOMPtr<nsITabChild> iTabChild;
|
||||
mozilla::dom::TabChild* tabChild = nullptr;
|
||||
if (aChannel) {
|
||||
NS_QueryNotificationCallbacks(aChannel, iTabChild);
|
||||
if (iTabChild) {
|
||||
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
||||
}
|
||||
if (MissingRequiredTabChild(tabChild, "cookie")) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Synchronously call the parent.
|
||||
SendSetCookieString(uriParams, !!isForeign, cookieString, serverTime,
|
||||
aFromHttp, IPC::SerializedLoadContext(aChannel), tabChild);
|
||||
aFromHttp, IPC::SerializedLoadContext(aChannel));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/net/CookieServiceParent.h"
|
||||
#include "mozilla/dom/PBrowserParent.h"
|
||||
#include "mozilla/dom/PContentParent.h"
|
||||
#include "mozilla/net/NeckoParent.h"
|
||||
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
@ -13,25 +13,25 @@
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
using mozilla::dom::PBrowserParent;
|
||||
using mozilla::dom::PContentParent;
|
||||
using mozilla::net::NeckoParent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
static bool
|
||||
GetAppInfoFromParams(const IPC::SerializedLoadContext &aLoadContext,
|
||||
PBrowserParent* aBrowser,
|
||||
uint32_t& aAppId,
|
||||
bool& aIsInBrowserElement,
|
||||
bool& aIsPrivate)
|
||||
bool
|
||||
CookieServiceParent::GetAppInfoFromParams(const IPC::SerializedLoadContext &aLoadContext,
|
||||
uint32_t& aAppId,
|
||||
bool& aIsInBrowserElement,
|
||||
bool& aIsPrivate)
|
||||
{
|
||||
aAppId = NECKO_NO_APP_ID;
|
||||
aIsInBrowserElement = false;
|
||||
aIsPrivate = false;
|
||||
|
||||
const char* error = NeckoParent::GetValidatedAppInfo(aLoadContext, aBrowser,
|
||||
const char* error = NeckoParent::GetValidatedAppInfo(aLoadContext,
|
||||
Manager()->Manager(),
|
||||
&aAppId,
|
||||
&aIsInBrowserElement);
|
||||
if (error) {
|
||||
@ -69,7 +69,6 @@ CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
|
||||
const bool& aFromHttp,
|
||||
const IPC::SerializedLoadContext&
|
||||
aLoadContext,
|
||||
PBrowserParent* aBrowser,
|
||||
nsCString* aResult)
|
||||
{
|
||||
if (!mCookieService)
|
||||
@ -83,7 +82,7 @@ CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
|
||||
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement, isPrivate;
|
||||
bool valid = GetAppInfoFromParams(aLoadContext, aBrowser, appId,
|
||||
bool valid = GetAppInfoFromParams(aLoadContext, appId,
|
||||
isInBrowserElement, isPrivate);
|
||||
if (!valid) {
|
||||
return false;
|
||||
@ -101,8 +100,7 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
|
||||
const nsCString& aServerTime,
|
||||
const bool& aFromHttp,
|
||||
const IPC::SerializedLoadContext&
|
||||
aLoadContext,
|
||||
PBrowserParent* aBrowser)
|
||||
aLoadContext)
|
||||
{
|
||||
if (!mCookieService)
|
||||
return true;
|
||||
@ -115,7 +113,7 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
|
||||
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement, isPrivate;
|
||||
bool valid = GetAppInfoFromParams(aLoadContext, aBrowser, appId,
|
||||
bool valid = GetAppInfoFromParams(aLoadContext, appId,
|
||||
isInBrowserElement, isPrivate);
|
||||
if (!valid) {
|
||||
return false;
|
||||
|
@ -13,9 +13,6 @@ class nsCookieService;
|
||||
class nsIIOService;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class PBrowserParent;
|
||||
}
|
||||
namespace net {
|
||||
|
||||
class CookieServiceParent : public PCookieServiceParent
|
||||
@ -25,13 +22,18 @@ public:
|
||||
virtual ~CookieServiceParent();
|
||||
|
||||
protected:
|
||||
virtual bool RecvGetCookieString(const URIParams& aHost,
|
||||
MOZ_WARN_UNUSED_RESULT bool
|
||||
GetAppInfoFromParams(const IPC::SerializedLoadContext &aLoadContext,
|
||||
uint32_t& aAppId,
|
||||
bool& aIsInBrowserElement,
|
||||
bool& aIsPrivate);
|
||||
|
||||
virtual bool RecvGetCookieString(const URIParams& aHost,
|
||||
const bool& aIsForeign,
|
||||
const bool& aFromHttp,
|
||||
const IPC::SerializedLoadContext&
|
||||
loadContext,
|
||||
mozilla::dom::PBrowserParent* aBrowser,
|
||||
nsCString* aResult);
|
||||
nsCString* aResult) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvSetCookieString(const URIParams& aHost,
|
||||
const bool& aIsForeign,
|
||||
@ -39,8 +41,7 @@ protected:
|
||||
const nsCString& aServerTime,
|
||||
const bool& aFromHttp,
|
||||
const IPC::SerializedLoadContext&
|
||||
loadContext,
|
||||
mozilla::dom::PBrowserParent* aBrowser);
|
||||
loadContext) MOZ_OVERRIDE;
|
||||
|
||||
nsRefPtr<nsCookieService> mCookieService;
|
||||
};
|
||||
|
@ -6,7 +6,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PNecko;
|
||||
include protocol PBrowser;
|
||||
include URIParams;
|
||||
|
||||
include "SerializedLoadContext.h";
|
||||
@ -65,8 +64,7 @@ parent:
|
||||
sync GetCookieString(URIParams host,
|
||||
bool isForeign,
|
||||
bool fromHttp,
|
||||
SerializedLoadContext loadContext,
|
||||
nullable PBrowser browser)
|
||||
SerializedLoadContext loadContext)
|
||||
returns (nsCString result);
|
||||
|
||||
/*
|
||||
@ -103,8 +101,7 @@ parent:
|
||||
nsCString cookieString,
|
||||
nsCString serverTime,
|
||||
bool fromHttp,
|
||||
SerializedLoadContext loadContext,
|
||||
nullable PBrowser browser);
|
||||
SerializedLoadContext loadContext);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
@ -13,6 +13,7 @@
|
||||
#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"
|
||||
@ -25,6 +26,7 @@
|
||||
#include "nsEscape.h"
|
||||
#include "RemoteOpenFileParent.h"
|
||||
|
||||
using mozilla::dom::ContentParent;
|
||||
using mozilla::dom::TabParent;
|
||||
using mozilla::net::PTCPSocketParent;
|
||||
using mozilla::dom::TCPSocketParent;
|
||||
@ -75,6 +77,47 @@ PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized)
|
||||
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<PBrowserParent*>& browsers = aContent->ManagedPBrowserParent();
|
||||
for (uint32_t i = 0; i < browsers.Length(); i++) {
|
||||
// GetValidatedAppInfo returning null means we passed security checks.
|
||||
if (!GetValidatedAppInfo(aSerialized, browsers[i], aAppId, aInBrowserElement)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (browsers.Length() == 0) {
|
||||
if (UsingNeckoIPCSecurity()) {
|
||||
return "ContentParent does not have any PBrowsers";
|
||||
}
|
||||
if (aSerialized.IsNotNull()) {
|
||||
*aAppId = aSerialized.mAppId;
|
||||
*aInBrowserElement = aSerialized.mIsInBrowserElement;
|
||||
} else {
|
||||
*aAppId = NECKO_NO_APP_ID;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we reached this point, we failed the security check.
|
||||
// Try to return a reasonable error message.
|
||||
return GetValidatedAppInfo(aSerialized, browsers[0], aAppId, aInBrowserElement);
|
||||
}
|
||||
|
||||
const char*
|
||||
NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
|
||||
PBrowserParent* aBrowser,
|
||||
|
@ -36,6 +36,13 @@ public:
|
||||
uint32_t* aAppId,
|
||||
bool* aInBrowserElement);
|
||||
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
static const char *
|
||||
GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
|
||||
PContentParent* aBrowser,
|
||||
uint32_t* aAppId,
|
||||
bool* aInBrowserElement);
|
||||
|
||||
/*
|
||||
* Creates LoadContext for parent-side of an e10s channel.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user