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

Unified Diff: chrome/ext/background.js

Issue 29350357: Issue 4386 - Fixed determining document domain, particularly after being redirected (Closed)
Patch Set: Created Aug. 31, 2016, 3:11 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
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -105,18 +105,38 @@
};
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
{
if (changeInfo.status == "loading")
ext.pages.onLoading._dispatch(new Page(tab));
});
+ function createFrame(tabId, frameId)
+ {
+ var frames = framesOfTabs[details.tabId];
kzar 2016/09/01 11:06:48 It should be `tabId` and `frameId` rather than `de
Wladimir Palant 2016/09/05 15:48:25 Ouch, not sure how I missed that in the testing. F
+ if (!frames)
+ frames = framesOfTabs[details.tabId] = Object.create(null);
+
+ var frame = frames[details.frameId];
+ if (!frame)
+ frame = frames[details.frameId] = {};
kzar 2016/08/31 16:06:39 Nit: Seems inconsistent to do `Object.create(null)
Wladimir Palant 2016/08/31 19:13:44 Yes, seems inconsistent but other than the frames
kzar 2016/09/01 11:06:48 Acknowledged.
+
+ 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 = frames[details.parentFrameId] || null;
kzar 2016/08/31 16:06:39 Since both times we use createFrame we just want t
Wladimir Palant 2016/08/31 19:13:44 Frankly, I think that this would specialize the fu
kzar 2016/09/01 11:06:48 Acknowledged.
kzar 2016/09/01 12:46:15 We don't assign the frame's URL here in case the n
kzar 2016/09/01 13:22:57 OK it turns out both onCommitted and onBeforeNavig
kzar 2016/09/01 13:39:13 I have something working now, I hope you don't min
+ });
+
+ chrome.webNavigation.onCommitted.addListener(function(details)
+ {
if (details.frameId == 0)
{
ext._removeFromAllPageMaps(details.tabId);
chrome.tabs.get(details.tabId, function()
{
// If the tab is prerendered, chrome.tabs.get() sets
// chrome.runtime.lastError and we have to dispatch the onLoading event,
@@ -131,25 +151,19 @@
id: details.tabId,
url: details.url
})
);
}
});
}
- // Add or update frame in frame structure
- var frames = framesOfTabs[details.tabId];
- if (!frames)
- frames = framesOfTabs[details.tabId] = Object.create(null);
-
- frames[details.frameId] = {
- parent: frames[details.parentFrameId] || null,
- url: new URL(details.url)
- };
+ // Update frame URL in frame structure
+ var frame = createFrame(details.tabId, details.frameId);
+ frame.url = new URL(details.url);
});
function forgetTab(tabId)
{
ext.pages.onRemoved._dispatch(tabId);
ext._removeFromAllPageMaps(tabId);
delete framesOfTabs[tabId];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld