Bug 952894 - Use existing triggers to clear open search engines state. r=rnewman, a=lsblakk
authorMark Finkle <mfinkle@mozilla.com>
Sat, 28 Dec 2013 22:14:13 -0500
changeset 175537 b71255e32a12433b7b65e77bb41b97d1db3f2d40
parent 175536 5a1f8b015361e6e87213a0f7229ba523f3572ab0
child 175538 de2c488ac3178015293818aef24999e0a78d713e
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, lsblakk
bugs952894
milestone28.0a2
Bug 952894 - Use existing triggers to clear open search engines state. r=rnewman, a=lsblakk
mobile/android/base/Tab.java
mobile/android/base/resources/menu/titlebar_contextmenu.xml
mobile/android/base/toolbar/BrowserToolbar.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -648,16 +648,17 @@ public class Tab {
 
         // We can unconditionally clear the favicon here: we already
         // short-circuited for both cases in which this was a (pseudo-)
         // spurious location change, so we're definitely loading a new page.
         // The same applies to all of the other fields we're wiping out.
         clearFavicon();
 
         setHasFeeds(false);
+        setHasOpenSearch(false);
         updateTitle(null);
         updateIdentityData(null);
         setReaderEnabled(false);
         setZoomConstraints(new ZoomConstraints(true));
         setHasTouchListeners(false);
         setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
         setErrorType(ErrorType.NONE);
 
--- a/mobile/android/base/resources/menu/titlebar_contextmenu.xml
+++ b/mobile/android/base/resources/menu/titlebar_contextmenu.xml
@@ -13,18 +13,17 @@
 
     <item android:id="@+id/share"
           android:title="@string/contextmenu_share"/>
 
     <item android:id="@+id/subscribe"
           android:title="@string/contextmenu_subscribe"/>
 
     <item android:id="@+id/add_search_engine"
-          android:title="@string/contextmenu_add_search_engine"
-          android:visible="false"/>
+          android:title="@string/contextmenu_add_search_engine"/>
 
     <item android:id="@+id/copyurl"
           android:title="@string/contextmenu_copyurl"/>
 
     <item android:id="@+id/site_settings"
           android:title="@string/contextmenu_site_settings" />
 
     <item android:id="@+id/add_to_launcher"
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -355,20 +355,17 @@ public class BrowserToolbar extends Geck
                 if (tab != null) {
                     String url = tab.getURL();
                     if (url == null) {
                         menu.findItem(R.id.copyurl).setVisible(false);
                         menu.findItem(R.id.share).setVisible(false);
                         menu.findItem(R.id.add_to_launcher).setVisible(false);
                     }
 
-                    if (!tab.hasFeeds()) {
-                        menu.findItem(R.id.subscribe).setVisible(false);
-                    }
-
+                    menu.findItem(R.id.subscribe).setVisible(tab.hasFeeds());
                     menu.findItem(R.id.add_search_engine).setVisible(tab.hasOpenSearch());
                 } else {
                     // if there is no tab, remove anything tab dependent
                     menu.findItem(R.id.copyurl).setVisible(false);
                     menu.findItem(R.id.share).setVisible(false);
                     menu.findItem(R.id.add_to_launcher).setVisible(false);
                     menu.findItem(R.id.subscribe).setVisible(false);
                     menu.findItem(R.id.add_search_engine).setVisible(false);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3717,28 +3717,18 @@ Tab.prototype = {
       if ((aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) && aWebProgress.isLoadingDocument) {
         // We may receive a document stop event while a document is still loading
         // (such as when doing URI fixup). Don't notify Java UI in these cases.
         return;
       }
 
       // Clear page-specific opensearch engines and feeds for a new request.
       if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && aRequest && aWebProgress.isTopLevel) {
-          this.browser.engines = null;
-
-          // Send message to clear search engine option in context menu.
-          let newEngineMessage = {
-            type: "Link:OpenSearch",
-            tabID: this.id,
-            visible: false
-          };
-
-          sendMessageToJava(newEngineMessage);
-
-          this.browser.feeds = null;
+        this.browser.engines = null;
+        this.browser.feeds = null;
       }
 
       // true if the page loaded successfully (i.e., no 404s or other errors)
       let success = false; 
       let uri = "";
       try {
         // Remember original URI for UA changes on redirected pages
         this.originalURI = aRequest.QueryInterface(Components.interfaces.nsIChannel).originalURI;