зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1203161 - remove the browser.search.cache.enabled pref, r=adw.
This commit is contained in:
Родитель
8263535ca5
Коммит
02fc488f62
|
@ -2074,57 +2074,54 @@ Engine.prototype = {
|
|||
case "https":
|
||||
case "ftp":
|
||||
// No use downloading the icon if the engine file is read-only
|
||||
if (!this._readOnly ||
|
||||
getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true)) {
|
||||
LOG("_setIcon: Downloading icon: \"" + uri.spec +
|
||||
"\" for engine: \"" + this.name + "\"");
|
||||
var chan = NetUtil.ioService.newChannelFromURI2(uri,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_IMAGE);
|
||||
LOG("_setIcon: Downloading icon: \"" + uri.spec +
|
||||
"\" for engine: \"" + this.name + "\"");
|
||||
var chan = NetUtil.ioService.newChannelFromURI2(uri,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_IMAGE);
|
||||
|
||||
let iconLoadCallback = function (aByteArray, aEngine) {
|
||||
// This callback may run after we've already set a preferred icon,
|
||||
// so check again.
|
||||
if (aEngine._hasPreferredIcon && !aIsPreferred)
|
||||
return;
|
||||
let iconLoadCallback = function (aByteArray, aEngine) {
|
||||
// This callback may run after we've already set a preferred icon,
|
||||
// so check again.
|
||||
if (aEngine._hasPreferredIcon && !aIsPreferred)
|
||||
return;
|
||||
|
||||
if (!aByteArray || aByteArray.length > MAX_ICON_SIZE) {
|
||||
LOG("iconLoadCallback: load failed, or the icon was too large!");
|
||||
return;
|
||||
}
|
||||
|
||||
var str = btoa(String.fromCharCode.apply(null, aByteArray));
|
||||
let dataURL = ICON_DATAURL_PREFIX + str;
|
||||
aEngine._iconURI = makeURI(dataURL);
|
||||
|
||||
if (aWidth && aHeight) {
|
||||
aEngine._addIconToMap(aWidth, aHeight, dataURL)
|
||||
}
|
||||
|
||||
// The engine might not have a file yet, if it's being downloaded,
|
||||
// because the request for the engine file itself (_onLoad) may not
|
||||
// yet be complete. In that case, this change will be written to
|
||||
// file when _onLoad is called. For readonly engines, we'll store
|
||||
// the changes in the cache once notified below.
|
||||
if (aEngine._file && !aEngine._readOnly)
|
||||
aEngine._serializeToFile();
|
||||
|
||||
notifyAction(aEngine, SEARCH_ENGINE_CHANGED);
|
||||
aEngine._hasPreferredIcon = aIsPreferred;
|
||||
if (!aByteArray || aByteArray.length > MAX_ICON_SIZE) {
|
||||
LOG("iconLoadCallback: load failed, or the icon was too large!");
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're currently acting as an "update engine", then the callback
|
||||
// should set the icon on the engine we're updating and not us, since
|
||||
// |this| might be gone by the time the callback runs.
|
||||
var engineToSet = this._engineToUpdate || this;
|
||||
var str = btoa(String.fromCharCode.apply(null, aByteArray));
|
||||
let dataURL = ICON_DATAURL_PREFIX + str;
|
||||
aEngine._iconURI = makeURI(dataURL);
|
||||
|
||||
var listener = new loadListener(chan, engineToSet, iconLoadCallback);
|
||||
chan.notificationCallbacks = listener;
|
||||
chan.asyncOpen(listener, null);
|
||||
if (aWidth && aHeight) {
|
||||
aEngine._addIconToMap(aWidth, aHeight, dataURL)
|
||||
}
|
||||
|
||||
// The engine might not have a file yet, if it's being downloaded,
|
||||
// because the request for the engine file itself (_onLoad) may not
|
||||
// yet be complete. In that case, this change will be written to
|
||||
// file when _onLoad is called. For readonly engines, we'll store
|
||||
// the changes in the cache once notified below.
|
||||
if (aEngine._file && !aEngine._readOnly)
|
||||
aEngine._serializeToFile();
|
||||
|
||||
notifyAction(aEngine, SEARCH_ENGINE_CHANGED);
|
||||
aEngine._hasPreferredIcon = aIsPreferred;
|
||||
}
|
||||
|
||||
// If we're currently acting as an "update engine", then the callback
|
||||
// should set the icon on the engine we're updating and not us, since
|
||||
// |this| might be gone by the time the callback runs.
|
||||
var engineToSet = this._engineToUpdate || this;
|
||||
|
||||
var listener = new loadListener(chan, engineToSet, iconLoadCallback);
|
||||
chan.notificationCallbacks = listener;
|
||||
chan.asyncOpen(listener, null);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -3614,9 +3611,6 @@ SearchService.prototype = {
|
|||
},
|
||||
|
||||
_buildCache: function SRCH_SVC__buildCache() {
|
||||
if (!getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true))
|
||||
return;
|
||||
|
||||
TelemetryStopwatch.start("SEARCH_SERVICE_BUILD_CACHE_MS");
|
||||
let cache = {};
|
||||
let locale = getLocale();
|
||||
|
@ -3697,13 +3691,10 @@ SearchService.prototype = {
|
|||
LOG("_syncLoadEngines: start");
|
||||
// See if we have a cache file so we don't have to parse a bunch of XML.
|
||||
let cache = {};
|
||||
let cacheEnabled = getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true);
|
||||
if (cacheEnabled) {
|
||||
let cacheFile = getDir(NS_APP_USER_PROFILE_50_DIR);
|
||||
cacheFile.append("search.json");
|
||||
if (cacheFile.exists())
|
||||
cache = this._readCacheFile(cacheFile);
|
||||
}
|
||||
let cacheFile = getDir(NS_APP_USER_PROFILE_50_DIR);
|
||||
cacheFile.append("search.json");
|
||||
if (cacheFile.exists())
|
||||
cache = this._readCacheFile(cacheFile);
|
||||
|
||||
let [chromeFiles, chromeURIs] = this._findJAREngines();
|
||||
|
||||
|
@ -3756,7 +3747,7 @@ SearchService.prototype = {
|
|||
this._visibleDefaultEngines.some(notInCacheVisibleEngines) ||
|
||||
toLoad.some(modifiedDir);
|
||||
|
||||
if (!cacheEnabled || rebuildCache) {
|
||||
if (rebuildCache) {
|
||||
LOG("_loadEngines: Absent or outdated cache. Loading engines from disk.");
|
||||
distDirs.forEach(this._loadEnginesFromDir, this);
|
||||
|
||||
|
@ -3764,8 +3755,7 @@ SearchService.prototype = {
|
|||
|
||||
otherDirs.forEach(this._loadEnginesFromDir, this);
|
||||
|
||||
if (cacheEnabled)
|
||||
this._buildCache();
|
||||
this._buildCache();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3787,11 +3777,8 @@ SearchService.prototype = {
|
|||
LOG("_asyncLoadEngines: start");
|
||||
// See if we have a cache file so we don't have to parse a bunch of XML.
|
||||
let cache = {};
|
||||
let cacheEnabled = getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true);
|
||||
if (cacheEnabled) {
|
||||
let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
|
||||
cache = yield checkForSyncCompletion(this._asyncReadCacheFile(cacheFilePath));
|
||||
}
|
||||
let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
|
||||
cache = yield checkForSyncCompletion(this._asyncReadCacheFile(cacheFilePath));
|
||||
|
||||
Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "find-jar-engines");
|
||||
let [chromeFiles, chromeURIs] =
|
||||
|
@ -3882,7 +3869,7 @@ SearchService.prototype = {
|
|||
this._visibleDefaultEngines.some(notInCacheVisibleEngines) ||
|
||||
(yield checkForSyncCompletion(hasModifiedDir(toLoad)));
|
||||
|
||||
if (!cacheEnabled || rebuildCache) {
|
||||
if (rebuildCache) {
|
||||
LOG("_asyncLoadEngines: Absent or outdated cache. Loading engines from disk.");
|
||||
let engines = [];
|
||||
for (let loadDir of distDirs) {
|
||||
|
@ -3902,8 +3889,7 @@ SearchService.prototype = {
|
|||
for (let engine of engines) {
|
||||
this._addEngineToStore(engine);
|
||||
}
|
||||
if (cacheEnabled)
|
||||
this._buildCache();
|
||||
this._buildCache();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5545,12 +5531,6 @@ var engineUpdateService = {
|
|||
if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates)
|
||||
return;
|
||||
|
||||
// We use the cache to store updated app engines, so refuse to update if the
|
||||
// cache is disabled.
|
||||
if (engine._readOnly &&
|
||||
!getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true))
|
||||
return;
|
||||
|
||||
let testEngine = null;
|
||||
let updateURL = engine._getURLOfType(URLTYPE_OPENSEARCH);
|
||||
let updateURI = (updateURL && updateURL._hasRelation("self")) ?
|
||||
|
|
Загрузка…
Ссылка в новой задаче