Closed Bug 1590803 Opened 5 years ago Closed 4 years ago

Replace some calls to getDefaultEngines with purpose-built specific nsISearchEngine.isAppProvided flag

Categories

(Firefox :: Search, task, P3)

task
Points:
3

Tracking

()

RESOLVED FIXED
Firefox 76
Iteration:
76.2 - Mar 23 - Apr 5
Tracking Status
firefox76 --- fixed

People

(Reporter: standard8, Assigned: standard8)

Details

Attachments

(2 files)

Currently, there's two places in the code where we call getDefaultEngines to work out if a single engine is default (aka built-in) or not:

https://searchfox.org/mozilla-central/rev/8a63fc190b39ed6951abb4aef4a56487a43962bc/browser/base/content/browser.js#4515,4519
https://searchfox.org/mozilla-central/rev/8a63fc190b39ed6951abb4aef4a56487a43962bc/browser/components/extensions/parent/ext-chrome-settings-overrides.js#367,370

In both of these cases, we have easy access to the nsISearchEngine object.

Currently getDefaultEngines uses the engine._isDefault getter to filter the engines before sorting them. We should just expose the equivalent of _isDefault on nsISearchEngine, and then have the callers above access that direct.

This would save getting arrays and iterating over them.

Ideally, we should use an attribute name other than isDefault as that could be confused with being the "default" engine for a user. Unfortunately we can't use isBuiltIn as that is for built-in engines that aren't distribution engines.

Bug 1621892 is removing one instance of this.

Depends on: 1621892

(In reply to Mark Banner (:standard8) from comment #1)

Bug 1621892 is removing one instance of this.

I was wrong, that's a slightly different bit of code. I'll start looking at this next.

Assignee: nobody → standard8
Iteration: --- → 76.2 - Mar 23 - Apr 5
Points: --- → 3
No longer depends on: 1621892

I've got a couple of patches that do this change. I've gone with isAppProvided for now since that feels like a much better term than using something that references "default" (which is overloaded), or "built-in" (also overloaded, and not necessarily true all the time).

I'm open to even better naming though. For now, isAppProvided just replaces the _isDefault that we had before, however, I think we can work towards replacing _builtIn with it as well, but I'm still investigating those and working through it, so I'll leave those to a later bug.

Summary: Replace some calls to getDefaultEngines with purpose-built specific nsISearchEngine.isBuiltIn flag → Replace some calls to getDefaultEngines with purpose-built specific nsISearchEngine.isAppProvided flag
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/efd1d1868d70
Replace SearchEngine._isBuiltIn with a public nsISearchEngine.isAppProvided function. r=daleharvey
https://hg.mozilla.org/integration/autoland/rev/6256694a9047
Clean up uses of SearchService.getDefaultEngines where we can now use engine.isAppProvided. r=daleharvey

I fixed the failure, this will re-land once the tree is open again.

Flags: needinfo?(standard8)
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e31c9f38d6d2
Replace SearchEngine._isBuiltIn with a public nsISearchEngine.isAppProvided function. r=daleharvey
https://hg.mozilla.org/integration/autoland/rev/2ff264d68b14
Clean up uses of SearchService.getDefaultEngines where we can now use engine.isAppProvided. r=daleharvey
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: