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

Unified Diff: 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, 5:06 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 | chrome/ext/background.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -30,11 +30,17 @@
}
with(require("whitelisting"))
{
- this.isWhitelisted = isWhitelisted;
+ this.isPageWhitelisted = isPageWhitelisted;
this.isFrameWhitelisted = isFrameWhitelisted;
this.processKey = processKey;
this.getKey = getKey;
}
+with(require("url"))
+{
+ this.stringifyURL = stringifyURL;
+ this.isThirdParty = isThirdParty;
+ this.extractHostFromFrame = extractHostFromFrame;
+}
var FilterStorage = require("filterStorage").FilterStorage;
var ElemHide = require("elemHide").ElemHide;
var defaultMatcher = require("matcher").defaultMatcher;
@@ -127,7 +133,7 @@
// Adds or removes browser action icon according to options.
function refreshIconAndContextMenu(page)
{
- var whitelisted = isWhitelisted(page.url);
+ var whitelisted = isPageWhitelisted(page);
var iconFilename;
if (whitelisted && require("info").platform != "safari")
@@ -500,10 +506,13 @@
break;
}
- var requestHost = extractHostFromURL(msg.url);
+ var url = new URL(msg.url);
var documentHost = extractHostFromFrame(sender.frame);
- var thirdParty = isThirdParty(requestHost, documentHost);
- var filter = defaultMatcher.matchesAny(msg.url, msg.mediatype, documentHost, thirdParty);
+ var filter = defaultMatcher.matchesAny(
+ stringifyURL(url), msg.mediatype,
+ documentHost, isThirdParty(url, documentHost)
+ );
+
if (filter instanceof BlockingFilter)
{
var collapse = filter.collapse;
@@ -519,7 +528,7 @@
// The browser action popup asks us this.
if(sender.page)
{
- sendResponse({enabled: !isWhitelisted(sender.page.url)});
+ sendResponse({enabled: !isPageWhitelisted(sender.page)});
return;
}
break;
« no previous file with comments | « no previous file | chrome/ext/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld