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

Delta Between Two Patch Sets: chrome/ext/background.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Left Patch Set: Fixed issues in content script breaking element hide tracing Created Jan. 30, 2016, 6:19 p.m.
Right Patch Set: Adapt for UI changes generating domain specific filters when necessary Created Feb. 3, 2016, 10:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/devtools.js ('k') | chrome/ext/devtools.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 524 }
525 525
526 return frames[0]; 526 return frames[0];
527 } 527 }
528 }; 528 };
529 } 529 }
530 530
531 return ext.onMessage._dispatch(message, sender, sendResponse).indexOf(true) != -1; 531 return ext.onMessage._dispatch(message, sender, sendResponse).indexOf(true) != -1;
532 }); 532 });
533 533
534 // We have to ensure there is at least one listener for the onConnect event.
535 // Otherwise we can't connect a port later, which we need to do in order to
536 // detect when the extension is reloaded, disabled or uninstalled.
537 chrome.runtime.onConnect.addListener(function() {});
538
539 534
540 /* Storage */ 535 /* Storage */
541 536
542 ext.storage = { 537 ext.storage = {
543 get: function(keys, callback) 538 get: function(keys, callback)
544 { 539 {
545 chrome.storage.local.get(keys, callback); 540 chrome.storage.local.get(keys, callback);
546 }, 541 },
547 set: function(key, value, callback) 542 set: function(key, value, callback)
548 { 543 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 if (callback) 579 if (callback)
585 callback(new Page(tab)); 580 callback(new Page(tab));
586 } 581 }
587 else 582 else
588 { 583 {
589 ext.pages.open(optionsUrl, callback); 584 ext.pages.open(optionsUrl, callback);
590 } 585 }
591 }); 586 });
592 }); 587 });
593 }; 588 };
594
595
596 /* Devtools panel */
597
598 var Panel = function(inspectedTabId, port)
599 {
600 this.inspectedTabId = inspectedTabId;
601 this._port = port;
602 };
603 Panel.prototype = {
604 sendMessage: function(message)
605 {
606 this._port.postMessage(message);
607 },
608 get onRemoved()
609 {
610 return this._port.onDisconnect;
611 }
612 };
613
614 ext.devtools = {
615 onCreated: new ext._EventTarget()
616 };
617
618 // If this code should ever be removed, note that we still have to
619 // ensure that there is at least one listener for the onConnect event.
620 // Otherwise we can't connect a port later, in order to detect when
621 // the extension is reloaded,disabled or uninstalled.
622 chrome.runtime.onConnect.addListener(function(port)
623 {
624 var match = port.name.match(/^devtools-(\d+)$/);
625 if (match)
626 {
627 var panel = new Panel(parseInt(match[1], 10), port);
kzar 2016/01/31 13:33:51 Nit: Maybe should use let instead of var for these
Sebastian Noack 2016/02/02 10:39:51 I'd rather keep things conistent. (Except for one
628 ext.devtools.onCreated._dispatch(panel);
629 }
630 });
631 })(); 589 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld