Bug 1493662 - Bug 1475387 follow-up: Remove use of nsDocShellLoadInfo and make nsIMsgMailNewsUrl.loadURI scriptable again. r=jorgk
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Mon, 24 Sep 2018 06:25:00 +0200
changeset 33230 d900f4b75757f47d21d8c9404488438c7724e877
parent 33229 9a567595d18a5e0a8aa8ba229fba6e080a82a620
child 33231 34eaca00ed364f73e4b43c1240e1d8a900655bce
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1493662, 1475387
Bug 1493662 - Bug 1475387 follow-up: Remove use of nsDocShellLoadInfo and make nsIMsgMailNewsUrl.loadURI scriptable again. r=jorgk
mailnews/base/public/nsIMsgMailNewsUrl.idl
mailnews/base/src/nsMessenger.cpp
mailnews/base/util/nsMsgMailNewsUrl.cpp
mailnews/imap/src/nsImapService.cpp
mailnews/local/src/nsMailboxService.cpp
mailnews/news/src/nsNntpService.cpp
--- a/mailnews/base/public/nsIMsgMailNewsUrl.idl
+++ b/mailnews/base/public/nsIMsgMailNewsUrl.idl
@@ -16,21 +16,16 @@ interface nsIMsgSearchSession;
 interface nsICacheEntry;
 interface nsIMimeHeaders;
 interface nsIStreamListener;
 interface nsIMsgFolder;
 interface nsIMsgHeaderSink;
 interface nsIMsgDBHdr;
 interface nsIDocShell;
 
-%{ C++
-class nsDocShellLoadInfo;
-%}
-native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
-
 [scriptable, builtinclass, uuid(995455ba-5bb4-4643-8d70-2b877a2e1320)]
 interface nsIMsgMailNewsUrl : nsIURL {
   [noscript,notxpcom,nostdcall]
   nsresult setFileNameInternal(in ACString aFileName);
 
   [noscript,notxpcom,nostdcall]
   nsresult setSpecInternal(in ACString aSpec);
 
@@ -111,31 +106,22 @@ interface nsIMsgMailNewsUrl : nsIURL {
   /**
    * Loads the URI in a docshell. This will give priority to loading the
    * URI in the passed-in docshell. If it can't be loaded there
    * however, the URL dispatcher will go through its normal process of content
    * loading.
    *
    * @param docshell     The docshell that will consume the load.
    *
-   * @param loadInfo     This is the extended load info for this load. This
-   *                     most often will be null, but if you need to do
-   *                     additional setup for this load you can get a loadInfo
-   *                     object by calling createLoadInfo. Once you have this
-   *                     object you can set the needed properties on it and
-   *                     then pass it to loadURI.
-   *
    * @param aLoadFlags   Flags to modify load behaviour. Flags are defined in
-   *                     nsIWebNavigation. Note that using flags outside
-   *                     LOAD_FLAGS_MASK is only allowed if passing in a
-   *                     non-null loadInfo. And even some of those might not
-   *                     be allowed. Use at your own risk. See nsIDocShell.idl
+   *                     nsIWebNavigation. Normally only LOAD_FLAGS_NONE or
+   *                     LOAD_FLAGS_IS_LINK is needed, but there are eleven
+   *                     other allowed sets of flags. See nsDocShellLoadTypes.h
    */
    void loadURI(in nsIDocShell docshell,
-                in nsDocShellLoadInfoPtr loadInfo,
                 in unsigned long aLoadFlags);
 
 };
 
 //////////////////////////////////////////////////////////////////////////////////
 // This is a very small interface which I'm grouping with the mailnewsUrl interface.
 // Several url types (mailbox, imap, nntp) have similar properties because they can
 // represent mail messages. For instance, these urls can be have URI
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -42,18 +42,16 @@
 #ifdef NS_PRINTING
 #include "nsIWebBrowserPrint.h"
 #include "nsMsgPrintEngine.h"
 #endif
 
 /* for access to docshell */
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
-#include "mozilla/net/ReferrerPolicy.h"
-#include "nsDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebNavigation.h"
 #include "nsContentUtils.h"
 
 // mail
 #include "nsIMsgMailNewsUrl.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgAccountManager.h"
@@ -584,22 +582,20 @@ nsMessenger::LoadURL(mozIDOMWindowProxy 
           headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader));
           if (dummyHeader && loadingFromFile)
             dummyHeader->SetMessageSize((uint32_t) fileSize);
         }
       }
     }
   }
 
-  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
-  loadInfo->SetLoadType(LOAD_NORMAL);
   AddMsgUrlToNavigateHistory(aURL);
   mNavigatingToUri.Truncate();
   mLastDisplayURI = aURL; // Remember the last uri we displayed.
-  return mDocShell->LoadURI(uri, loadInfo, 0, true);
+  return mDocShell->LoadURI(uri, nullptr, nsIWebNavigation::LOAD_FLAGS_NONE, true);
 }
 
 NS_IMETHODIMP nsMessenger::SaveAttachmentToFile(nsIFile *aFile,
                                                 const nsACString &aURL,
                                                 const nsACString &aMessageUri,
                                                 const nsACString &aContentType,
                                                 nsIUrlListener *aListener)
 {
--- a/mailnews/base/util/nsMsgMailNewsUrl.cpp
+++ b/mailnews/base/util/nsMsgMailNewsUrl.cpp
@@ -786,21 +786,20 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetMimeH
 
 NS_IMETHODIMP nsMsgMailNewsUrl::SetMimeHeaders(nsIMimeHeaders *mimeHeaders)
 {
     mMimeHeaders = mimeHeaders;
     return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgMailNewsUrl::LoadURI(nsIDocShell* docShell,
-                                        nsDocShellLoadInfo* loadInfo,
                                         uint32_t aLoadFlags)
 {
   NS_ENSURE_ARG_POINTER(docShell);
-  return docShell->LoadURI(this, loadInfo, aLoadFlags, false);
+  return docShell->LoadURI(this, nullptr, aLoadFlags, false);
 }
 
 #define SAVE_BUF_SIZE FILE_IO_BUFFER_SIZE
 class nsMsgSaveAsListener : public nsIStreamListener
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -14,18 +14,16 @@
 #include "nsIMsgFolder.h"
 #include "nsIMsgImapMailFolder.h"
 #include "nsIImapIncomingServer.h"
 #include "nsIImapServerSink.h"
 #include "nsIImapMockChannel.h"
 #include "nsImapUtils.h"
 #include "nsIMAPNamespace.h"
 #include "nsIDocShell.h"
-#include "mozilla/net/ReferrerPolicy.h"
-#include "nsDocShellLoadInfo.h"
 #include "nsIRDFService.h"
 #include "nsRDFCID.h"
 #include "nsIProgressEventSink.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsILoadGroup.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
@@ -615,27 +613,25 @@ nsresult nsImapService::FetchMimePart(ns
     }
     // if the display consumer is a docshell, then we should run the url in the docshell.
     // otherwise, it should be a stream listener....so open a channel using AsyncRead
     // and the provided stream listener....
 
     nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
     if (NS_SUCCEEDED(rv) && docShell)
     {
-      RefPtr<nsDocShellLoadInfo> loadInfo;
       // DIRTY LITTLE HACK --> if we are opening an attachment we want the docshell to
       // treat this load as if it were a user click event. Then the dispatching stuff will be much
       // happier.
-      if (aImapAction == nsImapUrl::nsImapOpenMimePart)
-      {
-        loadInfo = new nsDocShellLoadInfo();
-        loadInfo->SetLoadType(LOAD_LINK);
-      }
-
-      rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+      rv = docShell->LoadURI(url,
+                             nullptr,
+                             aImapAction == nsImapUrl::nsImapOpenMimePart
+                               ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
+                               : nsIWebNavigation::LOAD_FLAGS_NONE,
+                             false);
     }
     else
     {
       nsCOMPtr<nsIStreamListener> aStreamListener = do_QueryInterface(aDisplayConsumer, &rv);
       if (NS_SUCCEEDED(rv) && aStreamListener)
       {
         nsCOMPtr<nsIChannel> aChannel;
         nsCOMPtr<nsILoadGroup> loadGroup;
--- a/mailnews/local/src/nsMailboxService.cpp
+++ b/mailnews/local/src/nsMailboxService.cpp
@@ -16,18 +16,16 @@
 #include "nsTArray.h"
 #include "nsLocalUtils.h"
 #include "nsMsgLocalCID.h"
 #include "nsMsgBaseCID.h"
 #include "nsIDocShell.h"
 #include "nsMsgUtils.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsNetUtil.h"
-#include "mozilla/net/ReferrerPolicy.h"
-#include "nsDocShellLoadInfo.h"
 #include "nsIWebNavigation.h"
 #include "prprf.h"
 #include "nsIMsgHdr.h"
 #include "nsIFileURL.h"
 #include "mozilla/RefPtr.h"
 #include "nsIRDFService.h"
 
 nsMailboxService::nsMailboxService()
@@ -228,26 +226,25 @@ nsresult nsMailboxService::FetchMessage(
   if (i18nurl)
     i18nurl->SetCharsetOverRide(aCharsetOverride);
 
   // instead of running the mailbox url like we used to, let's try to run the url in the docshell...
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
   // if we were given a docShell, run the url in the docshell..otherwise just run it normally.
   if (NS_SUCCEEDED(rv) && docShell)
   {
-    RefPtr<nsDocShellLoadInfo> loadInfo;
     // DIRTY LITTLE HACK --> if we are opening an attachment we want the docshell to
     // treat this load as if it were a user click event. Then the dispatching stuff will be much
     // happier.
-    if (mailboxAction == nsIMailboxUrl::ActionFetchPart)
-    {
-      loadInfo = new nsDocShellLoadInfo();
-      loadInfo->SetLoadType(LOAD_LINK);
-    }
-    rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+    rv = docShell->LoadURI(url,
+                           nullptr,
+                           mailboxAction == nsIMailboxUrl::ActionFetchPart
+                             ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
+                             : nsIWebNavigation::LOAD_FLAGS_NONE,
+                           false);
   }
   else
     rv = RunMailboxUrl(url, aDisplayConsumer);
 
   if (aURL && mailboxurl)
     CallQueryInterface(mailboxurl, aURL);
 
   return rv;
@@ -358,23 +355,20 @@ NS_IMETHODIMP nsMailboxService::OpenAtta
   nsresult rv = NS_NewURI(getter_AddRefs(URL), urlString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // try to run the url in the docshell...
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
   // if we were given a docShell, run the url in the docshell..otherwise just run it normally.
   if (NS_SUCCEEDED(rv) && docShell)
   {
-    RefPtr<nsDocShellLoadInfo> loadInfo;
     // DIRTY LITTLE HACK --> since we are opening an attachment we want the docshell to
     // treat this load as if it were a user click event. Then the dispatching stuff will be much
     // happier.
-    loadInfo = new nsDocShellLoadInfo();
-    loadInfo->SetLoadType(LOAD_LINK);
-    return docShell->LoadURI(URL, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+    return docShell->LoadURI(URL, nullptr, nsIWebNavigation::LOAD_FLAGS_IS_LINK, false);
   }
   return RunMailboxUrl(URL, aDisplayConsumer);
 
 }
 
 
 NS_IMETHODIMP
 nsMailboxService::SaveMessageToDisk(const char *aMessageURI,
--- a/mailnews/news/src/nsNntpService.cpp
+++ b/mailnews/news/src/nsNntpService.cpp
@@ -17,18 +17,16 @@
 #include "nsMsgBaseCID.h"
 #include "nsNntpService.h"
 #include "nsIChannel.h"
 #include "nsILoadGroup.h"
 #include "nsCOMPtr.h"
 #include "nsIMsgAccountManager.h"
 #include "nsINntpIncomingServer.h"
 #include "nsIDocShell.h"
-#include "mozilla/net/ReferrerPolicy.h"
-#include "nsDocShellLoadInfo.h"
 #include "mozIDOMWindow.h"
 #include "nsIMsgSearchSession.h"
 #include "nsMailDirServiceDefs.h"
 #include "nsIWebNavigation.h"
 #include "nsNetCID.h"
 #include "nsNewsDownloader.h"
 #include "prprf.h"
 #include "nsICacheStorage.h"
@@ -301,27 +299,25 @@ nsresult nsNntpService::GetMessageFromUr
 {
   nsresult rv;
   // if the consumer is the docshell then we want to run the url in the webshell
   // in order to display it. If it isn't a docshell then just run the news url
   // like we would any other news url.
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
   if (NS_SUCCEEDED(rv))
   {
-    RefPtr<nsDocShellLoadInfo> loadInfo;
     // DIRTY LITTLE HACK --> if we are opening an attachment we want the docshell to
     // treat this load as if it were a user click event. Then the dispatching stuff will be much
     // happier.
-    if (mOpenAttachmentOperation)
-    {
-      loadInfo = new nsDocShellLoadInfo();
-      loadInfo->SetLoadType(LOAD_LINK);
-    }
-
-    rv = docShell->LoadURI(aUrl, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+    rv = docShell->LoadURI(aUrl,
+                           nullptr,
+                           mOpenAttachmentOperation
+                             ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
+                             : nsIWebNavigation::LOAD_FLAGS_NONE,
+                           false);
   }
   else
   {
     nsCOMPtr<nsIStreamListener> aStreamListener(do_QueryInterface(aDisplayConsumer, &rv));
     if (NS_SUCCEEDED(rv))
     {
       nsCOMPtr<nsIChannel> aChannel;
       nsCOMPtr<nsILoadGroup> aLoadGroup;
@@ -442,21 +438,17 @@ NS_IMETHODIMP nsNntpService::OpenAttachm
 //    if (msgMessageUrl)
 //      msgMessageUrl->SetOriginalSpec(newsUrl.get());
     // set up the url listener
     if (aUrlListener)
       msgUrl->RegisterListener(aUrlListener);
 
     nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
     if (NS_SUCCEEDED(rv) && docShell)
-    {
-      RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
-      loadInfo->SetLoadType(LOAD_LINK);
-      return docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
-    }
+      return docShell->LoadURI(url, nullptr, nsIWebNavigation::LOAD_FLAGS_IS_LINK, false);
     else
       return RunNewsUrl(url, aMsgWindow, aDisplayConsumer);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsNntpService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow)
 {