Closed Bug 587691 Opened 14 years ago Closed 14 years ago

need a way to get the default engine, even if it is hidden

Categories

(Firefox :: Search, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 4.0b5
Tracking Status
blocking2.0 --- beta5+

People

(Reporter: Gavin, Assigned: Gavin)

Details

(Whiteboard: [has reviewed patch])

Attachments

(1 file, 3 obsolete files)

For the functionality added in bug 586821, we want to always use the default engine, even if it's hidden.
blocking2.0: --- → beta5+
One option is to change the defaultEngine getter to just always return the original default, even it if is hidden. That would mean context menu search would continue using that engine even though it "doesn't exist". It might also break other people's expectations.

Another option is to add some extra property, but I have no idea what we'd call it.
Assignee: nobody → gavin.sharp
Attached patch add originalDefaultEngine (obsolete) — Splinter Review
Attachment #468070 - Flags: review?
Attachment #468070 - Flags: review? → review?(rflint)
Attached patch patch (obsolete) — Splinter Review
Attachment #468070 - Attachment is obsolete: true
Attachment #468385 - Flags: review?(rflint)
Attachment #468070 - Flags: review?(rflint)
I'm not super pleased that we baked the "or fall back to the first visible engine" logic into the search service rather than in the frontend, because it kind of ties our hands a bit.

This patch just adds the additional property (originalDefaultEngine), and updates the docs to match, which I think is the simplest and safest choice at this point, even though it's sucky to have both "defaultEngine" and "originalDefaultEngine" properties...
Comment on attachment 468385 [details] [diff] [review]
patch


>+  /**
>+   * The original default engine. This differs from the "defaultEngine"
>+   * attribute in that it always returns a given build's default engine,
>+   * regardless of whether it is hidden. May be null if there are no visible
>+   * search engines.
>+   */
>+  readonly attribute nsISearchEngine originalDefaultEngine;

can it really be null if there are no visible engines? the phrase "if there are no visible search engines" looks conflicting with "regardless of whether it is hidden" and the default engine pref should always exist.

>diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js

>+  get originalDefaultEngine() {
>+    const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
>+    return this.getEngineByName(getLocalizedPref(defPref, ""));
>+  },

looks like this could cache the value or we expect it to change during runtime? (the old code was looking like trying to cache it, but wrongly), even if the pref can be changed it's unlikely someone would do it and expect immediate effect.
(In reply to comment #5)
> can it really be null if there are no visible engines?

Well, it can be null if there are no installed engines, but I think the search service doesn't handle that case very well, so probably not worth covering that case here - I'll adjust the comment.

> looks like this could cache the value or we expect it to change during
> runtime?

Yeah, it could be cached. And this file could use Services.jsm and XPCOMUtils lazy getters, too - but search service doesn't have a test suite at the moment, so I really want to be conservative and avoid unnecessary changes. I'll file a followup.
Attached patch updated patch (obsolete) — Splinter Review
Attachment #468385 - Attachment is obsolete: true
Attachment #468768 - Flags: review?(rflint)
Attachment #468385 - Flags: review?(rflint)
Attachment #468768 - Flags: review?(rflint) → review+
Attachment #468768 - Attachment is obsolete: true
Whiteboard: [has reviewed patch]
http://hg.mozilla.org/mozilla-central/rev/d8d151330687
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 4.0b5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: