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: Created Nov. 10, 2016, 3:16 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 | 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..5355d5b86db91211ec61d6c4056407a5bd1b2bd4 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,27 @@
// 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 can be fired from a page before its navigation has been
+ // confirmed we have to also update the page structure here. Otherwise those
+ // requests will be using the old structure, meaning first party requests
+ // might be considered third party. (We also need to listen for this event
+ // in order to get the parentFrameId which onCommitted doesn't provide.)
+ ext._updatePageFrameStructure(details.frameId, details.tabId,
+ details.url, false, details.parentFrameId);
+ });
+
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