Closed Bug 523453 Opened 15 years ago Closed 15 years ago

optionally allow loading engines from chrome:// URIs

Categories

(Firefox :: Search, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3.7a1
Tracking Status
status1.9.2 --- beta2-fixed

People

(Reporter: Gavin, Assigned: Gavin)

References

Details

Attachments

(2 files, 2 obsolete files)

Fennec would like this functionality for multi-locale builds, so that we can package the search engines in the locale JARs. I'm going to make this opt-in using a pref.
Attached patch patch (obsolete) — Splinter Review
Similar to the patch we discussed on IRC. I made one change to preserve the [app] _ids for JAR-loaded plugins, otherwise the engine sorting was broken for existing Fennec users (since they'd have the useDBForOrder pref set, and the engine IDs would all change). Slightly risky, but it's pretty unlikely that we'll ever get a conflict in practice, there.
Attachment #407389 - Flags: review?(rflint)
Attachment #407389 - Flags: review?(rflint) → review+
Comment on attachment 407389 [details] [diff] [review]
patch

>diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js
>+__defineGetter__("gChromeReg", function () {

nit: prevailing style is function()

>   __id: null,
>   get _id() {
>     if (!this.__id) {

Invert and return early here?

>+      // This means we're vulnerable to conflicts if a file loaded from a JAR
>+      // has the same filename as a file loaded from the app dir, but with a
>+      // different engine name. People using the JAR functionality should be
>+      // careful not to do that!
>+      if (this._isInAppDir || this._isInJAR) {
>+        let leafName;
>+        if (this._file)
>+          leafName = this._file.leafName;
>+        else {
>+          // If we've reached this point, we must be loaded from a JAR, which
>+          // also means we should have a URL.

Since the app dir vs. jar distinction is already being made, can't you use [jar]+leafName to avoid the conflicts?

>   _loadEnginesFromCache: function SRCH_SVC__loadEnginesFromCache(aDir) {
>+        if (json.filePath)
>+          engine = new Engine({cached: true, value: json.filePath}, json._dataType,
>+                                  json._readOnly);

nit: indent here is a little funky.

>+        else if (json._url)
>+          engine = new Engine(makeURI(json._url), json._dataType, json._readOnly);

Instead of creating a URI, this should just pass in the URL, and like _file, _url should be a getter that can convert to a URI when needed. You can just turn |cached| into a type string and work with that in the Engine constructor.

When creating a trunk version of this, note that gIoSvc is now NetUtil.ioService.

Looks good!
(In reply to comment #2)
> Since the app dir vs. jar distinction is already being made, can't you use
> [jar]+leafName to avoid the conflicts?

Er, right. Totally missed comment 1...
Attachment #407389 - Attachment is obsolete: true
Attached patch as landedSplinter Review
Forgot to replace one gIoSvc in the previous patch.
Attachment #408181 - Attachment is obsolete: true
http://hg.mozilla.org/mozilla-central/rev/aeccda67019e
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.6
Target Milestone: Firefox 3.6 → Firefox 3.7a1
Attached patch 192 versionSplinter Review
Attachment #408375 - Flags: approval1.9.2?
Blocks a fennec blocker. This one makes me nervous; even preffed off, I wish we had better tests, here.
Flags: blocking-firefox3.6+
Attachment #408375 - Flags: approval1.9.2?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: