Open Bug 1262957 Opened 9 years ago Updated 3 years ago

use NavHistoryService visit's transitionType to enhance the webNavigation transition types and qualifiers

Categories

(WebExtensions :: Request Handling, defect, P5)

defect

Tracking

(Not tracked)

REOPENED

People

(Reporter: rpl, Unassigned)

References

Details

(Whiteboard: [webNavigation]triaged)

The WebExtension WebNavigation API contains in some of its events (onCommitted and onHistoryStateUpdated), information that are usually related to the history tracking. A subset of the needed information are already tracked on Firefox: - the PlacesUIUtils.jsm asks the NavHistoryService to mark a visited urls as typed, bookmarks or link, which means the user clicked on a link - https://dxr.mozilla.org/mozilla-central/source/browser/components/places/PlacesUIUtils.jsm#519 - https://dxr.mozilla.org/mozilla-central/source/browser/components/places/PlacesUIUtils.jsm#530 - https://dxr.mozilla.org/mozilla-central/source/browser/components/places/PlacesUIUtils.jsm#540 - the NavHistoryService receives this information and send it to a list of NavHistoryObservers https://dxr.mozilla.org/mozilla-central/source/toolkit/components/places/History.cpp#661 Unfortunately, a NavHistoryObserver's onVisit method receives the visit information too late to be able to use it to detect the transitionType on webNavigation event related to a sub-frame (which will help us to be able to differentiate a manual_subframe from the default auto_subframe transitionType)
Whiteboard: [webNavigation]
After trying to detect this visit information from a registered NavHistoryObserver didn't worked with iframes, as an experiment, with the goal of getting a picture of the issue and its potential solutions, I've added a new "early-mark-visit" event notified using the ObserverService, in the PlacesUIUtils.jsm methods linked above (but obviously doing something similar directly from the NavHistoryService will work too), e.g.: > markPageAsTyped: function PUIU_markPageAsTyped(aURL) { >+ Services.obs.notifyObservers(null, "early-mark-visit", "typed"); > PlacesUtils.history.markPageAsTyped(this.createFixedURI(aURL)); > }, > > markPageAsFollowedBookmark: function PUIU_markPageAsFollowedBookmark(aURL) { >+ Services.obs.notifyObservers(null, "early-mark-visit", "bookmark"); > PlacesUtils.history.markPageAsFollowedBookmark(this.createFixedURI(aURL)); > }, > > markPageAsFollowedLink: function PUIU_markPageAsFollowedLink(aURL) { >+ Services.obs.notifyObservers(null, "early-mark-visit", "link"); > PlacesUtils.history.markPageAsFollowedLink(this.createFixedURI(aURL)); > }, > And then using that "early-mark-visit" to get the necessary info associated to the most current selected tab: >var NavHistoryListener = { > init() { > Services.obs.addObserver(this, "early-mark-visit", false); > }, > > uninit() { > Services.obs.removeObserver(this, "early-mark-visit", false); > }, > > observe: function observe(aSubject, aTopic, aData) { > let tabTransitionData = {}; > > switch (aData) { > case "typed": > tabTransitionData.typed = true; > break; > case "bookmark": > tabTransitionData.bookmark = true; > break; > case "link": > tabTransitionData.link = true; > break; > } > > // Push the information into the internal webNavigation recentTabTransition tracker, > // associate for the current selected tab > WebNavigationManager.pushRecentTabTransitionData(tabTransitionData); > }, >};
Whiteboard: [webNavigation] → [webNavigation]triaged
Depends on: 1263723
Component: WebExtensions: Untriaged → WebExtensions: Request Handling
Priority: -- → P5
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INACTIVE
Status: RESOLVED → REOPENED
Resolution: INACTIVE → ---
Product: Toolkit → WebExtensions
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.