1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
From: Mike Hommey <mh@glandium.org>
Date: Sun, 15 Apr 2012 11:38:32 +0200
Subject: Handle transition to /etc/<appname>/searchplugins more gracefully
Closes: #666675.
---
toolkit/components/search/nsSearchService.js | 32 ++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js
index 2807835..8fa31ca 100644
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -710,6 +710,7 @@ function getMozParamPref(prefName)
*
* @see nsIBrowserSearchService.idl
*/
+let gForceCacheInvalidation = false;
let gEnginesLoaded = false;
function notifyAction(aEngine, aVerb) {
if (gEnginesLoaded) {
@@ -2012,6 +2013,20 @@ Engine.prototype = {
**/
_initWithJSON: function SRCH_ENG__initWithJSON(aJson) {
this.__id = aJson._id;
+ try {
+ let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
+ file.initWithPath(this.__id);
+ let loadDirs = [];
+ let locations = getDir(NS_APP_SEARCH_DIR_LIST, Ci.nsISimpleEnumerator);
+ while (locations.hasMoreElements()) {
+ let dir = locations.getNext().QueryInterface(Ci.nsIFile);
+ loadDirs.push(dir);
+ }
+ if (loadDirs.some(function (element) element.equals(file.parent))) {
+ this.__id = "[app]/" + file.leafName;
+ gForceCacheInvalidation = true;
+ }
+ } catch (e) { }
this._name = aJson._name;
this._description = aJson.description;
if (aJson._hasPreferredIcon == undefined)
@@ -2306,8 +2321,19 @@ Engine.prototype = {
this.__installLocation = SEARCH_APP_DIR;
else if (this._file.parent.equals(getDir(NS_APP_USER_SEARCH_DIR)))
this.__installLocation = SEARCH_PROFILE_DIR;
- else
- this.__installLocation = SEARCH_IN_EXTENSION;
+ else {
+ let loadDirs = [];
+ let locations = getDir(NS_APP_SEARCH_DIR_LIST, Ci.nsISimpleEnumerator);
+ while (locations.hasMoreElements()) {
+ let dir = locations.getNext().QueryInterface(Ci.nsIFile);
+ loadDirs.push(dir);
+ }
+ let parent = this._file.parent;
+ if (loadDirs.some(function (element) !element.equals(parent)))
+ this.__installLocation = SEARCH_APP_DIR;
+ else
+ this.__installLocation = SEARCH_IN_EXTENSION;
+ }
}
return this.__installLocation;
@@ -2471,6 +2497,8 @@ function SearchService() {
}
gEnginesLoaded = true;
this._addObservers();
+ if (gForceCacheInvalidation)
+ this._batchCacheInvalidation();
}
SearchService.prototype = {
classID: Components.ID("{7319788a-fe93-4db3-9f39-818cf08f4256}"),
|