Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8215)

Unified Diff: chrome/common/extensions/docs/examples/api/webNavigation/basic/navigation_collector.js

Issue 10704225: Send an webNavigation event for navigations triggered by window.history (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/api/webNavigation/basic/navigation_collector.js
diff --git a/chrome/common/extensions/docs/examples/api/webNavigation/basic/navigation_collector.js b/chrome/common/extensions/docs/examples/api/webNavigation/basic/navigation_collector.js
index 15b7fa1ac23d631e0c79e3f3d9f7204519389ab7..5493aedc66406c1adcf094f72c9e0b82b1ace936 100644
--- a/chrome/common/extensions/docs/examples/api/webNavigation/basic/navigation_collector.js
+++ b/chrome/common/extensions/docs/examples/api/webNavigation/basic/navigation_collector.js
@@ -60,6 +60,8 @@ function NavigationCollector() {
this.onErrorOccurredListener_.bind(this));
chrome.webNavigation.onReferenceFragmentUpdated.addListener(
this.onReferenceFragmentUpdatedListener_.bind(this));
+ chrome.webNavigation.onHistoryStateUpdated.addListener(
+ this.onHistoryStateUpdatedListener_.bind(this));
// Bind handler to extension messages for communication from popup.
chrome.extension.onRequest.addListener(this.onRequestListener_.bind(this));
@@ -256,6 +258,40 @@ NavigationCollector.prototype = {
/**
+ * Handler for the 'onHistoryStateUpdated' event. Updates the pending
+ * request with transition information.
+ *
+ * Pushes the request onto the
+ * 'pending_' object, and stores it for later use.
+ *
+ * @param {!Object} data The event data generated for this request.
+ * @private
+ */
+ onHistoryStateUpdatedListener_: function(data) {
+ var id = this.parseId_(data);
+ if (!this.pending_[id]) {
+ this.completed_[data.url] = this.completed_[data.url] || [];
+ this.completed_[data.url].push({
+ duration: 0,
+ openedInNewWindow: false,
+ source: {
+ frameId: null,
+ tabId: null
+ },
+ transitionQualifiers: data.transitionQualifiers,
+ transitionType: data.transitionType,
+ url: data.url
+ });
+ } else {
+ this.prepareDataStorage_(id, data.url);
+ this.pending_[id].transitionType = data.transitionType;
+ this.pending_[id].transitionQualifiers =
+ data.transitionQualifiers;
+ }
+ },
+
+
+ /**
* Handler for the 'onCompleted` event. Pulls the request's data from the
* 'pending_' object, combines it with the completed event's data, and pushes
* a new NavigationCollector.Request object onto 'completed_'.

Powered by Google App Engine
This is Rietveld 408576698