зеркало из https://github.com/mozilla/gecko-dev.git
Bug 344059: Don't write search prefs. on shutdown unless something has changed, patch by Adam Guthrie <ispiked@gmail.com>, r=me
This commit is contained in:
Родитель
8ce53c83e5
Коммит
85f0bb938d
|
@ -2148,6 +2148,9 @@ function SearchService() {
|
||||||
SearchService.prototype = {
|
SearchService.prototype = {
|
||||||
_engines: { },
|
_engines: { },
|
||||||
_sortedEngines: null,
|
_sortedEngines: null,
|
||||||
|
// Whether or not we need to write the order of engines on shutdown. This
|
||||||
|
// needs to happen anytime _sortedEngines is modified after initial startup.
|
||||||
|
_needToSetOrderPrefs: false,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
engineMetadataService.init();
|
engineMetadataService.init();
|
||||||
|
@ -2217,8 +2220,10 @@ SearchService.prototype = {
|
||||||
// has already been built (i.e. if this._sortedEngines is non-null). If
|
// has already been built (i.e. if this._sortedEngines is non-null). If
|
||||||
// it hasn't, we're still loading engines from disk, and will build the
|
// it hasn't, we're still loading engines from disk, and will build the
|
||||||
// sorted engine list when that initial loading is done.
|
// sorted engine list when that initial loading is done.
|
||||||
if (this._sortedEngines)
|
if (this._sortedEngines) {
|
||||||
this._sortedEngines.push(aEngine);
|
this._sortedEngines.push(aEngine);
|
||||||
|
this._needToSetOrderPrefs = true;
|
||||||
|
}
|
||||||
notifyAction(aEngine, SEARCH_ENGINE_ADDED);
|
notifyAction(aEngine, SEARCH_ENGINE_ADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2306,6 +2311,10 @@ SearchService.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_saveSortedEngineList: function SRCH_SVC_saveSortedEngineList() {
|
_saveSortedEngineList: function SRCH_SVC_saveSortedEngineList() {
|
||||||
|
// We only need to write the prefs. if something has changed.
|
||||||
|
if (!this._needToSetOrderPrefs)
|
||||||
|
return;
|
||||||
|
|
||||||
var engines = this._getSortedEngines(true);
|
var engines = this._getSortedEngines(true);
|
||||||
var values = [];
|
var values = [];
|
||||||
var names = [];
|
var names = [];
|
||||||
|
@ -2334,11 +2343,17 @@ SearchService.prototype = {
|
||||||
if (orderNumber && !this._sortedEngines[orderNumber-1]) {
|
if (orderNumber && !this._sortedEngines[orderNumber-1]) {
|
||||||
this._sortedEngines[orderNumber-1] = engine;
|
this._sortedEngines[orderNumber-1] = engine;
|
||||||
addedEngines[engine.name] = engine;
|
addedEngines[engine.name] = engine;
|
||||||
|
} else {
|
||||||
|
// We need to call _saveSortedEngines so this gets sorted out.
|
||||||
|
this._needToSetOrderPrefs = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out any nulls for engines that may have been removed
|
// Filter out any nulls for engines that may have been removed
|
||||||
this._sortedEngines = this._sortedEngines.filter(function(a) { return !!a; });
|
var filteredEngines = this._sortedEngines.filter(function(a) { return !!a; });
|
||||||
|
if (this._sortedEngines.length != filteredEngines.length)
|
||||||
|
this._needToSetOrderPrefs = true;
|
||||||
|
this._sortedEngines = filteredEngines;
|
||||||
|
|
||||||
// Array for the remaining engines, alphabetically sorted
|
// Array for the remaining engines, alphabetically sorted
|
||||||
var alphaEngines = [];
|
var alphaEngines = [];
|
||||||
|
@ -2611,6 +2626,9 @@ SearchService.prototype = {
|
||||||
delete this._engines[engineToRemove.name];
|
delete this._engines[engineToRemove.name];
|
||||||
|
|
||||||
notifyAction(engineToRemove, SEARCH_ENGINE_REMOVED);
|
notifyAction(engineToRemove, SEARCH_ENGINE_REMOVED);
|
||||||
|
|
||||||
|
// Since we removed an engine, we need to update the preferences.
|
||||||
|
this._needToSetOrderPrefs = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2631,6 +2649,9 @@ SearchService.prototype = {
|
||||||
this._sortedEngines.splice(aNewIndex, 0, movedEngine);
|
this._sortedEngines.splice(aNewIndex, 0, movedEngine);
|
||||||
|
|
||||||
notifyAction(engine, SEARCH_ENGINE_CHANGED);
|
notifyAction(engine, SEARCH_ENGINE_CHANGED);
|
||||||
|
|
||||||
|
// Since we moved an engine, we need to update the preferences.
|
||||||
|
this._needToSetOrderPrefs = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
restoreDefaultEngines: function SRCH_SVC_resetDefaultEngines() {
|
restoreDefaultEngines: function SRCH_SVC_resetDefaultEngines() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче