Bug 1443371 - Remove unused page descriptor in viewSourceUtils.js. r=bdahl draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 06 Mar 2018 08:12:39 -0600
changeset 763679 3308ca8687d1fa9898344e6b4dde11eb5aea4085
parent 763678 5ae2effc012d48333000d7c4ffd9d1b2cc120182
push id101524
push userbmo:jryans@gmail.com
push dateTue, 06 Mar 2018 14:14:34 +0000
reviewersbdahl
bugs1443371, 1418403
milestone60.0a1
Bug 1443371 - Remove unused page descriptor in viewSourceUtils.js. r=bdahl `openInExternalEditor` used to accept a page descriptor as a deprecated arg, but this is no longer possible after bug 1418403. MozReview-Commit-ID: codNqEOemu
toolkit/components/viewsource/content/viewSourceUtils.js
--- a/toolkit/components/viewsource/content/viewSourceUtils.js
+++ b/toolkit/components/viewsource/content/viewSourceUtils.js
@@ -212,52 +212,37 @@ var gViewSourceUtils = {
           resolve(data);
         } else {
           // set up the progress listener with what we know so far
           this.viewSourceProgressListener.contentLoaded = false;
           this.viewSourceProgressListener.editor = editor;
           this.viewSourceProgressListener.resolve = resolve;
           this.viewSourceProgressListener.reject = reject;
           this.viewSourceProgressListener.data = data;
-          if (!data.pageDescriptor) {
-            // without a page descriptor, loadPage has no chance of working. download the file.
-            var file = this.getTemporaryFile(uri, data.doc, contentType);
-            this.viewSourceProgressListener.file = file;
 
-            var webBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
-              .createInstance(this.mnsIWebBrowserPersist);
-            // the default setting is to not decode. we need to decode.
-            webBrowserPersist.persistFlags = this.mnsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
-            webBrowserPersist.progressListener = this.viewSourceProgressListener;
-            let referrerPolicy = Ci.nsIHttpChannel.REFERRER_POLICY_NO_REFERRER;
-            webBrowserPersist.savePrivacyAwareURI(uri, null, null, referrerPolicy, null, null, file, data.isPrivate);
+          // without a page descriptor, loadPage has no chance of working. download the file.
+          var file = this.getTemporaryFile(uri, data.doc, contentType);
+          this.viewSourceProgressListener.file = file;
 
-            let helperService = Cc["@mozilla.org/uriloader/external-helper-app-service;1"]
-              .getService(Ci.nsPIExternalAppLauncher);
-            if (data.isPrivate) {
-              // register the file to be deleted when possible
-              helperService.deleteTemporaryPrivateFileWhenPossible(file);
-            } else {
-              // register the file to be deleted on app exit
-              helperService.deleteTemporaryFileOnExit(file);
-            }
+          var webBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+            .createInstance(this.mnsIWebBrowserPersist);
+          // the default setting is to not decode. we need to decode.
+          webBrowserPersist.persistFlags = this.mnsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
+          webBrowserPersist.progressListener = this.viewSourceProgressListener;
+          let referrerPolicy = Ci.nsIHttpChannel.REFERRER_POLICY_NO_REFERRER;
+          webBrowserPersist.savePrivacyAwareURI(uri, null, null, referrerPolicy, null, null, file, data.isPrivate);
+
+          let helperService = Cc["@mozilla.org/uriloader/external-helper-app-service;1"]
+            .getService(Ci.nsPIExternalAppLauncher);
+          if (data.isPrivate) {
+            // register the file to be deleted when possible
+            helperService.deleteTemporaryPrivateFileWhenPossible(file);
           } else {
-            // we'll use nsIWebPageDescriptor to get the source because it may
-            // not have to refetch the file from the server
-            // XXXbz this is so broken...  This code doesn't set up this docshell
-            // at all correctly; if somehow the view-source stuff managed to
-            // execute script we'd be in big trouble here, I suspect.
-            var webShell = Cc["@mozilla.org/docshell;1"].createInstance();
-            webShell.QueryInterface(Ci.nsIBaseWindow).create();
-            this.viewSourceProgressListener.webShell = webShell;
-            var progress = webShell.QueryInterface(this.mnsIWebProgress);
-            progress.addProgressListener(this.viewSourceProgressListener,
-              this.mnsIWebProgress.NOTIFY_STATE_DOCUMENT);
-            var pageLoader = webShell.QueryInterface(this.mnsIWebPageDescriptor);
-            pageLoader.loadPage(data.pageDescriptor, this.mnsIWebPageDescriptor.DISPLAY_AS_SOURCE);
+            // register the file to be deleted on app exit
+            helperService.deleteTemporaryFileOnExit(file);
           }
         }
       } catch (ex) {
         // we failed loading it with the external editor.
         Cu.reportError(ex);
         reject(data);
       }
     });