OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 * @extends {WebInspector.Object} | 671 * @extends {WebInspector.Object} |
672 * @implements {WebInspector.TargetManager.Observer} | 672 * @implements {WebInspector.TargetManager.Observer} |
673 */ | 673 */ |
674 WebInspector.MultitargetNetworkManager = function() | 674 WebInspector.MultitargetNetworkManager = function() |
675 { | 675 { |
676 WebInspector.Object.call(this); | 676 WebInspector.Object.call(this); |
677 WebInspector.targetManager.observeTargets(this); | 677 WebInspector.targetManager.observeTargets(this); |
678 | 678 |
679 /** @type {!Set<string>} */ | 679 /** @type {!Set<string>} */ |
680 this._blockedURLs = new Set(); | 680 this._blockedURLs = new Set(); |
681 } | 681 this._blockedSetting = WebInspector.moduleSetting("blockedURLs"); |
682 | 682 this._blockedSetting.addChangeListener(this._updateBlockedURLs, this); |
683 WebInspector.MultitargetNetworkManager.EventTypes = { | 683 this._updateBlockedURLs(); |
684 BlockedURLsChanged: "BlockedURLsChanged" | |
685 } | 684 } |
686 | 685 |
687 WebInspector.MultitargetNetworkManager.prototype = { | 686 WebInspector.MultitargetNetworkManager.prototype = { |
688 /** | 687 /** |
689 * @override | 688 * @override |
690 * @param {!WebInspector.Target} target | 689 * @param {!WebInspector.Target} target |
691 */ | 690 */ |
692 targetAdded: function(target) | 691 targetAdded: function(target) |
693 { | 692 { |
694 var networkAgent = target.networkAgent(); | 693 var networkAgent = target.networkAgent(); |
(...skipping 27 matching lines...) Expand all Loading... |
722 * @param {string} userAgent | 721 * @param {string} userAgent |
723 */ | 722 */ |
724 setUserAgentOverride: function(userAgent) | 723 setUserAgentOverride: function(userAgent) |
725 { | 724 { |
726 WebInspector.ResourceLoader.targetUserAgent = userAgent; | 725 WebInspector.ResourceLoader.targetUserAgent = userAgent; |
727 this._userAgent = userAgent; | 726 this._userAgent = userAgent; |
728 for (var target of WebInspector.targetManager.targets()) | 727 for (var target of WebInspector.targetManager.targets()) |
729 target.networkAgent().setUserAgentOverride(this._userAgent); | 728 target.networkAgent().setUserAgentOverride(this._userAgent); |
730 }, | 729 }, |
731 | 730 |
| 731 _updateBlockedURLs: function() |
| 732 { |
| 733 var blocked = this._blockedSetting.get(); |
| 734 for (var url of blocked) { |
| 735 if (!this._blockedURLs.has(url)) |
| 736 this._addBlockedURL(url); |
| 737 } |
| 738 for (var url of this._blockedURLs) { |
| 739 if (blocked.indexOf(url) === -1) |
| 740 this._removeBlockedURL(url); |
| 741 } |
| 742 }, |
| 743 |
732 /** | 744 /** |
733 * @param {string} url | 745 * @param {string} url |
734 */ | 746 */ |
735 toggleURLBlocked: function(url) | 747 _addBlockedURL: function(url) |
736 { | 748 { |
737 if (this._blockedURLs.has(url)) { | 749 this._blockedURLs.add(url); |
738 this._blockedURLs.delete(url); | 750 for (var target of WebInspector.targetManager.targets()) |
739 for (var target of WebInspector.targetManager.targets()) | 751 target.networkAgent().addBlockedURL(url); |
740 target.networkAgent().removeBlockedURL(url); | |
741 } else { | |
742 this._blockedURLs.add(url); | |
743 for (var target of WebInspector.targetManager.targets()) | |
744 target.networkAgent().addBlockedURL(url); | |
745 } | |
746 this.dispatchEventToListeners(WebInspector.MultitargetNetworkManager.Eve
ntTypes.BlockedURLsChanged); | |
747 }, | 752 }, |
748 | 753 |
749 /** | 754 /** |
750 * @return {!Set<string>} | 755 * @param {string} url |
751 */ | 756 */ |
752 blockedURLs: function() | 757 _removeBlockedURL: function(url) |
753 { | 758 { |
754 return this._blockedURLs; | 759 this._blockedURLs.delete(url); |
| 760 for (var target of WebInspector.targetManager.targets()) |
| 761 target.networkAgent().removeBlockedURL(url); |
755 }, | 762 }, |
756 | 763 |
757 __proto__: WebInspector.Object.prototype | 764 __proto__: WebInspector.Object.prototype |
758 } | 765 } |
759 | 766 |
760 /** | 767 /** |
761 * @type {!WebInspector.MultitargetNetworkManager} | 768 * @type {!WebInspector.MultitargetNetworkManager} |
762 */ | 769 */ |
763 WebInspector.multitargetNetworkManager; | 770 WebInspector.multitargetNetworkManager; |
OLD | NEW |