From 8ace8c51a590837fe4b4e4d386ad99b7ac549c74 Mon Sep 17 00:00:00 2001 From: Yoshi Huang Date: Thu, 19 May 2016 15:49:41 +0800 Subject: [PATCH] Bug 1244340 - Part 1: Use origin attributes as cstor arg for LoadContext r=sicking --- docshell/base/LoadContext.h | 8 ++++---- toolkit/components/downloads/ApplicationReputation.cpp | 6 ++++-- .../url-classifier/nsUrlClassifierStreamUpdater.cpp | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/docshell/base/LoadContext.h b/docshell/base/LoadContext.h index b31800a9fa31..c93a1ea1e5c5 100644 --- a/docshell/base/LoadContext.h +++ b/docshell/base/LoadContext.h @@ -93,14 +93,14 @@ public: MOZ_ASSERT(aUsePrivateBrowsing == (aAttrs.mPrivateBrowsingId != 0)); } - // Constructor taking reserved appId for the safebrowsing cookie. - explicit LoadContext(uint32_t aAppId) + // Constructor taking reserved origin attributes. + explicit LoadContext(DocShellOriginAttributes& aAttrs) : mTopFrameElement(nullptr) , mNestedFrameId(0) , mIsContent(false) - , mUsePrivateBrowsing(false) + , mUsePrivateBrowsing(aAttrs.mPrivateBrowsingId != 0) , mUseRemoteTabs(false) - , mOriginAttributes(aAppId, false) + , mOriginAttributes(aAttrs) #ifdef DEBUG , mIsNotNull(true) #endif diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp index 506e7587535b..6828bc24b287 100644 --- a/toolkit/components/downloads/ApplicationReputation.cpp +++ b/toolkit/components/downloads/ApplicationReputation.cpp @@ -52,6 +52,7 @@ #include "nsContentUtils.h" using mozilla::BasePrincipal; +using mozilla::DocShellOriginAttributes; using mozilla::PrincipalOriginAttributes; using mozilla::Preferences; using mozilla::TimeStamp; @@ -1282,8 +1283,9 @@ PendingLookup::SendRemoteQueryInternal() // Set the Safebrowsing cookie jar, so that the regular Google cookie is not // sent with this request. See bug 897516. - nsCOMPtr loadContext = - new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID); + DocShellOriginAttributes attrs; + attrs.mAppId = NECKO_SAFEBROWSING_APP_ID; + nsCOMPtr loadContext = new mozilla::LoadContext(attrs); rv = mChannel->SetNotificationCallbacks(loadContext); NS_ENSURE_SUCCESS(rv, rv); diff --git a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp index 177440cfea41..d1c14c9c1f26 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp @@ -24,6 +24,8 @@ #include "nsContentUtils.h" #include "nsIURLFormatter.h" +using mozilla::DocShellOriginAttributes; + static const char* gQuitApplicationMessage = "quit-application"; // Limit the list file size to 32mb @@ -178,8 +180,9 @@ nsUrlClassifierStreamUpdater::FetchUpdate(nsIURI *aUpdateUrl, // Create a custom LoadContext for SafeBrowsing, so we can use callbacks on // the channel to query the appId which allows separation of safebrowsing // cookies in a separate jar. - nsCOMPtr sbContext = - new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID); + DocShellOriginAttributes attrs; + attrs.mAppId = NECKO_SAFEBROWSING_APP_ID; + nsCOMPtr sbContext = new mozilla::LoadContext(attrs); rv = mChannel->SetNotificationCallbacks(sbContext); NS_ENSURE_SUCCESS(rv, rv);