Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js

Issue 2296953004: Send certificates to devtools when it's open instead of using certId (Closed)
Patch Set: self review Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 this._networkAgent.setCacheDisabled(true); 44 this._networkAgent.setCacheDisabled(true);
45 if (WebInspector.moduleSetting("monitoringXHREnabled").get()) 45 if (WebInspector.moduleSetting("monitoringXHREnabled").get())
46 this._networkAgent.setMonitoringXHREnabled(true); 46 this._networkAgent.setMonitoringXHREnabled(true);
47 47
48 // Limit buffer when talking to a remote device. 48 // Limit buffer when talking to a remote device.
49 if (Runtime.queryParam("remoteFrontend") || Runtime.queryParam("ws")) 49 if (Runtime.queryParam("remoteFrontend") || Runtime.queryParam("ws"))
50 this._networkAgent.enable(10000000, 5000000); 50 this._networkAgent.enable(10000000, 5000000);
51 else 51 else
52 this._networkAgent.enable(); 52 this._networkAgent.enable();
53 53
54 /** @type {!Map<!SecurityAgent.CertificateId, !Promise<!NetworkAgent.Certifi cateDetails>>} */
55 this._certificateDetailsCache = new Map();
56
57 this._bypassServiceWorkerSetting = WebInspector.settings.createSetting("bypa ssServiceWorker", false); 54 this._bypassServiceWorkerSetting = WebInspector.settings.createSetting("bypa ssServiceWorker", false);
58 if (this._bypassServiceWorkerSetting.get()) 55 if (this._bypassServiceWorkerSetting.get())
59 this._bypassServiceWorkerChanged(); 56 this._bypassServiceWorkerChanged();
60 this._bypassServiceWorkerSetting.addChangeListener(this._bypassServiceWorker Changed, this); 57 this._bypassServiceWorkerSetting.addChangeListener(this._bypassServiceWorker Changed, this);
61 58
62 WebInspector.moduleSetting("cacheDisabled").addChangeListener(this._cacheDis abledSettingChanged, this); 59 WebInspector.moduleSetting("cacheDisabled").addChangeListener(this._cacheDis abledSettingChanged, this);
63 } 60 }
64 61
65 /** @enum {symbol} */ 62 /** @enum {symbol} */
66 WebInspector.NetworkManager.Events = { 63 WebInspector.NetworkManager.Events = {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 var enabled = /** @type {boolean} */ (event.data); 140 var enabled = /** @type {boolean} */ (event.data);
144 this._networkAgent.setCacheDisabled(enabled); 141 this._networkAgent.setCacheDisabled(enabled);
145 }, 142 },
146 143
147 dispose: function() 144 dispose: function()
148 { 145 {
149 WebInspector.moduleSetting("cacheDisabled").removeChangeListener(this._c acheDisabledSettingChanged, this); 146 WebInspector.moduleSetting("cacheDisabled").removeChangeListener(this._c acheDisabledSettingChanged, this);
150 }, 147 },
151 148
152 /** 149 /**
153 * @param {!SecurityAgent.CertificateId} certificateId
154 * @return {!Promise<!NetworkAgent.CertificateDetails>}
155 */
156 certificateDetailsPromise: function(certificateId)
157 {
158 var cachedPromise = this._certificateDetailsCache.get(certificateId);
159 if (cachedPromise)
160 return cachedPromise;
161
162 /**
163 * @this {WebInspector.NetworkManager}
164 * @param {function(?NetworkAgent.CertificateDetails)} resolve
165 * @param {function()} reject
166 */
167 function executor(resolve, reject) {
168 /**
169 * @param {?Protocol.Error} error
170 * @param {?NetworkAgent.CertificateDetails} certificateDetails
171 */
172 function innerCallback(error, certificateDetails)
173 {
174 if (error) {
175 console.error("Unable to get certificate details from the br owser (for certificate ID ", certificateId, "): ", error);
176 reject();
177 } else {
178 resolve(certificateDetails);
179 }
180 }
181 this._networkAgent.getCertificateDetails(certificateId, innerCallbac k);
182 }
183
184 var promise = new Promise(executor.bind(this));
185
186 this._certificateDetailsCache.set(certificateId, promise);
187 return promise;
188 },
189
190 /**
191 * @return {!WebInspector.Setting} 150 * @return {!WebInspector.Setting}
192 */ 151 */
193 bypassServiceWorkerSetting: function() 152 bypassServiceWorkerSetting: function()
194 { 153 {
195 return this._bypassServiceWorkerSetting; 154 return this._bypassServiceWorkerSetting;
196 }, 155 },
197 156
198 _bypassServiceWorkerChanged: function() 157 _bypassServiceWorkerChanged: function()
199 { 158 {
200 this._networkAgent.setBypassServiceWorker(this._bypassServiceWorkerSetti ng.get()); 159 this._networkAgent.setBypassServiceWorker(this._bypassServiceWorkerSetti ng.get());
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 target.networkAgent().clearBrowserCache(); 870 target.networkAgent().clearBrowserCache();
912 }, 871 },
913 872
914 clearBrowserCookies: function() 873 clearBrowserCookies: function()
915 { 874 {
916 for (var target of WebInspector.targetManager.targets()) 875 for (var target of WebInspector.targetManager.targets())
917 target.networkAgent().clearBrowserCookies(); 876 target.networkAgent().clearBrowserCookies();
918 }, 877 },
919 878
920 /** 879 /**
921 * @param {!SecurityAgent.CertificateId} certificateId 880 * @param {string} origin
881 * @param {function(!Array<string>)} callback
922 */ 882 */
923 showCertificateViewer: function(certificateId) 883 getCertificate: function(origin, callback)
924 { 884 {
925 var target = WebInspector.targetManager.mainTarget(); 885 var target = WebInspector.targetManager.mainTarget();
926 if (target) 886 target.networkAgent().getCertificate(origin, mycallback);
927 target.networkAgent().showCertificateViewer(certificateId); 887
888 /**
889 * @param {?Protocol.Error} error
890 * @param {!Array<string>} certificate
891 */
892 function mycallback(error, certificate)
893 {
894 callback(error ? [] : certificate);
895 }
928 }, 896 },
929 897
930 /** 898 /**
931 * @param {string} url 899 * @param {string} url
932 * @param {function(number, !Object.<string, string>, string)} callback 900 * @param {function(number, !Object.<string, string>, string)} callback
933 */ 901 */
934 loadResource: function(url, callback) 902 loadResource: function(url, callback)
935 { 903 {
936 var headers = {}; 904 var headers = {};
937 905
938 var currentUserAgent = this._currentUserAgent(); 906 var currentUserAgent = this._currentUserAgent();
939 if (currentUserAgent) 907 if (currentUserAgent)
940 headers["User-Agent"] = currentUserAgent; 908 headers["User-Agent"] = currentUserAgent;
941 909
942 if (WebInspector.moduleSetting("cacheDisabled").get()) 910 if (WebInspector.moduleSetting("cacheDisabled").get())
943 headers["Cache-Control"] = "no-cache"; 911 headers["Cache-Control"] = "no-cache";
944 912
945 WebInspector.ResourceLoader.load(url, headers, callback); 913 WebInspector.ResourceLoader.load(url, headers, callback);
946 }, 914 },
947 915
948 __proto__: WebInspector.Object.prototype 916 __proto__: WebInspector.Object.prototype
949 } 917 }
950 918
951 /** 919 /**
952 * @type {!WebInspector.MultitargetNetworkManager} 920 * @type {!WebInspector.MultitargetNetworkManager}
953 */ 921 */
954 WebInspector.multitargetNetworkManager; 922 WebInspector.multitargetNetworkManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698