mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 04:27:37 +00:00
Bug 1203524 - search.xml should use Services.jsm, r=Mossop.
This commit is contained in:
parent
02fc488f62
commit
5d9c268c78
@ -68,14 +68,11 @@
|
|||||||
// Make sure we rebuild the popup in onpopupshowing
|
// Make sure we rebuild the popup in onpopupshowing
|
||||||
this._needToBuildPopup = true;
|
this._needToBuildPopup = true;
|
||||||
|
|
||||||
var os =
|
Services.obs.addObserver(this, "browser-search-engine-modified", false);
|
||||||
Components.classes["@mozilla.org/observer-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIObserverService);
|
|
||||||
os.addObserver(this, "browser-search-engine-modified", false);
|
|
||||||
|
|
||||||
this._initialized = true;
|
this._initialized = true;
|
||||||
|
|
||||||
this.searchService.init((function search_init_cb(aStatus) {
|
Services.search.init((function search_init_cb(aStatus) {
|
||||||
// Bail out if the binding's been destroyed
|
// Bail out if the binding's been destroyed
|
||||||
if (!this._initialized)
|
if (!this._initialized)
|
||||||
return;
|
return;
|
||||||
@ -98,9 +95,7 @@
|
|||||||
if (this._initialized) {
|
if (this._initialized) {
|
||||||
this._initialized = false;
|
this._initialized = false;
|
||||||
|
|
||||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
Services.obs.removeObserver(this, "browser-search-engine-modified");
|
||||||
.getService(Components.interfaces.nsIObserverService);
|
|
||||||
os.removeObserver(this, "browser-search-engine-modified");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to break the cycle from _textbox to us. Otherwise we leak
|
// Make sure to break the cycle from _textbox to us. Otherwise we leak
|
||||||
@ -120,7 +115,6 @@
|
|||||||
<field name="_textboxInitialized">false</field>
|
<field name="_textboxInitialized">false</field>
|
||||||
<field name="_textbox">document.getAnonymousElementByAttribute(this,
|
<field name="_textbox">document.getAnonymousElementByAttribute(this,
|
||||||
"anonid", "searchbar-textbox");</field>
|
"anonid", "searchbar-textbox");</field>
|
||||||
<field name="_ss">null</field>
|
|
||||||
<field name="_engines">null</field>
|
<field name="_engines">null</field>
|
||||||
<field name="FormHistory" readonly="true">
|
<field name="FormHistory" readonly="true">
|
||||||
(Components.utils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory;
|
(Components.utils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory;
|
||||||
@ -132,19 +126,19 @@
|
|||||||
<property name="engines" readonly="true">
|
<property name="engines" readonly="true">
|
||||||
<getter><![CDATA[
|
<getter><![CDATA[
|
||||||
if (!this._engines)
|
if (!this._engines)
|
||||||
this._engines = this.searchService.getVisibleEngines();
|
this._engines = Services.search.getVisibleEngines();
|
||||||
return this._engines;
|
return this._engines;
|
||||||
]]></getter>
|
]]></getter>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<property name="currentEngine">
|
<property name="currentEngine">
|
||||||
<setter><![CDATA[
|
<setter><![CDATA[
|
||||||
let ss = this.searchService;
|
let ss = Services.search;
|
||||||
ss.defaultEngine = ss.currentEngine = val;
|
ss.defaultEngine = ss.currentEngine = val;
|
||||||
return val;
|
return val;
|
||||||
]]></setter>
|
]]></setter>
|
||||||
<getter><![CDATA[
|
<getter><![CDATA[
|
||||||
var currentEngine = this.searchService.currentEngine;
|
var currentEngine = Services.search.currentEngine;
|
||||||
// Return a dummy engine if there is no currentEngine
|
// Return a dummy engine if there is no currentEngine
|
||||||
return currentEngine || {name: "", uri: null};
|
return currentEngine || {name: "", uri: null};
|
||||||
]]></getter>
|
]]></getter>
|
||||||
@ -155,18 +149,6 @@
|
|||||||
<property name="textbox" readonly="true"
|
<property name="textbox" readonly="true"
|
||||||
onget="return this._textbox;"/>
|
onget="return this._textbox;"/>
|
||||||
|
|
||||||
<property name="searchService" readonly="true">
|
|
||||||
<getter><![CDATA[
|
|
||||||
if (!this._ss) {
|
|
||||||
const nsIBSS = Components.interfaces.nsIBrowserSearchService;
|
|
||||||
this._ss =
|
|
||||||
Components.classes["@mozilla.org/browser/search-service;1"]
|
|
||||||
.getService(nsIBSS);
|
|
||||||
}
|
|
||||||
return this._ss;
|
|
||||||
]]></getter>
|
|
||||||
</property>
|
|
||||||
|
|
||||||
<property name="value" onget="return this._textbox.value;"
|
<property name="value" onget="return this._textbox.value;"
|
||||||
onset="return this._textbox.value = val;"/>
|
onset="return this._textbox.value = val;"/>
|
||||||
|
|
||||||
@ -366,7 +348,7 @@
|
|||||||
where = whereToOpenLink(aEvent, false, true);
|
where = whereToOpenLink(aEvent, false, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var newTabPref = textBox._prefBranch.getBoolPref("browser.search.openintab");
|
var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
|
||||||
if (((aEvent instanceof KeyboardEvent) && aEvent.altKey) ^ newTabPref)
|
if (((aEvent instanceof KeyboardEvent) && aEvent.altKey) ^ newTabPref)
|
||||||
where = "tab";
|
where = "tab";
|
||||||
if ((aEvent instanceof MouseEvent) &&
|
if ((aEvent instanceof MouseEvent) &&
|
||||||
@ -456,18 +438,15 @@
|
|||||||
if (target.engine) {
|
if (target.engine) {
|
||||||
this.currentEngine = target.engine;
|
this.currentEngine = target.engine;
|
||||||
} else if (target.classList.contains("addengine-item")) {
|
} else if (target.classList.contains("addengine-item")) {
|
||||||
var searchService =
|
|
||||||
Components.classes["@mozilla.org/browser/search-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIBrowserSearchService);
|
|
||||||
// We only detect OpenSearch files
|
// We only detect OpenSearch files
|
||||||
var type = Components.interfaces.nsISearchEngine.DATA_XML;
|
var type = Ci.nsISearchEngine.DATA_XML;
|
||||||
// Select the installed engine if the installation succeeds
|
// Select the installed engine if the installation succeeds
|
||||||
var installCallback = {
|
var installCallback = {
|
||||||
onSuccess: engine => this.currentEngine = engine
|
onSuccess: engine => this.currentEngine = engine
|
||||||
}
|
}
|
||||||
searchService.addEngine(target.getAttribute("uri"), type,
|
Services.search.addEngine(target.getAttribute("uri"), type,
|
||||||
target.getAttribute("src"), false,
|
target.getAttribute("src"), false,
|
||||||
installCallback);
|
installCallback);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -559,13 +538,10 @@
|
|||||||
|
|
||||||
// Initialize fields
|
// Initialize fields
|
||||||
this._stringBundle = document.getBindingParent(this)._stringBundle;
|
this._stringBundle = document.getBindingParent(this)._stringBundle;
|
||||||
this._prefBranch =
|
|
||||||
Components.classes["@mozilla.org/preferences-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
|
||||||
this._suggestEnabled =
|
this._suggestEnabled =
|
||||||
this._prefBranch.getBoolPref("browser.search.suggest.enabled");
|
Services.prefs.getBoolPref("browser.search.suggest.enabled");
|
||||||
|
|
||||||
if (this._prefBranch.getBoolPref("browser.urlbar.clickSelectsAll"))
|
if (Services.prefs.getBoolPref("browser.urlbar.clickSelectsAll"))
|
||||||
this.setAttribute("clickSelectsAll", true);
|
this.setAttribute("clickSelectsAll", true);
|
||||||
|
|
||||||
// Add items to context menu and attach controller to handle them
|
// Add items to context menu and attach controller to handle them
|
||||||
@ -637,15 +613,11 @@
|
|||||||
document.getBindingParent(this)._textboxInitialized = true;
|
document.getBindingParent(this)._textboxInitialized = true;
|
||||||
|
|
||||||
// Add observer for suggest preference
|
// Add observer for suggest preference
|
||||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
Services.prefs.addObserver("browser.search.suggest.enabled", this, false);
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
|
||||||
prefs.addObserver("browser.search.suggest.enabled", this, false);
|
|
||||||
]]></constructor>
|
]]></constructor>
|
||||||
|
|
||||||
<destructor><![CDATA[
|
<destructor><![CDATA[
|
||||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
Services.prefs.removeObserver("browser.search.suggest.enabled", this);
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
|
||||||
prefs.removeObserver("browser.search.suggest.enabled", this);
|
|
||||||
|
|
||||||
// Because XBL and the customize toolbar code interacts poorly,
|
// Because XBL and the customize toolbar code interacts poorly,
|
||||||
// there may not be anything to remove here
|
// there may not be anything to remove here
|
||||||
@ -655,7 +627,6 @@
|
|||||||
]]></destructor>
|
]]></destructor>
|
||||||
|
|
||||||
<field name="_stringBundle"/>
|
<field name="_stringBundle"/>
|
||||||
<field name="_prefBranch"/>
|
|
||||||
<field name="_suggestMenuItem"/>
|
<field name="_suggestMenuItem"/>
|
||||||
<field name="_suggestEnabled"/>
|
<field name="_suggestEnabled"/>
|
||||||
|
|
||||||
@ -698,7 +669,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
popup.mInput = this;
|
popup.mInput = this;
|
||||||
popup.view = this.controller.QueryInterface(Components.interfaces.nsITreeView);
|
popup.view = this.controller.QueryInterface(Ci.nsITreeView);
|
||||||
popup.invalidate();
|
popup.invalidate();
|
||||||
|
|
||||||
popup.showCommentColumn = this.showCommentColumn;
|
popup.showCommentColumn = this.showCommentColumn;
|
||||||
@ -730,7 +701,7 @@
|
|||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
if (aTopic == "nsPref:changed") {
|
if (aTopic == "nsPref:changed") {
|
||||||
this._suggestEnabled =
|
this._suggestEnabled =
|
||||||
this._prefBranch.getBoolPref("browser.search.suggest.enabled");
|
Services.prefs.getBoolPref("browser.search.suggest.enabled");
|
||||||
this._suggestMenuItem.setAttribute("checked", this._suggestEnabled);
|
this._suggestMenuItem.setAttribute("checked", this._suggestEnabled);
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
@ -974,8 +945,8 @@
|
|||||||
case "cmd_togglesuggest":
|
case "cmd_togglesuggest":
|
||||||
// The pref observer will update _suggestEnabled and the menu
|
// The pref observer will update _suggestEnabled and the menu
|
||||||
// checkmark.
|
// checkmark.
|
||||||
this._self._prefBranch.setBoolPref("browser.search.suggest.enabled",
|
Services.prefs.setBoolPref("browser.search.suggest.enabled",
|
||||||
!this._self._suggestEnabled);
|
!this._self._suggestEnabled);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// do nothing with unrecognized command
|
// do nothing with unrecognized command
|
||||||
|
Loading…
Reference in New Issue
Block a user