Bug 1225842 - Properly send message to update open search state. r=liuche
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 05 Feb 2016 12:56:23 -0500
changeset 331218 438b42019921171cdbcbad79dc216d185cad1b5f
parent 331217 f7b64f45c4fb8a06514b878dbec85f35654766e0
child 331219 1ba422314bc61c2cbf657f8c76ffff7e10a9082e
push id10938
push userBogdan.Postelnicu@softvision.ro
push dateTue, 16 Feb 2016 15:52:05 +0000
reviewersliuche
bugs1225842
milestone47.0a1
Bug 1225842 - Properly send message to update open search state. r=liuche MozReview-Commit-ID: 77s1zWo9vrr
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3961,17 +3961,17 @@ Tab.prototype = {
         type: "Link:Feed",
         tabID: this.id
       };
     } catch (e) {
         return null;
     }
   },
 
-  makeOpenSearchMessage: function(eventTarget) {
+  sendOpenSearchMessage: function(eventTarget) {
     let type = eventTarget.type && eventTarget.type.toLowerCase();
     // Replace all starting or trailing spaces or spaces before "*;" globally w/ "".
     type = type.replace(/^\s+|\s*(?:;.*)?$/g, "");
 
     // Check that type matches opensearch.
     let isOpenSearch = (type == "application/opensearchdescription+xml");
     if (isOpenSearch && eventTarget.title && /^(?:https?|ftp):/i.test(eventTarget.href)) {
       Services.search.init(() => {
@@ -4007,21 +4007,21 @@ Tab.prototype = {
 
         this.browser.engines.push(newEngine);
 
         // Don't send a message to display engines if we've already handled an engine.
         if (this.browser.engines.length > 1)
           return null;
 
         // Broadcast message that this tab contains search engines that should be visible.
-        return {
+        Messaging.sendRequest({
           type: "Link:OpenSearch",
           tabID: this.id,
           visible: true
-        };
+        });
       });
     }
   },
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "DOMContentLoaded": {
         let target = aEvent.originalTarget;
@@ -4136,17 +4136,17 @@ Tab.prototype = {
           let type = target.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
           let isFeed = (type == "application/rss+xml" || type == "application/atom+xml");
 
           if (!isFeed)
             return;
 
           jsonMessage = this.makeFeedMessage(target, type);
         } else if (list.indexOf("[search]" != -1) && aEvent.type == "DOMLinkAdded") {
-          jsonMessage = this.makeOpenSearchMessage(target);
+          this.sendOpenSearchMessage(target);
         }
         if (!jsonMessage)
          return;
 
         Messaging.sendRequest(jsonMessage);
         break;
       }