On 19/08/2013 4:03 PM, Boris Zbarsky wrote:
On 8/16/13 1:37 PM, Jason Duell wrote:
bz/biesi: so for Mark's issue, could we just add LOAD_ANONYMOUS to the
list here?
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsLoadGroup.cpp#1035>.
I think so, yes.
This doesn't seem to have any effect in my simple tests. After setting
'docShell.loadGroup.loadFlags |= Ci.nsIChannel.LOAD_ANONYMOUS;' we load
a URI with nsIWebNavigation::loadURI.
This ends up calling nsDocShell::DoURILoad(), which ends up calling
NS_NewChannel() at
http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp#9451
- and while mLoadGroup->mLoadFlags has LOAD_ANONYMOUS, this flag doesn't
end up on the new channel.
Next nsDocShell::DoChannelLoad() load is called, and while this also
touches the channel loadFlags, it also doesn't do anything with
LOAD_ANONYMOUS.
Then the channel loads, and best I can tell,
nsLoadGroup::MergeLoadFlags() isn't actually called here - but note that
in my test there are no sub-requests, which probably explains this.
So in my case, it seems this flag isn't ending up on the *default*
request, let alone subrequests.
On 8/18/13 8:19 PM, Brian Smith wrote:
If I were to attempt this, I would follow the example here:
https://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp?rev=9fd000703ace#9426
i.e. I would set a flag/property on the docshell and then I would modify
DoURILoad to check that flag (on the current docshell, and on the parent)
and set the LOAD_ANONYMOUS flag on the channel as needed.
That wouldn't set LOAD_ANONYMOUS on the various subrequests for the document
loaded in the docshell (scripts, images, etc).
Note that this (obviously) works for the primary request. Given it
seems likely the suggested fix in nsLoadGroup.cpp will set this flag on
subrequests, is it possible I need to do both?
FWIW, I'm attaching a quick-and-nasty patch that does both of these and
in fairly limited testing, seems to do what I need. Thoughts/feedback
welcome!
Thanks,
Mark
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index e72cfb3..5308432 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -771,6 +771,7 @@ nsDocShell::nsDocShell():
mIsAppTab(false),
mUseGlobalHistory(false),
mInPrivateBrowsing(false),
+ mIsAnonymous(false),
mFiredUnloadEvent(false),
mEODForCurrentDocument(false),
mURIResultedInDocument(false),
@@ -2873,6 +2874,10 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
{
SetIsActive(value);
}
+ if (NS_SUCCEEDED(parentAsDocShell->GetIsAnonymous(&value)))
+ {
+ SetIsAnonymous(value);
+ }
if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) {
value = false;
}
@@ -5335,6 +5340,21 @@ nsDocShell::GetIsActive(bool *aIsActive)
}
NS_IMETHODIMP
+nsDocShell::SetIsAnonymous(bool aIsAnonymous)
+{
+ mIsAnonymous = aIsAnonymous;
+ // XXX - should I iterate over children like SetIsActive does?
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsDocShell::GetIsAnonymous(bool *aIsAnonymous)
+{
+ *aIsAnonymous = mIsAnonymous;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
nsDocShell::SetIsAppTab(bool aIsAppTab)
{
mIsAppTab = aIsAppTab;
@@ -9422,6 +9442,18 @@ nsDocShell::DoURILoad(nsIURI * aURI,
// Error pages are LOAD_BACKGROUND
loadFlags |= nsIChannel::LOAD_BACKGROUND;
}
+ if (mIsAnonymous) {
+ loadFlags |= nsIChannel::LOAD_ANONYMOUS;
+ } else {
+ // but maybe the parent is
+ nsCOMPtr<nsIDocShellTreeItem> parentItem;
+ GetSameTypeParent(getter_AddRefs(parentItem));
+ nsCOMPtr<nsIDocShell> parentDocShell = do_GetInterface(parentItem);
+ bool anon;
+ if (parentDocShell && parentDocShell->GetIsAnonymous(&anon)) {
+ loadFlags |= nsIChannel::LOAD_ANONYMOUS;
+ }
+ }
// check for Content Security Policy to pass along with the
// new channel we are creating
diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h
index 454ec92..5b7d5a2 100644
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -824,6 +824,7 @@ protected:
bool mIsAppTab;
bool mUseGlobalHistory;
bool mInPrivateBrowsing;
+ bool mIsAnonymous;
// This boolean is set to true right before we fire pagehide and generally
// unset when we embed a new content viewer. While it's true no navigation
diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl
index 3f41109..9664df6 100644
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -42,7 +42,7 @@ interface nsIVariant;
interface nsIPrivacyTransitionObserver;
interface nsIReflowObserver;
-[scriptable, builtinclass, uuid(b5bd6052-ec8c-45bf-b55c-409ad15cecfb)]
+[scriptable, builtinclass, uuid(9ddad412-664f-4b57-bdcc-ecf9a256df88)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@@ -545,6 +545,15 @@ interface nsIDocShell : nsIDocShellTreeItem
attribute boolean isActive;
/**
+ * Sets whether the docshell should only make requests with
+ * nsIRequest::LOAD_ANONYMOUS set. docShells are not anonymous until this
+ * flag is set.
+ */
+ // XXX MARKH - maybe this should be 'loadAnonymous' to reflect that things
+ // already loaded by the docShell aren't magically going to be anonymized?
+ attribute boolean isAnonymous;
+
+ /**
* The ID of the docshell in the session history.
*/
readonly attribute unsigned long long historyID;
diff --git a/netwerk/base/src/nsLoadGroup.cpp b/netwerk/base/src/nsLoadGroup.cpp
index 3220230..7ebfc7a 100644
--- a/netwerk/base/src/nsLoadGroup.cpp
+++ b/netwerk/base/src/nsLoadGroup.cpp
@@ -1033,7 +1033,8 @@ nsresult nsLoadGroup::MergeLoadFlags(nsIRequest
*aRequest, nsLoadFlags& outFlags
oldFlags = flags;
// Inherit the following bits...
- flags |= (mLoadFlags & (LOAD_BACKGROUND |
+ flags |= (mLoadFlags & (LOAD_ANONYMOUS |
+ LOAD_BACKGROUND |
LOAD_BYPASS_CACHE |
LOAD_FROM_CACHE |
VALIDATE_ALWAYS |
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network