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

Unified Diff: chrome/ext/background.js

Issue 29350213: Issue 4364 - Drop support for Chrome 29-40 and remove legacy code (Closed)
Patch Set: Rebased, renamed function to runInPageContext(), fixed typo in comment Created Sept. 9, 2016, 2:38 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 | composer.postload.js » ('j') | 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
@@ -483,50 +483,40 @@
chrome.webRequest.onBeforeRequest.addListener(function(details)
{
- // the high-level code isn't interested in requests that aren't related
- // to a tab and since those can only be handled in Chrome, we ignore
- // them here instead of in the browser independent high-level code.
- if (details.tabId == -1)
+ // the high-level code isn't interested in requests that aren't
+ // related to a tab or requests loading a top-level document,
+ // those should never be blocked
+ if (details.tabId == -1 || details.type == "main_frame")
return;
- var isMainFrame = details.type == "main_frame" || (
- // assume that the first request belongs to the top frame. Chrome 29
- // may give the top frame the type "object" instead of "main_frame".
- // https://code.google.com/p/chromium/issues/detail?id=281711
- details.frameId == 0 && !(details.tabId in framesOfTabs)
- );
+ // we are looking for the frame that contains the element that
+ // is about to load, however if a frame is loading the surrounding
+ // frame is indicated by parentFrameId instead of frameId
+ var frameId;
+ var requestType;
+ if (details.type == "sub_frame")
+ {
+ frameId = details.parentFrameId;
+ requestType = "SUBDOCUMENT";
+ }
+ else
+ {
+ frameId = details.frameId;
+ requestType = details.type.toUpperCase();
+ }
- if (!isMainFrame)
+ var frame = ext.getFrame(details.tabId, frameId);
+ if (frame)
{
- // we are looking for the frame that contains the element that
- // is about to load, however if a frame is loading the surrounding
- // frame is indicated by parentFrameId instead of frameId
- var frameId;
- var requestType;
- if (details.type == "sub_frame")
- {
- frameId = details.parentFrameId;
- requestType = "SUBDOCUMENT";
- }
- else
- {
- frameId = details.frameId;
- requestType = details.type.toUpperCase();
- }
+ var results = ext.webRequest.onBeforeRequest._dispatch(
+ new URL(details.url),
+ requestType,
+ new Page({id: details.tabId}),
+ frame
+ );
- var frame = ext.getFrame(details.tabId, frameId);
- if (frame)
- {
- var results = ext.webRequest.onBeforeRequest._dispatch(
- new URL(details.url),
- requestType,
- new Page({id: details.tabId}),
- frame
- );
-
- if (results.indexOf(false) != -1)
- return {cancel: true};
- }
+ if (results.indexOf(false) != -1)
+ return {cancel: true};
}
}, {urls: ["http://*/*", "https://*/*"]}, ["blocking"]);
« no previous file with comments | « no previous file | composer.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld