Bug 1243289 - UITour: Remove never used UrlbarCapture code. r=Gijs draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 26 Jan 2016 22:45:42 -0800
changeset 326036 fedba60ee85a23ce41ef23bed83231a4d1fca481
parent 325606 e93d49248f6972e100d089aeeca10a0ab50e375c
child 326040 8318b570e30569683076face4a2162bdd1497195
child 326041 9b503582a76811859ff0a8c6f9c89466b3189456
child 326045 e41296dd495b8b65db2afa5a0a4eaf92a26d76ae
child 326046 a662d2e95710ec3d5de3a4638a5c1cec2802d56e
push id10086
push usermozilla@noorenberghe.ca
push dateWed, 27 Jan 2016 06:46:06 +0000
reviewersGijs
bugs1243289
milestone46.0a1
Bug 1243289 - UITour: Remove never used UrlbarCapture code. r=Gijs
browser/components/uitour/UITour-lib.js
browser/components/uitour/UITour.jsm
--- a/browser/components/uitour/UITour-lib.js
+++ b/browser/components/uitour/UITour-lib.js
@@ -215,27 +215,16 @@ if (typeof Mozilla == 'undefined') {
 	};
 
 	Mozilla.UITour.hideMenu = function(name) {
 		_sendEvent('hideMenu', {
 			name: name
 		});
 	};
 
-	Mozilla.UITour.startUrlbarCapture = function(text, url) {
-		_sendEvent('startUrlbarCapture', {
-			text: text,
-			url: url
-		});
-	};
-
-	Mozilla.UITour.endUrlbarCapture = function() {
-		_sendEvent('endUrlbarCapture');
-	};
-
 	Mozilla.UITour.getConfiguration = function(configName, callback) {
 		_sendEvent('getConfiguration', {
 			callbackID: _waitForCallback(callback),
 			configuration: configName,
 		});
 	};
 
 	Mozilla.UITour.setConfiguration = function(configName, configValue) {
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -38,17 +38,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource:///modules/ReaderParent.jsm");
 
 // See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
 const PREF_LOG_LEVEL      = "browser.uitour.loglevel";
 const PREF_SEENPAGEIDS    = "browser.uitour.seenPageIDs";
 const PREF_READERVIEW_TRIGGER = "browser.uitour.readerViewTrigger";
 
 const BACKGROUND_PAGE_ACTIONS_ALLOWED = new Set([
-  "endUrlbarCapture",
   "forceShowReaderIcon",
   "getConfiguration",
   "getTreatmentTag",
   "hideHighlight",
   "hideInfo",
   "hideMenu",
   "ping",
   "registerPageID",
@@ -85,17 +84,16 @@ this.UITour = {
   url: null,
   seenPageIDs: null,
   // This map is not persisted and is used for
   // building the content source of a potential tour.
   pageIDsForSession: new Map(),
   pageIDSourceBrowsers: new WeakMap(),
   /* Map from browser chrome windows to a Set of <browser>s in which a tour is open (both visible and hidden) */
   tourBrowsersByWindow: new WeakMap(),
-  urlbarCapture: new WeakMap(),
   appMenuOpenForAnnotation: new Set(),
   availableTargetsCache: new WeakMap(),
   clearAvailableTargetsCache() {
     this.availableTargetsCache = new WeakMap();
   },
 
   _annotationPanelMutationObservers: new WeakMap(),
 
@@ -572,51 +570,16 @@ this.UITour = {
         break;
       }
 
       case "hideMenu": {
         this.hideMenu(window, data.name);
         break;
       }
 
-      case "startUrlbarCapture": {
-        if (typeof data.text != "string" || !data.text ||
-            typeof data.url != "string" || !data.url) {
-          log.warn("startUrlbarCapture: Text or URL not specified");
-          return false;
-        }
-
-        let uri = null;
-        try {
-          uri = Services.io.newURI(data.url, null, null);
-        } catch (e) {
-          log.warn("startUrlbarCapture: Malformed URL specified");
-          return false;
-        }
-
-        let secman = Services.scriptSecurityManager;
-        let contentDocument = browser.contentWindow.document;
-        let principal = contentDocument.nodePrincipal;
-        let flags = secman.DISALLOW_INHERIT_PRINCIPAL;
-        try {
-          secman.checkLoadURIWithPrincipal(principal, uri, flags);
-        } catch (e) {
-          log.warn("startUrlbarCapture: Orginating page doesn't have permission to open specified URL");
-          return false;
-        }
-
-        this.startUrlbarCapture(window, data.text, data.url);
-        break;
-      }
-
-      case "endUrlbarCapture": {
-        this.endUrlbarCapture(window);
-        break;
-      }
-
       case "getConfiguration": {
         if (typeof data.configuration != "string") {
           log.warn("getConfiguration: No configuration option specified");
           return false;
         }
 
         this.getConfiguration(messageManager, window, data.configuration, data.callbackID);
         break;
@@ -801,24 +764,16 @@ this.UITour = {
         break;
       }
 
       case "SSWindowClosing": {
         let window = aEvent.target;
         this.teardownTourForWindow(window);
         break;
       }
-
-      case "input": {
-        if (aEvent.target.id == "urlbar") {
-          let window = aEvent.target.ownerDocument.defaultView;
-          this.handleUrlbarInput(window);
-        }
-        break;
-      }
     }
   },
 
   observe: function(aSubject, aTopic, aData) {
     log.debug("observe: aTopic =", aTopic);
     switch (aTopic) {
       // The browser message manager is disconnected when the <browser> is
       // destroyed and we want to teardown at that point.
@@ -898,17 +853,16 @@ this.UITour = {
     aWindow.PanelUI.panel.removeEventListener("popuphidden", this.onPanelHidden);
     let loopPanel = aWindow.document.getElementById("loop-notification-panel");
     loopPanel.removeEventListener("popuphidden", this.onPanelHidden);
     loopPanel.removeEventListener("popuphiding", this.hideLoopPanelAnnotations);
     let controlCenterPanel = aWindow.gIdentityHandler._identityPopup;
     controlCenterPanel.removeEventListener("popuphidden", this.onPanelHidden);
     controlCenterPanel.removeEventListener("popuphiding", this.hideControlCenterAnnotations);
 
-    this.endUrlbarCapture(aWindow);
     this.resetTheme();
 
     // If there are no more tour tabs left in the window, teardown the tour for the whole window.
     if (!openTourBrowsers || openTourBrowsers.size == 0) {
       this.teardownTourForWindow(aWindow);
     }
   },
 
@@ -1758,51 +1712,16 @@ this.UITour = {
       aPanel.clientWidth; // flush
       return;
     }
     aPanel.hidden = true;
     aPanel.clientWidth; // flush
     aPanel.hidden = false;
   },
 
-  startUrlbarCapture: function(aWindow, aExpectedText, aUrl) {
-    let urlbar = aWindow.document.getElementById("urlbar");
-    this.urlbarCapture.set(aWindow, {
-      expected: aExpectedText.toLocaleLowerCase(),
-      url: aUrl
-    });
-    urlbar.addEventListener("input", this);
-  },
-
-  endUrlbarCapture: function(aWindow) {
-    let urlbar = aWindow.document.getElementById("urlbar");
-    urlbar.removeEventListener("input", this);
-    this.urlbarCapture.delete(aWindow);
-  },
-
-  handleUrlbarInput: function(aWindow) {
-    if (!this.urlbarCapture.has(aWindow))
-      return;
-
-    let urlbar = aWindow.document.getElementById("urlbar");
-
-    let {expected, url} = this.urlbarCapture.get(aWindow);
-
-    if (urlbar.value.toLocaleLowerCase().localeCompare(expected) != 0)
-      return;
-
-    urlbar.handleRevert();
-
-    let tab = aWindow.gBrowser.addTab(url, {
-      owner: aWindow.gBrowser.selectedTab,
-      relatedToCurrent: true
-    });
-    aWindow.gBrowser.selectedTab = tab;
-  },
-
   getConfiguration: function(aMessageManager, aWindow, aConfiguration, aCallbackID) {
     switch (aConfiguration) {
       case "appinfo":
         let props = ["defaultUpdateChannel", "version"];
         let appinfo = {};
         props.forEach(property => appinfo[property] = Services.appinfo[property]);
         let isDefaultBrowser = null;
         try {