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: Improve explanation in comment Created Nov. 11, 2016, 9:14 a.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 | lib/whitelisting.js » ('j') | 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..e99a71842f172d1b0943c5ac2226ebc1743c3d05 100644
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -123,16 +123,10 @@
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)
+ ext._updatePageFrameStructure = function(frameId, tabId, url, eager,
+ parentFrameId)
{
if (frameId == 0)
{
@@ -166,11 +160,26 @@
// Update frame URL in frame structure
var frame = createFrame(tabId, frameId);
frame.url = new URL(url);
+
+ // We only get the parentFrameId for onBeforeNavigate, not for onCommitted
+ if (typeof parentFrameId != "undefined")
+ frame.parent = framesOfTabs[tabId][parentFrameId] || null;
};
+ chrome.webNavigation.onBeforeNavigate.addListener(function(details)
+ {
+ // Since requests are sometimes made by a page before its onCommitted event
+ // fires we also need to update the page structure here. Otherwise those
+ // requests will be considered third party since a URL for the page wasn't
+ // yet determined.
+ ext._updatePageFrameStructure(details.frameId, details.tabId,
+ details.url, false, details.parentFrameId);
Wladimir Palant 2016/11/14 08:18:44 You are essentially reverting changes from issue 4
+ });
+
chrome.webNavigation.onCommitted.addListener(function(details)
{
- ext._updatePageFrameStructure(details.frameId, details.tabId, details.url);
+ ext._updatePageFrameStructure(details.frameId, details.tabId,
+ details.url, false);
});
function forgetTab(tabId)
« no previous file with comments | « no previous file | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld