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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 */ | 659 */ |
660 _createNetworkRequest: function(requestId, frameId, loaderId, url, documentU
RL, initiator) | 660 _createNetworkRequest: function(requestId, frameId, loaderId, url, documentU
RL, initiator) |
661 { | 661 { |
662 return new WebInspector.NetworkRequest(this._manager._target, requestId,
url, documentURL, frameId, loaderId, initiator); | 662 return new WebInspector.NetworkRequest(this._manager._target, requestId,
url, documentURL, frameId, loaderId, initiator); |
663 } | 663 } |
664 } | 664 } |
665 | 665 |
666 | 666 |
667 /** | 667 /** |
668 * @constructor | 668 * @constructor |
| 669 * @extends {WebInspector.Object} |
669 * @implements {WebInspector.TargetManager.Observer} | 670 * @implements {WebInspector.TargetManager.Observer} |
670 */ | 671 */ |
671 WebInspector.MultitargetNetworkManager = function() | 672 WebInspector.MultitargetNetworkManager = function() |
672 { | 673 { |
| 674 WebInspector.Object.call(this); |
673 WebInspector.targetManager.observeTargets(this); | 675 WebInspector.targetManager.observeTargets(this); |
| 676 |
| 677 /** @type {!Set<string>} */ |
| 678 this._blockedURLs = new Set(); |
| 679 } |
| 680 |
| 681 WebInspector.MultitargetNetworkManager.EventTypes = { |
| 682 BlockedURLsChanged: "BlockedURLsChanged" |
674 } | 683 } |
675 | 684 |
676 WebInspector.MultitargetNetworkManager.prototype = { | 685 WebInspector.MultitargetNetworkManager.prototype = { |
677 /** | 686 /** |
678 * @override | 687 * @override |
679 * @param {!WebInspector.Target} target | 688 * @param {!WebInspector.Target} target |
680 */ | 689 */ |
681 targetAdded: function(target) | 690 targetAdded: function(target) |
682 { | 691 { |
683 var networkAgent = target.networkAgent(); | 692 var networkAgent = target.networkAgent(); |
684 if (this._extraHeaders) | 693 if (this._extraHeaders) |
685 networkAgent.setExtraHTTPHeaders(this._extraHeaders); | 694 networkAgent.setExtraHTTPHeaders(this._extraHeaders); |
686 if (typeof this._userAgent !== "undefined") | 695 if (typeof this._userAgent !== "undefined") |
687 networkAgent.setUserAgentOverride(this._userAgent); | 696 networkAgent.setUserAgentOverride(this._userAgent); |
| 697 for (var url of this._blockedURLs) |
| 698 networkAgent.addBlockedURL(url); |
688 }, | 699 }, |
689 | 700 |
690 /** | 701 /** |
691 * @override | 702 * @override |
692 * @param {!WebInspector.Target} target | 703 * @param {!WebInspector.Target} target |
693 */ | 704 */ |
694 targetRemoved: function(target) | 705 targetRemoved: function(target) |
695 { | 706 { |
696 }, | 707 }, |
697 | 708 |
698 /** | 709 /** |
699 * @param {!NetworkAgent.Headers} headers | 710 * @param {!NetworkAgent.Headers} headers |
700 */ | 711 */ |
701 setExtraHTTPHeaders: function(headers) | 712 setExtraHTTPHeaders: function(headers) |
702 { | 713 { |
703 this._extraHeaders = headers; | 714 this._extraHeaders = headers; |
704 for (var target of WebInspector.targetManager.targets()) | 715 for (var target of WebInspector.targetManager.targets()) |
705 target.networkAgent().setExtraHTTPHeaders(this._extraHeaders); | 716 target.networkAgent().setExtraHTTPHeaders(this._extraHeaders); |
706 }, | 717 }, |
707 | 718 |
708 /** | 719 /** |
709 * @param {string} userAgent | 720 * @param {string} userAgent |
710 */ | 721 */ |
711 setUserAgentOverride: function(userAgent) | 722 setUserAgentOverride: function(userAgent) |
712 { | 723 { |
713 WebInspector.ResourceLoader.targetUserAgent = userAgent; | 724 WebInspector.ResourceLoader.targetUserAgent = userAgent; |
714 this._userAgent = userAgent; | 725 this._userAgent = userAgent; |
715 for (var target of WebInspector.targetManager.targets()) | 726 for (var target of WebInspector.targetManager.targets()) |
716 target.networkAgent().setUserAgentOverride(this._userAgent); | 727 target.networkAgent().setUserAgentOverride(this._userAgent); |
717 } | 728 }, |
| 729 |
| 730 /** |
| 731 * @param {string} url |
| 732 */ |
| 733 toggleURLBlocked: function(url) |
| 734 { |
| 735 if (this._blockedURLs.has(url)) { |
| 736 this._blockedURLs.delete(url); |
| 737 for (var target of WebInspector.targetManager.targets()) |
| 738 target.networkAgent().removeBlockedURL(url); |
| 739 } else { |
| 740 this._blockedURLs.add(url); |
| 741 for (var target of WebInspector.targetManager.targets()) |
| 742 target.networkAgent().addBlockedURL(url); |
| 743 } |
| 744 this.dispatchEventToListeners(WebInspector.MultitargetNetworkManager.Eve
ntTypes.BlockedURLsChanged); |
| 745 }, |
| 746 |
| 747 /** |
| 748 * @return {!Set<string>} |
| 749 */ |
| 750 blockedURLs: function() |
| 751 { |
| 752 return this._blockedURLs; |
| 753 }, |
| 754 |
| 755 __proto__: WebInspector.Object.prototype |
718 } | 756 } |
719 | 757 |
720 /** | 758 /** |
721 * @type {!WebInspector.MultitargetNetworkManager} | 759 * @type {!WebInspector.MultitargetNetworkManager} |
722 */ | 760 */ |
723 WebInspector.multitargetNetworkManager; | 761 WebInspector.multitargetNetworkManager; |
OLD | NEW |