Bug 1500347 - Port Bug 1492648: nsIDocShell.loadURI() takes a nsDocShellLoadState parameter now. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Fri, 19 Oct 2018 10:32:36 +0200
changeset 33620 251d4aa464d29dc07d749dcd9aeb971fc8596201
parent 33619 9abb0344923c81781c50a0ac3983161bd032bec3
child 33621 fd1f4b9f6638f3f9c81a65ad651ac536187e5a7b
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersbustage-fix
bugs1500347, 1492648
Bug 1500347 - Port Bug 1492648: nsIDocShell.loadURI() takes a nsDocShellLoadState parameter now. rs=bustage-fix
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/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -45,16 +45,17 @@
 #endif
 
 /* for access to docshell */
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebNavigation.h"
 #include "nsContentUtils.h"
+#include "nsDocShellLoadState.h"
 
 // mail
 #include "nsIMsgMailNewsUrl.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIMsgMailSession.h"
 #include "nsIMailboxUrl.h"
 #include "nsIMsgFolder.h"
@@ -585,17 +586,21 @@ nsMessenger::LoadURL(mozIDOMWindowProxy 
         }
       }
     }
   }
 
   AddMsgUrlToNavigateHistory(aURL);
   mNavigatingToUri.Truncate();
   mLastDisplayURI = aURL; // Remember the last uri we displayed.
-  return mDocShell->LoadURI(uri, nullptr, nsIWebNavigation::LOAD_FLAGS_NONE, true);
+  RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+  loadState->SetURI(uri);
+  loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
+  loadState->SetFirstParty(true);
+  return mDocShell->LoadURI(loadState);
 }
 
 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
@@ -22,16 +22,17 @@
 #include "nsNetUtil.h"
 #include "nsIFile.h"
 #include "prmem.h"
 #include <time.h>
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 #include "nsProxyRelease.h"
 #include "mozilla/Encoding.h"
+#include "nsDocShellLoadState.h"
 
 nsMsgMailNewsUrl::nsMsgMailNewsUrl()
 {
   // nsIURI specific state
   m_runningUrl = false;
   m_updatingFolder = false;
   m_msgIsInLocalCache = false;
   m_suppressErrorMsgs = false;
@@ -789,17 +790,22 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetMimeH
     mMimeHeaders = mimeHeaders;
     return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgMailNewsUrl::LoadURI(nsIDocShell* docShell,
                                         uint32_t aLoadFlags)
 {
   NS_ENSURE_ARG_POINTER(docShell);
-  return docShell->LoadURI(this, nullptr, aLoadFlags, false);
+  RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+  loadState->SetURI(this);
+  loadState->SetLoadFlags(aLoadFlags);
+  loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags));
+  loadState->SetFirstParty(false);
+  return docShell->LoadURI(loadState);
 }
 
 #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
@@ -58,16 +58,17 @@
 #include "nsIMsgMailSession.h"
 #include "nsIStreamConverterService.h"
 #include "nsIAutoSyncManager.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsMsgMessageFlags.h"
 #include "nsIMsgPluggableStore.h"
 #include "../../base/src/MailnewsLoadContextInfo.h"
+#include "nsDocShellLoadState.h"
 
 #define PREF_MAIL_ROOT_IMAP "mail.root.imap"            // old - for backward compatibility only
 #define PREF_MAIL_ROOT_IMAP_REL "mail.root.imap-rel"
 
 static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
 static NS_DEFINE_CID(kCImapMockChannel, NS_IMAPMOCKCHANNEL_CID);
 
 static const char sequenceString[] = "SEQUENCE";
@@ -618,22 +619,25 @@ nsresult nsImapService::FetchMimePart(ns
     // and the provided stream listener....
 
     nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
     if (NS_SUCCEEDED(rv) && docShell)
     {
       // 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.
-      rv = docShell->LoadURI(url,
-                             nullptr,
-                             aImapAction == nsImapUrl::nsImapOpenMimePart
-                               ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
-                               : nsIWebNavigation::LOAD_FLAGS_NONE,
-                             false);
+      RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+      loadState->SetURI(url);
+      loadState->SetLoadFlags(aImapAction == nsImapUrl::nsImapOpenMimePart
+                                ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
+                                : nsIWebNavigation::LOAD_FLAGS_NONE);
+      if (aImapAction == nsImapUrl::nsImapOpenMimePart)
+        loadState->SetLoadType(LOAD_LINK);
+      loadState->SetFirstParty(false);
+      rv = docShell->LoadURI(loadState);
     }
     else
     {
       nsCOMPtr<nsIStreamListener> aStreamListener = do_QueryInterface(aDisplayConsumer, &rv);
       if (NS_SUCCEEDED(rv) && aStreamListener)
       {
         nsCOMPtr<nsIChannel> aChannel;
         nsCOMPtr<nsILoadGroup> loadGroup;
@@ -1053,17 +1057,21 @@ nsresult nsImapService::GetMessageFromUr
         aImapServer(do_QueryInterface(aMsgIncomingServer, &rv));
       if (NS_SUCCEEDED(rv) && aImapServer)
         aImapServer->PseudoInterruptMsgLoad(aImapMailFolder, aMsgWindow, &interrupted);
     }
   }
   if (NS_SUCCEEDED(rv) && docShell)
   {
     NS_ASSERTION(!aConvertDataToText, "can't convert to text when using docshell");
-    rv = docShell->LoadURI(url, nullptr, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+    RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+    loadState->SetURI(url);
+    loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
+    loadState->SetFirstParty(false);
+    rv = docShell->LoadURI(loadState);
   }
   else
   {
     nsCOMPtr<nsIStreamListener> streamListener = do_QueryInterface(aDisplayConsumer, &rv);
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl, &rv);
     if (aMsgWindow && mailnewsUrl)
       mailnewsUrl->SetMsgWindow(aMsgWindow);
     if (NS_SUCCEEDED(rv) && streamListener)
--- a/mailnews/local/src/nsMailboxService.cpp
+++ b/mailnews/local/src/nsMailboxService.cpp
@@ -21,16 +21,17 @@
 #include "nsMsgUtils.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsNetUtil.h"
 #include "nsIWebNavigation.h"
 #include "prprf.h"
 #include "nsIMsgHdr.h"
 #include "nsIFileURL.h"
 #include "mozilla/RefPtr.h"
+#include "nsDocShellLoadState.h"
 #include "nsIRDFService.h"
 
 nsMailboxService::nsMailboxService()
 {
     mPrintingOperation = false;
 }
 
 nsMailboxService::~nsMailboxService()
@@ -229,22 +230,25 @@ nsresult nsMailboxService::FetchMessage(
   // 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)
   {
     // 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.
-    rv = docShell->LoadURI(url,
-                           nullptr,
-                           mailboxAction == nsIMailboxUrl::ActionFetchPart
-                             ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
-                             : nsIWebNavigation::LOAD_FLAGS_NONE,
-                           false);
+    RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+    loadState->SetURI(url);
+    loadState->SetLoadFlags(mailboxAction == nsIMailboxUrl::ActionFetchPart
+                              ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
+                              : nsIWebNavigation::LOAD_FLAGS_NONE);
+    if (mailboxAction == nsIMailboxUrl::ActionFetchPart)
+      loadState->SetLoadType(LOAD_LINK);
+    loadState->SetFirstParty(false);
+    rv = docShell->LoadURI(loadState);
   }
   else
     rv = RunMailboxUrl(url, aDisplayConsumer);
 
   if (aURL && mailboxurl)
     CallQueryInterface(mailboxurl, aURL);
 
   return rv;
@@ -358,17 +362,22 @@ NS_IMETHODIMP nsMailboxService::OpenAtta
   // 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)
   {
     // 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.
-    return docShell->LoadURI(URL, nullptr, nsIWebNavigation::LOAD_FLAGS_IS_LINK, false);
+    RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+    loadState->SetURI(URL);
+    loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_IS_LINK);
+    loadState->SetLoadType(LOAD_LINK);
+    loadState->SetFirstParty(false);
+    return docShell->LoadURI(loadState);
   }
   return RunMailboxUrl(URL, aDisplayConsumer);
 
 }
 
 
 NS_IMETHODIMP
 nsMailboxService::SaveMessageToDisk(const char *aMessageURI,
--- a/mailnews/news/src/nsNntpService.cpp
+++ b/mailnews/news/src/nsNntpService.cpp
@@ -38,16 +38,17 @@
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgMailSession.h"
 #include "nsISupportsPrimitives.h"
 #include "nsArrayUtils.h"
 #include "nsIStreamListener.h"
 #include "nsIInputStream.h"
 #include "nsIURIMutator.h"
 #include "nsTArray.h"
+#include "nsDocShellLoadState.h"
 
 #include "../../base/src/MailnewsLoadContextInfo.h"
 
 #undef GetPort  // XXX Windows!
 #undef SetPort  // XXX Windows!
 
 #define PREF_MAIL_ROOT_NNTP   "mail.root.nntp"        // old - for backward compatibility only
 #define PREF_MAIL_ROOT_NNTP_REL   "mail.root.nntp-rel"
@@ -302,22 +303,25 @@ nsresult nsNntpService::GetMessageFromUr
   // 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))
   {
     // 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.
-    rv = docShell->LoadURI(aUrl,
-                           nullptr,
-                           mOpenAttachmentOperation
-                             ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
-                             : nsIWebNavigation::LOAD_FLAGS_NONE,
-                           false);
+    RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+    loadState->SetURI(aUrl);
+    loadState->SetLoadFlags(mOpenAttachmentOperation
+                              ? nsIWebNavigation::LOAD_FLAGS_IS_LINK
+                              : nsIWebNavigation::LOAD_FLAGS_NONE);
+    if (mOpenAttachmentOperation)
+      loadState->SetLoadType(LOAD_LINK);
+    loadState->SetFirstParty(false);
+    rv = docShell->LoadURI(loadState);
   }
   else
   {
     nsCOMPtr<nsIStreamListener> aStreamListener(do_QueryInterface(aDisplayConsumer, &rv));
     if (NS_SUCCEEDED(rv))
     {
       nsCOMPtr<nsIChannel> aChannel;
       nsCOMPtr<nsILoadGroup> aLoadGroup;
@@ -437,20 +441,26 @@ NS_IMETHODIMP nsNntpService::OpenAttachm
 //   nsCOMPtr<nsIMsgMessageUrl> msgMessageUrl = do_QueryInterface(url);
 //    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)
-      return docShell->LoadURI(url, nullptr, nsIWebNavigation::LOAD_FLAGS_IS_LINK, false);
-    else
+    if (NS_SUCCEEDED(rv) && docShell) {
+      RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
+      loadState->SetURI(url);
+      loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_IS_LINK);
+      loadState->SetLoadType(LOAD_LINK);
+      loadState->SetFirstParty(false);
+      return docShell->LoadURI(loadState);
+    } else {
       return RunNewsUrl(url, aMsgWindow, aDisplayConsumer);
+    }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsNntpService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow)
 {
   nsresult rv = NS_OK;