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

Unified Diff: chrome/ext/background.js

Issue 5564089086509056: Issue 1801 - Use URL objects to process URLs in the background page (Closed)
Patch Set: Rebased and addressed comments Created Feb. 11, 2015, 10:54 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 | « background.js ('k') | lib/basedomain.js » ('j') | lib/url.js » ('J')
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
@@ -22,7 +22,7 @@
var Page = ext.Page = function(tab)
{
this._id = tab.id;
- this._url = tab.url;
+ this._url = tab.url && new URL(tab.url);
this.browserAction = new BrowserAction(tab.id);
this.contextMenus = new ContextMenus(this);
@@ -32,7 +32,7 @@
{
// usually our Page objects are created from Chrome's Tab objects, which
Wladimir Palant 2015/02/11 13:45:45 Nit: A sentence is usually started by a capital le
Sebastian Noack 2015/02/11 17:07:06 Note that I just reverted those lines including th
// provide the url. So we can return the url given in the constructor.
- if (this._url != null)
+ if (this._url)
return this._url;
// but sometimes we only have the tab id when we create a Page object.
Sebastian Noack 2015/02/11 10:55:51 All changes below are due to rebase.
@@ -342,7 +342,7 @@
var frames = framesOfTabs[tab.id] = {__proto__: null};
for (var i = 0; i < details.length; i++)
- frames[details[i].frameId] = {url: details[i].url, parent: null};
+ frames[details[i].frameId] = {url: new URL(details[i].url), parent: null};
for (var i = 0; i < details.length; i++)
{
@@ -382,6 +382,7 @@
frames = framesOfTabs[details.tabId] = {__proto__: null};
var frame = null;
+ var url = new URL(details.url);
if (!isMainFrame)
{
// we are looking for the frame that contains the element that
@@ -404,7 +405,7 @@
requestType = "object";
var results = ext.webRequest.onBeforeRequest._dispatch(
- details.url,
+ url,
requestType,
new Page({id: details.tabId}),
frame
@@ -416,7 +417,7 @@
}
if (isMainFrame || details.type == "sub_frame")
- frames[details.frameId] = {url: details.url, parent: frame};
+ frames[details.frameId] = {url: url, parent: frame};
}
catch (e)
{
@@ -435,7 +436,7 @@
var sender = {
page: new Page(rawSender.tab),
frame: {
- url: rawSender.url,
+ url: new URL(rawSender.url),
get parent()
{
var frames = framesOfTabs[rawSender.tab.id];
@@ -455,7 +456,7 @@
// Chrome 28-40
for (var frameId in frames)
{
- if (frames[frameId].url == rawSender.url)
+ if (frames[frameId].url.href == this.url.href)
return frames[frameId].parent;
}
}
« no previous file with comments | « background.js ('k') | lib/basedomain.js » ('j') | lib/url.js » ('J')

Powered by Google App Engine
This is Rietveld