summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorKetmar Dark <ketmar@ketmar.no-ip.org>2018-09-05 19:03:19 +0300
committerwolfbeast <mcwerewolf@gmail.com>2018-09-10 18:37:04 +0200
commit2e9c525a91b66038dafcc2ef97dd436164ab65f6 (patch)
tree2b7f391e0597ded776a18d1c74a017633dbc47a3 /toolkit
parenteb2016063a119d5b3fb78cf657d400742fb3d8fd (diff)
downloaduxp-2e9c525a91b66038dafcc2ef97dd436164ab65f6.tar.gz
fix mozilla regression in search service (saving user-defined search engines)
this restores some API that is used by search engine management extensions, and tells "browser-search-engine-modified"/"engine-changed" signal to save user-defined search engines to "%PROFILE%/searchplugins", as it did in Good Old Times.
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/components/search/orginal/nsSearchService.js23
1 files changed, 18 insertions, 5 deletions
diff --git a/toolkit/components/search/orginal/nsSearchService.js b/toolkit/components/search/orginal/nsSearchService.js
index c7b847905d..8d81e1a277 100644
--- a/toolkit/components/search/orginal/nsSearchService.js
+++ b/toolkit/components/search/orginal/nsSearchService.js
@@ -2237,7 +2237,10 @@ Engine.prototype = {
get lazySerializeTask() {
if (!this._lazySerializeTask) {
let task = function taskCallback() {
- this._serializeToFile();
+ // This check should be done by caller, but it is better to be safe than sorry.
+ if (!this._readOnly && this._file) {
+ this._serializeToFile();
+ }
}.bind(this);
this._lazySerializeTask = new DeferredTask(task, LAZY_SERIALIZE_DELAY);
}
@@ -2245,6 +2248,17 @@ Engine.prototype = {
return this._lazySerializeTask;
},
+ // This API is required by some search engine management extensions, so let's restore it.
+ // Old API was using a timer to do its work, but this can lead us too far. If extension is
+ // rely on such subtle internal details, that extension should be fixed, not browser.
+ _lazySerializeToFile: function SRCH_ENG_lazySerializeToFile() {
+ // This check should be done by caller, but it is better to be safe than sorry.
+ // Besides, we don't have to create a task for r/o or non-file engines.
+ if (!this._readOnly && this._file) {
+ this.lazySerializeTask.arm();
+ }
+ },
+
/**
* Serializes the engine object to file.
*/
@@ -3059,10 +3073,9 @@ SearchService.prototype = {
}
// Write out serialized search engine files when rebuilding cache.
- if (!engine._readOnly && engine._file) {
- engine._serializeToFile();
- }
-
+ // Do it lazily, to: 1) reuse existing API; 2) make browser interface more responsive
+ engine._lazySerializeToFile();
+
let cacheKey = parent.path;
if (!cache.directories[cacheKey]) {
let cacheEntry = {};