From e5e17a6285b76fe29b28e6e76c60173cbffdf4e4 Mon Sep 17 00:00:00 2001 From: "beng%bengoodger.com" Date: Tue, 27 Jun 2006 19:54:47 +0000 Subject: [PATCH] 336903 - feeds should not run with chrome privileges. Expose a currentDocumentChannel attribute on nsIDocShell to look at the channel of the currently loaded page (so that we can find out its actual real URI, etc vs. what webNavigation thinks it is (originalURI). r=bz sr=darin git-svn-id: svn://10.0.0.236/trunk@201021 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 21 +++++++++++++++++++++ mozilla/docshell/base/nsIDocShell.idl | 10 +++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 78e357a6d08..765f4d79663 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -1739,6 +1739,27 @@ nsDocShell::AddSessionStorage(const nsACString& aDomain, return NS_OK; } +NS_IMETHODIMP +nsDocShell::GetCurrentDocumentChannel(nsIChannel** aResult) +{ + *aResult = nsnull; + if (!mContentViewer) + return NS_OK; + + nsCOMPtr domDoc; + nsresult rv = mContentViewer->GetDOMDocument(getter_AddRefs(domDoc)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr doc(do_QueryInterface(domDoc)); + if (doc) { + *aResult = doc->GetChannel(); + NS_IF_ADDREF(*aResult); + } + + return NS_OK; +} + //***************************************************************************** // nsDocShell::nsIDocShellTreeItem //***************************************************************************** diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index f417e1eec1a..9e864d3ee6d 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -53,6 +53,7 @@ class nsIPresShell; [ptr] native nsIPresShell(nsIPresShell); interface nsIURI; +interface nsIChannel; interface nsIContentViewer; interface nsIURIContentListener; interface nsIChromeEventHandler; @@ -67,7 +68,7 @@ interface nsILayoutHistoryState; interface nsISecureBrowserUI; interface nsIDOMStorage; -[scriptable, uuid(616b8670-d170-11da-a94d-0800200c9a66)] +[scriptable, uuid(51241d7c-73c9-4b85-970c-bd4f91acfbcc)] interface nsIDocShell : nsISupports { /** @@ -421,5 +422,12 @@ interface nsIDocShell : nsISupports * @param storage the storage object to add */ void addSessionStorage(in ACString aDomain, in nsIDOMStorage storage); + + /** + * Gets the channel for the currently loaded document, if any. + * For a new document load, this will be the channel of the previous document + * until after OnLocationChange fires. + */ + readonly attribute nsIChannel currentDocumentChannel; };