Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/ext/background.js

Issue 29362203: Issue 4599 - Update the page structure more eagerly (Closed)
Patch Set: Only eagerly update structure for new tabs Created Nov. 14, 2016, 2:53 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
diff --git a/chrome/ext/background.js b/chrome/ext/background.js
index 0c8bdfc289fc8276fa7a8c6b5f171ad41e729328..53058d0b5c01578024698ac645a6bae5e48abc7e 100644
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -123,13 +123,6 @@
return frame;
}
- chrome.webNavigation.onBeforeNavigate.addListener(function(details)
- {
- // Capture parent frame here because onCommitted doesn't get this info.
- var frame = createFrame(details.tabId, details.frameId);
- frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null;
- });
-
var eagerlyUpdatedPages = new ext.PageMap();
ext._updatePageFrameStructure = function(frameId, tabId, url, eager)
@@ -168,6 +161,21 @@
frame.url = new URL(url);
};
+ chrome.webNavigation.onBeforeNavigate.addListener(function(details)
+ {
+ // Capture parent frame here because onCommitted doesn't get this info.
+ var frame = createFrame(details.tabId, details.frameId);
+ frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null;
+
+ // Chrome will sometimes perform requests for a pre-rendered page before
+ // navigation was confirmed and the onComitted event was fired. Those
+ // requests will often wrongly be considered as third party, since their
+ // page structure was not recorded. As a work around we update the page
+ // structure eagerly for new tabs (which includes pre-rendered pages).
+ if (!(details.tabId in framesOfTabs))
+ ext._updatePageFrameStructure(details.frameId, details.tabId, details.url);
+ });
+
chrome.webNavigation.onCommitted.addListener(function(details)
{
ext._updatePageFrameStructure(details.frameId, details.tabId, details.url);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld