Bug 1225842 - Properly send message to update open search state. r=liuche
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3957,17 +3957,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(() => {
@@ -4003,21 +4003,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;
@@ -4132,17 +4132,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;
}