mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186920 - Fix b2g applications that use cookies. r=gwagner
This commit is contained in:
parent
48aa856131
commit
ad5b34efee
@ -21,27 +21,39 @@ using mozilla::net::NeckoParent;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool
|
// Ignore failures from this function, as they only affect whether we do or
|
||||||
CreateDummyChannel(nsIURI* aHostURI, bool aIsPrivate, nsIChannel **aChannel)
|
// don't show a dialog box in private browsing mode if the user sets a pref.
|
||||||
|
void
|
||||||
|
CreateDummyChannel(nsIURI* aHostURI, uint32_t aAppId, bool aInMozBrowser,
|
||||||
|
bool aIsPrivate, nsIChannel **aChannel)
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID);
|
||||||
|
|
||||||
nsCOMPtr<nsIPrincipal> principal;
|
nsCOMPtr<nsIPrincipal> principal;
|
||||||
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
||||||
nsresult rv = ssm->GetNoAppCodebasePrincipal(aHostURI, getter_AddRefs(principal));
|
nsresult rv = ssm->GetAppCodebasePrincipal(aHostURI, aAppId, aInMozBrowser,
|
||||||
|
getter_AddRefs(principal));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return false;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIURI> dummyURI;
|
||||||
|
rv = NS_NewURI(getter_AddRefs(dummyURI), "about:blank");
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> dummyChannel;
|
nsCOMPtr<nsIChannel> dummyChannel;
|
||||||
NS_NewChannel(getter_AddRefs(dummyChannel), aHostURI, principal,
|
NS_NewChannel(getter_AddRefs(dummyChannel), dummyURI, principal,
|
||||||
nsILoadInfo::SEC_NORMAL, nsIContentPolicy::TYPE_INVALID);
|
nsILoadInfo::SEC_NORMAL, nsIContentPolicy::TYPE_INVALID);
|
||||||
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(dummyChannel);
|
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(dummyChannel);
|
||||||
if (!pbChannel) {
|
if (!pbChannel) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbChannel->SetPrivate(aIsPrivate);
|
pbChannel->SetPrivate(aIsPrivate);
|
||||||
dummyChannel.forget(aChannel);
|
dummyChannel.forget(aChannel);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -163,10 +175,10 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
|
|||||||
// with aIsForeign before we have to worry about nsCookiePermission trying
|
// with aIsForeign before we have to worry about nsCookiePermission trying
|
||||||
// to use the channel to inspect it.
|
// to use the channel to inspect it.
|
||||||
nsCOMPtr<nsIChannel> dummyChannel;
|
nsCOMPtr<nsIChannel> dummyChannel;
|
||||||
if (!CreateDummyChannel(hostURI, isPrivate, getter_AddRefs(dummyChannel))) {
|
CreateDummyChannel(hostURI, appId, isInBrowserElement,
|
||||||
return false;
|
isPrivate, getter_AddRefs(dummyChannel));
|
||||||
}
|
|
||||||
|
|
||||||
|
// NB: dummyChannel could be null if something failed in CreateDummyChannel.
|
||||||
nsDependentCString cookieString(aCookieString, 0);
|
nsDependentCString cookieString(aCookieString, 0);
|
||||||
mCookieService->SetCookieStringInternal(hostURI, aIsForeign, cookieString,
|
mCookieService->SetCookieStringInternal(hostURI, aIsForeign, cookieString,
|
||||||
aServerTime, aFromHttp, appId,
|
aServerTime, aFromHttp, appId,
|
||||||
|
Loading…
Reference in New Issue
Block a user