Add APIs to manage search engines for the web search bar/location bar

RESOLVED DUPLICATE of bug 1428948

Status

P3
normal
RESOLVED DUPLICATE of bug 1428948
3 years ago
5 months ago

People

(Reporter: yuki, Assigned: kev)

Tracking

(Blocks: 2 bugs)

Trunk
Dependency tree / graph

Firefox Tracking Flags

(firefox49 affected)

Details

(Whiteboard: triaged)

(Reporter)

Description

3 years ago
For enterprise use, needless default search engines are expected to be disabled, and sometimes custom search engines are needed to be installed by default. Currently we need to control search engines via nsIBrowserSearchService from an addon to do it. After WebExtensions, I need something to alter the feature.

Of course, non-WebExtensions solution (new secret preferences to do it, or new configuration entries in distribution.ini) will also help me.

Updated

3 years ago
Whiteboard: [design-decision-needed]triaged
(Reporter)

Comment 1

2 years ago
I think the API can be appear like APIs to control tabs, like:

chrome.searchengines.query() // list search engines
chrome.searchengines.get() // get one engine
chrome.searchengines.install() // add new search engine
chrome.searchengines.create() // add new search engine from scratch without XML file - I think this will help us to generate search engines with different parameters easily (for example, different trees in dxr.mozilla.org)
Blocks: 1215059
Summary: Add APIs to manage search engines in the web search bar/location bar → Add APIs to manage search engines for the web search bar/location bar

Updated

2 years ago
Component: WebExtensions: Untriaged → WebExtensions: Frontend
Priority: -- → P3
I tried to port https://addons.mozilla.org/en-US/firefox/addon/add-to-search-bar/ to a WebExtension but this bug is a blocker for it.

Comment 3

2 years ago
Hello, my Search Buttons Bar extension requires API to query user's Search engines. As a WebExtension I didn't find any working solutions to achieve it. I'm currently using the nsIBrowserSearchService.

https://addons.mozilla.org/addon/searchbuttonsbar/

Updated

2 years ago
Flags: needinfo?(kev)
To be discussed at Dec. 13, 2016 WE triage meeting. 

Agenda: https://docs.google.com/document/d/1S1QrBK1hrulE7dlLiQzjMupHUUSwDYRYAOXiqtMHe-k/edit#
(Assignee)

Comment 5

2 years ago
I don't see this as a high priority currently, but agree search services need review, and should include the search team. Search is frequently targeted by browser hijackers, and the policy around search needs to be reviewed, updated, and surfaced in the product. Off the top I don't see querying and/or using existing search services to present challenges, but there do need to be better user controls in place for any kind of modification outside that. This may also be impacted by work on platform, search, front-end, and other components, and it makes sense to get more input.

I'll add this to my backlog, and will try to get a rough proposal out before the holidays start in earnest.
Flags: needinfo?(kev)

Comment 6

2 years ago
As Qwant partnering closely with Mozilla, we are looking for this bug to move forward. Our current extension is not compatible with Electrolysis and this bug is missing for us to migrate our extension to WebExtensions. Any chance to prioritize this as high ?

Updated

2 years ago
webextensions: --- → ?

Updated

2 years ago
Assignee: nobody → kev
Duplicate of this bug: 1276817

Comment 9

2 years ago
I there, I also require a WebExtensions API to access the browser's search engines (I use nsIBrowserSearchService currently), so this would make it possible to port my add-on. I'm the developer of Swift Selection Search:
https://addons.mozilla.org/en-US/firefox/addon/swift-selection-search
Could it be possible to add the ability to clear the search bar text on the API ?

Comment 11

2 years ago
Shouldn't 

chrome.searchengines.setDefault() // set one engine as default

be part of the API
(In reply to Tobias Mueller from comment #11)
> Shouldn't 
> 
> chrome.searchengines.setDefault() // set one engine as default
> 
> be part of the API

There's Bug 1301315 for this.

Comment 13

2 years ago
(In reply to Tim Nguyen :ntim from comment #12)
> There's Bug 1301315 for this.
Afaik this bug handles setting via manifest file only.
What about if an extension wants manage search engines? Or provide a setting to change the default?
(In reply to Tobias Mueller from comment #13)
> Or provide a setting to change the default?

Is the UI in the Firefox preferences not enough to set the default? I don't expect users to need to change their default engines frequently.
(Assignee)

Comment 15

2 years ago
The UI in Firefox makes it very simple for the user to change defaults. At this time, we don't plan on adding the capability to set the search default via an extension with the WebExtensions API. 


(In reply to Tobias Mueller from comment #13)
> (In reply to Tim Nguyen :ntim from comment #12)
> > There's Bug 1301315 for this.
> Afaik this bug handles setting via manifest file only.
> What about if an extension wants manage search engines? Or provide a setting
> to change the default?
Will there be an API to get all the details (icon, prefix URL and search engine name) for the current (default) search engine?
(Assignee)

Comment 17

2 years ago
See bug 1301315 for query details. 

(In reply to Geoffrey De Belie (Smile4ever) from comment #16)
> Will there be an API to get all the details (icon, prefix URL and search
> engine name) for the current (default) search engine?

Updated

2 years ago
webextensions: ? → ---
Getting the default search engine would help with an extension wishing to cleanly assign the search provider itself in it's own container, as per: https://github.com/mozilla/testpilot-containers/issues/434

Updated

2 years ago
Whiteboard: [design-decision-needed]triaged → triaged

Updated

2 years ago
See Also: → bug 1352598
Blocks: 1311472
I'm totally new to developing ffx extensions and I wanted to create a web extension that uses the search engines from the search bar. I encountered a lot of trouble trying stuff from the MDN only to finally discover that you can't import nsIBrowserSearchService when using the WebExtensions API. I'm surprised to see that this has been a pending issue for a year now despite being very blocking for many extension developers. Can somebody please explain what is holding back firefox developers from unblocking the situation? Is the issue technical or political? I've been a encouraging donator for the further development of firefox, but this is a bit disappointing!
(In reply to Olivier de Broqueville from comment #19)
> I'm totally new to developing ffx extensions and I wanted to create a web
> extension that uses the search engines from the search bar. 

I think you want bug 1352598.

>Can somebody please explain what is holding back firefox developers from unblocking the situation?

Changing the search engines (unlike just querying them, see the linked bug) is controversial because changing the default search engine is one of the most common hijacking attacks against browsers.
(In reply to Gian-Carlo Pascutto [:gcp] from comment #20)
> Changing the search engines (unlike just querying them, see the linked bug)
> is controversial because changing the default search engine is one of the
> most common hijacking attacks against browsers.

Thank you for your explanation, Gian-Carlo. Personally, I'm not looking for a way to modify the default search engine. I wanted to create a contextual search extension, which integrates with Firefox's search bar. Right-clicking on selected text in a web page would present a user with a contextual menu listing all the search engines he or she uses in the search bar. Unfortunately, with WebExtensions, I currently have no way of reading the list of search engines available in the search bar. For the mean time, I've resorted to creating a pre-specified list of search engines a user has to choose from, but I understand some users would preferably define their own search engines.

Comment 22

a year ago
Following this bug for "Duplicate Tabs Closer" extension compatibility.
OK, so looking at this more, what's being asked for is a simple "query search engines" API which I think is a good idea. I think there are good usecases for this (I've already found some).

I'm going to put together a spec and see what folks think. It's basically querying engines, including which is the default and possibility building a submission URL with an engine (so you have the possibility of executing a search in your addon).

Comment 24

a year ago
Mike, thanks for looking into it. 

Can you please also include the icon (e.g. base64 URI) as a retrievable property, e.g. so we can use it for menu items or whatever other use-cases people have? This is what nsISearchEngine currently provides. I'm looking for my add-on to provide the glue that bridges the search plugin API (this bug) and the change implemented in bug 1321544.

In fact, I guess this bug is essentially asking for a read-only exposed interface over nsIBrowserSearchService.getVisibleEngines() and nsISearchEngine.

A further consideration... Currently my add-on (and probably others) implements search via nsISearchSubmission, which permits sending data over POST. I assume the search box in the toolbar still does this as well, as that's where I essentially duplicated the implementation from originally. It would be nice if that behaviour can be preserved, but I don't know if that's just scope-creeping this bug or whether there should be a follow-up to allow this via the tabs API if not already possible.

Quick reference links:
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISearchEngine
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIBrowserSearchService
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISearchSubmission

Screenshot of my add-on for context (pun not intended):
https://www.basson.at/images/addons/contextsearch.png

Comment 25

a year ago
Depending on what you're planning to implement under this bug, it may be worth closing off bug 1352598 as a dupe of this one?
(In reply to Ben Basson from comment #25)
> Depending on what you're planning to implement under this bug, it may be
> worth closing off bug 1352598 as a dupe of this one?

I really would prefer Mike doing its idea for 1352598, and leaving this bug to include, at least, the capacity to add engines programmatically, so another different set of add-ons, as "Add to Search Bar", can be ported.
(In reply to Mike Kaply [:mkaply] from comment #23)
> OK, so looking at this more, what's being asked for is a simple "query
> search engines" API which I think is a good idea. I think there are good
> usecases for this (I've already found some).
> 
> I'm going to put together a spec and see what folks think. It's basically
> querying engines, including which is the default and possibility building a
> submission URL with an engine (so you have the possibility of executing a
> search in your addon).

Please see https://github.com/Smile4ever/webext-experiment-searchengines for the research I did. The webextension experiment is far from finished, but it provides some clues on which data is available in Firefox and other OpenSearchDescription implementations of search engines.
(In reply to Geoffrey De Belie (Smile4ever) from comment #27)
> (In reply to Mike Kaply [:mkaply] from comment #23)
> > OK, so looking at this more, what's being asked for is a simple "query
> > search engines" API which I think is a good idea. I think there are good
> > usecases for this (I've already found some).
> > 
> > I'm going to put together a spec and see what folks think. It's basically
> > querying engines, including which is the default and possibility building a
> > submission URL with an engine (so you have the possibility of executing a
> > search in your addon).
> 
> Please see https://github.com/Smile4ever/webext-experiment-searchengines for
> the research I did. The webextension experiment is far from finished, but it
> provides some clues on which data is available in Firefox and other
> OpenSearchDescription implementations of search engines.

This looks better than a spec. Did you consider going through the official process to try to get this into Firefox?

See:

http://webextensions-experiments.readthedocs.io/en/latest/uplifting.html

Comment 29

a year ago
from another bug:
November 14 WebExtensions
APIs triage meeting.

Here’s a quick overview of what to expect at the triage: 
* We normally spend 5 minutes per bug
* The more information in the bug, the better
* The goal of the triage is to give a general thumbs up or thumbs down on a
proposal; we won't be going deep into implementation details

Relevant Links: 
* Wiki for the meeting: https://wiki.mozilla.org/Add-ons/Contribute/Triage
* Meeting agenda:
https://docs.google.com/document/d/1g3RMfKZ3671NcusMqkoOiKwfPekRe-VI7Rzqxo6F_Ao/edit#
* Vision doc for WebExtensions: https://wiki.mozilla.org/WebExtensions/Vision

Comment 30

9 months ago
(In reply to Worcester12345 from comment #29)
> from another bug:
> November 14 WebExtensions
> APIs triage meeting.
> 
> Here’s a quick overview of what to expect at the triage: 
> * We normally spend 5 minutes per bug
> * The more information in the bug, the better
> * The goal of the triage is to give a general thumbs up or thumbs down on a
> proposal; we won't be going deep into implementation details
> 
> Relevant Links: 
> * Wiki for the meeting: https://wiki.mozilla.org/Add-ons/Contribute/Triage
> * Meeting agenda:
> https://docs.google.com/document/d/1g3RMfKZ3671NcusMqkoOiKwfPekRe-
> VI7Rzqxo6F_Ao/edit#
> * Vision doc for WebExtensions: https://wiki.mozilla.org/WebExtensions/Vision

Just went to the page, and it says next meeting is January 10.  Are these meetings not happening any more? That said, if they are still happening, it would be nice if this bug could get on the agenda. Thanks.
See previous question and note outdated wiki.
Flags: needinfo?(mozilla)

Comment 32

9 months ago
I was going to put together a spec, but after looking at :

https://github.com/Smile4ever/webext-experiment-searchengines

I thought Geoffrey might want to spearhead the process.

Geoffrey, is this something you are interested in making happen?
Flags: needinfo?(mozilla) → needinfo?(geoffreydebelie)

Comment 33

9 months ago
Can you get this into the next "triage" meeting agenda? When is that meeting? Thanks.
Hi all, we're going to bring this back into the triage meeting on March 6, 2018. Mike, it would be awesome if you could update the bug once you've confirmed the current plan. 

Relevant links: 
Agenda: https://docs.google.com/document/d/1n-Cbk3d6j394mObWPMhQsfIyHIL08RhC_IEV2QBV1x8/edit#
Wiki: https://wiki.mozilla.org/WebExtensions/Triage

Comment 35

8 months ago
I'm honestly really confused at this point because bug 1352598 seems to be approved and has an initial implementation of the query search engine APIs.

I'm going to remove this from the triage meeting for today while I try to figure out what the actual plan is.

Comment 36

8 months ago
(In reply to Mike Kaply [:mkaply] from comment #35)
> I'm honestly really confused at this point because bug 1352598 seems to be
> approved and has an initial implementation of the query search engine APIs.
> 
> I'm going to remove this from the triage meeting for today while I try to
> figure out what the actual plan is.

Please don't. I think these are two separate things. Isn't this the whole point of bringing it to that meeting?
;-)
Thanks.

Comment 37

8 months ago
> Please don't. I think these are two separate things. Isn't this the whole point of bringing it to that meeting?

We have no plans to allow adding search engine dynamically via WebExtensions. We've had too many problems with hijacking.

Specifying engines via manifest.json is the only way to add engines.

I thought what we were discussing at the triage was the API for querying/using engines.
(Reporter)

Comment 38

8 months ago
I'm very sorry I missed the triage meeting...

A half of the original motivation of this proposal is already covered by the bug 1428948. On company use, policies (Policy Engine) is a reasonable solution to do that. The rest half is: removing search engines via Policy Engine. Some system administrators want to remove Amazon from default list of search engines shown in the location bar (or the search bar), and another want to remove Google.

Comment 39

8 months ago
> The rest half is: removing search engines via Policy Engine. Some system administrators want to remove Amazon from default list of search engines shown in the location bar (or the search bar), and another want to remove Google.

This is something we plan for the policy engine.

Comment 40

8 months ago
We're not going to expand WebExtensions capabilities in this area, duplicating to the policy engine bug.
Status: NEW → RESOLVED
Last Resolved: 8 months ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1428948
Clearing the needinfo requested in the wrong bug. Correct bug for the needinfo request would be  https://bugzilla.mozilla.org/show_bug.cgi?id=1352598
Flags: needinfo?(geoffreydebelie)

Updated

5 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.