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

Side by Side Diff: chrome/ext/background.js

Issue 6136997097766912: Fallback to the top-level frame if we don't know the frame on Chrome (Closed)
Patch Set: Created Jan. 23, 2014, 8:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 // the high-level code isn't interested in top frame requests and 457 // the high-level code isn't interested in top frame requests and
458 // since those can only be handled in Chrome, we ignore them here 458 // since those can only be handled in Chrome, we ignore them here
459 // instead of in the browser independent high-level code. 459 // instead of in the browser independent high-level code.
460 if (details.type == "main_frame") 460 if (details.type == "main_frame")
461 return; 461 return;
462 } 462 }
463 else 463 else
464 frameId = details.frameId; 464 frameId = details.frameId;
465 465
466 // the high-level code relies on the frame. However in case the frame can't
467 // be controlled by the extension or the extension was (re)loaded after the
468 // frame was loaded, the frame is unknown and we have to ignore the request.
469 if (!(frameId in frames)) 466 if (!(frameId in frames))
470 return; 467 {
468 // the high-level code relies on the frame. So ignore the request if we
469 // don't even know the top-level frame. That can happen for example when
470 // the extension was just (re)loaded.
471 if (!(0 in frames))
472 return;
473
474 // however when the src of the frame is a javascript: or data: URL, we
475 // don't know the frame either. But since we know the top-level frame we
476 // can just pretend that we are in the top-level frame, in order to have
477 // at least most domain-based filter rules working.
478 frameId = 0;
479 if (details.type == "sub_frame")
480 frames[details.frameId].parent = frameId;
481 }
471 482
472 var frame = new Frame({id: frameId, tab: tab}); 483 var frame = new Frame({id: frameId, tab: tab});
473 484
474 for (var i = 0; i < ext.webRequest.onBeforeRequest._listeners.length; i++) 485 for (var i = 0; i < ext.webRequest.onBeforeRequest._listeners.length; i++)
475 { 486 {
476 if (ext.webRequest.onBeforeRequest._listeners[i](details.url, details.type , tab, frame) === false) 487 if (ext.webRequest.onBeforeRequest._listeners[i](details.url, details.type , tab, frame) === false)
477 return {cancel: true}; 488 return {cancel: true};
478 } 489 }
479 }, {urls: ["<all_urls>"]}, ["blocking"]); 490 }, {urls: ["<all_urls>"]}, ["blocking"]);
480 491
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if (isContextMenuHidden) 569 if (isContextMenuHidden)
559 return; 570 return;
560 571
561 chrome.contextMenus.removeAll(); 572 chrome.contextMenus.removeAll();
562 isContextMenuHidden = true; 573 isContextMenuHidden = true;
563 } 574 }
564 }; 575 };
565 576
566 ext.onMessage = new BackgroundMessageEventTarget(); 577 ext.onMessage = new BackgroundMessageEventTarget();
567 })(); 578 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld