Open Bug 1370388 Opened 7 years ago Updated 2 years ago

Offer an API to intercept and modify the typed URL

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(Not tracked)

People

(Reporter: francois, Unassigned)

References

()

Details

(Whiteboard: [design-decision-approved] triaged investigate )

The following add-on intercepts URLs typed into the URL bar and adds "https://" instead of "http://" if the user types an address without the scheme:

  https://github.com/Rob--W/https-by-default

Unlike HTTPS Everywhere, it does NOT touch URLs that aren't typed directly by the user (e.g. links).

It seems like the existing webRequest API is not sufficient to implement this add-on as a Web Extension. However, maybe a flag could be added in the details (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onBeforeRequest#details) so that add-ons can tell whether or not a URL was "typed"?
Whiteboard: [design-decision-needed] triaged
Hi François, this has been added to the agenda for the July 18 WebExtensions APIs triage meeting. Would you be able to join us? 

Wiki: https://wiki.mozilla.org/Add-ons/Contribute/Triage#Next_Meeting

Agenda: https://docs.google.com/document/d/1gWszBunGAyOJ_V8_HMECXJuZ4Gd_HTM_M7xjDSwSxeo/edit#
I'm marking this issue `investigate` in the whiteboard (and add a needinfo assigned to me):

This should be already possible by combining the webNavigation and the webRequest APIs,
I'm going to take a look and update this bugzilla issue).
Flags: needinfo?(lgreco)
Whiteboard: [design-decision-needed] triaged → [design-decision-needed] triaged investigate
(In reply to Luca Greco [:rpl] from comment #2)
> I'm marking this issue `investigate` in the whiteboard (and add a needinfo
> assigned to me):
> 
> This should be already possible by combining the webNavigation and the
> webRequest APIs,
> I'm going to take a look and update this bugzilla issue).

Unless the originally typed value is added to either API, neither the webNavigation nor the webRequest API provide enough information (i.e. the originally typed string).

For a different use case (custom search keywords, e.g. redirecting "XXX searchterms" to "google.com/search?q=site:XXX.example.com+escaped-searchterms"), I used the webRequest API and unpacked the generated search URL.
This only works because I developed that extension for personal use so I know that the configured search engine has a fixed format. And it does not work if the search term looks like a URL (and Firefox considers anything with a dot in it to be a URL...).

And FYI, the original report references an add-on of mine, so if you want to chat about the use cases, you know where to find me ;)
Severity: normal → enhancement
Priority: -- → P5
I think bug 1393349 comment 1 provide a program for this bug, i.e. provide the TransitionType to onBeforeNavigate, it has "typed".

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webNavigation/transitionType
(In reply to YF (Yang) from comment #4)
> I think bug 1393349 comment 1 provide a program for this bug, i.e. provide
> the TransitionType to onBeforeNavigate, it has "typed".
> 
> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webNavigation/
> transitionType

I looked at the value of transitionType at onCommitted.
The transitionType is "typed" when I press Enter after typing "example.com",
but "link" when I press Alt+Enter (to open in a new tab).

It seems that onBeforeNavigate fires before onBeforeRequest, so if the bug I described in this comment is fixed, and bug 1393349 is fixed, then this bug can be closed too (provided that this order of events is guaranteed).
Depends on: 1393349
Whiteboard: [design-decision-needed] triaged investigate → [design-decision-needed] triaged investigate [needs-follow-up]
This was approved at the February 27, 2018 WebExtensions APIs triage meeting.
Whiteboard: [design-decision-needed] triaged investigate [needs-follow-up] → [design-decision-approved] triaged investigate
Flags: needinfo?(lgreco)
Product: Toolkit → WebExtensions
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.