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: Fixed another regression from last-minute changes Created Sept. 5, 2016, 3:59 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[tabId];
+ if (!frames)
+ frames = framesOfTabs[tabId] = Object.create(null);
+
+ var frame = frames[frameId];
+ if (!frame)
+ frame = frames[frameId] = {};
+
+ 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;
+ });
+
+ 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