| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 664 |
| 665 | 665 |
| 666 /** | 666 /** |
| 667 * @constructor | 667 * @constructor |
| 668 * @extends {WebInspector.Object} | 668 * @extends {WebInspector.Object} |
| 669 * @implements {WebInspector.TargetManager.Observer} | 669 * @implements {WebInspector.TargetManager.Observer} |
| 670 */ | 670 */ |
| 671 WebInspector.MultitargetNetworkManager = function() | 671 WebInspector.MultitargetNetworkManager = function() |
| 672 { | 672 { |
| 673 WebInspector.Object.call(this); | 673 WebInspector.Object.call(this); |
| 674 WebInspector.targetManager.observeTargets(this); | |
| 675 | 674 |
| 676 /** @type {!Set<string>} */ | 675 /** @type {!Set<string>} */ |
| 677 this._blockedURLs = new Set(); | 676 this._blockedURLs = new Set(); |
| 678 this._blockedSetting = WebInspector.moduleSetting("blockedURLs"); | 677 this._blockedSetting = WebInspector.moduleSetting("blockedURLs"); |
| 679 this._blockedSetting.addChangeListener(this._updateBlockedURLs, this); | 678 this._blockedSetting.addChangeListener(this._updateBlockedURLs, this); |
| 680 this._blockedSetting.set([]); | 679 this._blockedSetting.set([]); |
| 681 this._updateBlockedURLs(); | 680 this._updateBlockedURLs(); |
| 682 | 681 |
| 683 this._userAgentOverride = ""; | 682 this._userAgentOverride = ""; |
| 684 /** @type {!Set<!Protocol.NetworkAgent>} */ | 683 /** @type {!Set<!Protocol.NetworkAgent>} */ |
| 685 this._agents = new Set(); | 684 this._agents = new Set(); |
| 686 /** @type {!WebInspector.NetworkManager.Conditions} */ | 685 /** @type {!WebInspector.NetworkManager.Conditions} */ |
| 687 this._networkConditions = WebInspector.NetworkManager.NoThrottlingConditions
; | 686 this._networkConditions = WebInspector.NetworkManager.NoThrottlingConditions
; |
| 687 |
| 688 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Network); |
| 688 }; | 689 }; |
| 689 | 690 |
| 690 /** @enum {symbol} */ | 691 /** @enum {symbol} */ |
| 691 WebInspector.MultitargetNetworkManager.Events = { | 692 WebInspector.MultitargetNetworkManager.Events = { |
| 692 ConditionsChanged: Symbol("ConditionsChanged"), | 693 ConditionsChanged: Symbol("ConditionsChanged"), |
| 693 UserAgentChanged: Symbol("UserAgentChanged") | 694 UserAgentChanged: Symbol("UserAgentChanged") |
| 694 }; | 695 }; |
| 695 | 696 |
| 696 /** | 697 /** |
| 697 * @param {string} uaString | 698 * @param {string} uaString |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 networkAgent.emulateNetworkConditions(this.isOffline(), conditions.l
atency, conditions.download < 0 ? 0 : conditions.download, conditions.upload < 0
? 0 : conditions.upload, WebInspector.NetworkManager._connectionType(conditions
)); | 783 networkAgent.emulateNetworkConditions(this.isOffline(), conditions.l
atency, conditions.download < 0 ? 0 : conditions.download, conditions.upload < 0
? 0 : conditions.upload, WebInspector.NetworkManager._connectionType(conditions
)); |
| 783 } | 784 } |
| 784 }, | 785 }, |
| 785 | 786 |
| 786 /** | 787 /** |
| 787 * @param {!NetworkAgent.Headers} headers | 788 * @param {!NetworkAgent.Headers} headers |
| 788 */ | 789 */ |
| 789 setExtraHTTPHeaders: function(headers) | 790 setExtraHTTPHeaders: function(headers) |
| 790 { | 791 { |
| 791 this._extraHeaders = headers; | 792 this._extraHeaders = headers; |
| 792 for (var target of WebInspector.targetManager.targets()) | 793 for (var agent of this._agents) |
| 793 target.networkAgent().setExtraHTTPHeaders(this._extraHeaders); | 794 agent.setExtraHTTPHeaders(this._extraHeaders); |
| 794 }, | 795 }, |
| 795 | 796 |
| 796 /** | 797 /** |
| 797 * @return {string} | 798 * @return {string} |
| 798 */ | 799 */ |
| 799 _currentUserAgent: function() | 800 _currentUserAgent: function() |
| 800 { | 801 { |
| 801 return this._customUserAgent ? this._customUserAgent : this._userAgentOv
erride; | 802 return this._customUserAgent ? this._customUserAgent : this._userAgentOv
erride; |
| 802 }, | 803 }, |
| 803 | 804 |
| 804 _updateUserAgentOverride: function() | 805 _updateUserAgentOverride: function() |
| 805 { | 806 { |
| 806 var userAgent = this._currentUserAgent(); | 807 var userAgent = this._currentUserAgent(); |
| 807 WebInspector.ResourceLoader.targetUserAgent = userAgent; | 808 WebInspector.ResourceLoader.targetUserAgent = userAgent; |
| 808 for (var target of WebInspector.targetManager.targets()) | 809 for (var agent of this._agents) |
| 809 target.networkAgent().setUserAgentOverride(userAgent); | 810 agent.setUserAgentOverride(userAgent); |
| 810 }, | 811 }, |
| 811 | 812 |
| 812 /** | 813 /** |
| 813 * @param {string} userAgent | 814 * @param {string} userAgent |
| 814 */ | 815 */ |
| 815 setUserAgentOverride: function(userAgent) | 816 setUserAgentOverride: function(userAgent) |
| 816 { | 817 { |
| 817 if (this._userAgentOverride === userAgent) | 818 if (this._userAgentOverride === userAgent) |
| 818 return; | 819 return; |
| 819 this._userAgentOverride = userAgent; | 820 this._userAgentOverride = userAgent; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 this._removeBlockedURL(url); | 852 this._removeBlockedURL(url); |
| 852 } | 853 } |
| 853 }, | 854 }, |
| 854 | 855 |
| 855 /** | 856 /** |
| 856 * @param {string} url | 857 * @param {string} url |
| 857 */ | 858 */ |
| 858 _addBlockedURL: function(url) | 859 _addBlockedURL: function(url) |
| 859 { | 860 { |
| 860 this._blockedURLs.add(url); | 861 this._blockedURLs.add(url); |
| 861 for (var target of WebInspector.targetManager.targets()) | 862 for (var agent of this._agents) |
| 862 target.networkAgent().addBlockedURL(url); | 863 agent.addBlockedURL(url); |
| 863 }, | 864 }, |
| 864 | 865 |
| 865 /** | 866 /** |
| 866 * @param {string} url | 867 * @param {string} url |
| 867 */ | 868 */ |
| 868 _removeBlockedURL: function(url) | 869 _removeBlockedURL: function(url) |
| 869 { | 870 { |
| 870 this._blockedURLs.delete(url); | 871 this._blockedURLs.delete(url); |
| 871 for (var target of WebInspector.targetManager.targets()) | 872 for (var agent of this._agents) |
| 872 target.networkAgent().removeBlockedURL(url); | 873 agent.removeBlockedURL(url); |
| 873 }, | 874 }, |
| 874 | 875 |
| 875 clearBrowserCache: function() | 876 clearBrowserCache: function() |
| 876 { | 877 { |
| 877 for (var target of WebInspector.targetManager.targets()) | 878 for (var agent of this._agents) |
| 878 target.networkAgent().clearBrowserCache(); | 879 agent.clearBrowserCache(); |
| 879 }, | 880 }, |
| 880 | 881 |
| 881 clearBrowserCookies: function() | 882 clearBrowserCookies: function() |
| 882 { | 883 { |
| 883 for (var target of WebInspector.targetManager.targets()) | 884 for (var agent of this._agents) |
| 884 target.networkAgent().clearBrowserCookies(); | 885 agent.clearBrowserCookies(); |
| 885 }, | 886 }, |
| 886 | 887 |
| 887 /** | 888 /** |
| 888 * @param {string} origin | 889 * @param {string} origin |
| 889 * @param {function(!Array<string>)} callback | 890 * @param {function(!Array<string>)} callback |
| 890 */ | 891 */ |
| 891 getCertificate: function(origin, callback) | 892 getCertificate: function(origin, callback) |
| 892 { | 893 { |
| 893 var target = WebInspector.targetManager.mainTarget(); | 894 var target = WebInspector.targetManager.mainTarget(); |
| 894 target.networkAgent().getCertificate(origin, mycallback); | 895 target.networkAgent().getCertificate(origin, mycallback); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 921 WebInspector.ResourceLoader.load(url, headers, callback); | 922 WebInspector.ResourceLoader.load(url, headers, callback); |
| 922 }, | 923 }, |
| 923 | 924 |
| 924 __proto__: WebInspector.Object.prototype | 925 __proto__: WebInspector.Object.prototype |
| 925 }; | 926 }; |
| 926 | 927 |
| 927 /** | 928 /** |
| 928 * @type {!WebInspector.MultitargetNetworkManager} | 929 * @type {!WebInspector.MultitargetNetworkManager} |
| 929 */ | 930 */ |
| 930 WebInspector.multitargetNetworkManager; | 931 WebInspector.multitargetNetworkManager; |
| OLD | NEW |