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

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

Issue 2610963005: [DevTools] Pass the frame payload (Closed)
Patch Set: [DevTools] Pass the frame payload Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 SDK.SecurityOriginManager = class extends SDK.SDKModel { 7 SDK.SecurityOriginManager = class extends SDK.SDKModel {
8 /** 8 /**
9 * @param {!SDK.Target} target 9 * @param {!SDK.Target} target
10 */ 10 */
11 constructor(target) { 11 constructor(target) {
12 super(SDK.SecurityOriginManager, target); 12 super(SDK.SecurityOriginManager, target);
13 13
14 this._securityOriginCounter = new Map(); 14 /** @type {!Set<string>} */
15 this._securityOrigins = new Set();
15 this._mainSecurityOrigin = ''; 16 this._mainSecurityOrigin = '';
16 } 17 }
17 18
18 /** 19 /**
19 * @param {!SDK.Target} target 20 * @param {!SDK.Target} target
20 * @return {!SDK.SecurityOriginManager} 21 * @return {!SDK.SecurityOriginManager}
21 */ 22 */
22 static fromTarget(target) { 23 static fromTarget(target) {
23 var securityOriginManager = target.model(SDK.SecurityOriginManager); 24 var securityOriginManager = target.model(SDK.SecurityOriginManager);
24 if (!securityOriginManager) 25 if (!securityOriginManager)
25 securityOriginManager = new SDK.SecurityOriginManager(target); 26 securityOriginManager = new SDK.SecurityOriginManager(target);
26 return securityOriginManager; 27 return securityOriginManager;
27 } 28 }
28 29
29 /** 30 /**
30 * @param {string} securityOrigin 31 * @param {!Set<string>} securityOrigins
31 */ 32 */
32 addSecurityOrigin(securityOrigin) { 33 updateSecurityOrigins(securityOrigins) {
33 var currentCount = this._securityOriginCounter.get(securityOrigin); 34 var oldOrigins = this._securityOrigins;
34 if (!currentCount) { 35 this._securityOrigins = new Set(securityOrigins);
pfeldman 2017/01/09 20:34:47 No need to wrap in a new set, it is already a set.
eostroukhov 2017/01/09 22:09:49 I don't trust API users... But I changed the code.
35 this._securityOriginCounter.set(securityOrigin, 1); 36
36 this.dispatchEventToListeners(SDK.SecurityOriginManager.Events.SecurityOri ginAdded, securityOrigin); 37 for (var origin of oldOrigins) {
37 return; 38 if (!this._securityOrigins.has(origin))
39 this.dispatchEventToListeners(SDK.SecurityOriginManager.Events.SecurityO riginRemoved, origin);
38 } 40 }
39 this._securityOriginCounter.set(securityOrigin, currentCount + 1);
40 }
41 41
42 /** 42 for (var origin of this._securityOrigins) {
43 * @param {string} securityOrigin 43 if (!oldOrigins.has(origin))
44 */ 44 this.dispatchEventToListeners(SDK.SecurityOriginManager.Events.SecurityO riginAdded, origin);
45 removeSecurityOrigin(securityOrigin) {
46 var currentCount = this._securityOriginCounter.get(securityOrigin);
47 if (currentCount === 1) {
48 this._securityOriginCounter.delete(securityOrigin);
49 this.dispatchEventToListeners(SDK.SecurityOriginManager.Events.SecurityOri ginRemoved, securityOrigin);
50 return;
51 } 45 }
52 this._securityOriginCounter.set(securityOrigin, currentCount - 1);
53 } 46 }
54 47
55 /** 48 /**
56 * @return {!Array<string>} 49 * @return {!Array<string>}
57 */ 50 */
58 securityOrigins() { 51 securityOrigins() {
59 return this._securityOriginCounter.keysArray(); 52 return this._securityOrigins.valuesArray();
60 } 53 }
61 54
62 /** 55 /**
63 * @return {string} 56 * @return {string}
64 */ 57 */
65 mainSecurityOrigin() { 58 mainSecurityOrigin() {
66 return this._mainSecurityOrigin; 59 return this._mainSecurityOrigin;
67 } 60 }
68 61
69 /** 62 /**
70 * @param {string} securityOrigin 63 * @param {string} securityOrigin
71 */ 64 */
72 setMainSecurityOrigin(securityOrigin) { 65 setMainSecurityOrigin(securityOrigin) {
73 this._mainSecurityOrigin = securityOrigin; 66 this._mainSecurityOrigin = securityOrigin;
74 this.dispatchEventToListeners(SDK.SecurityOriginManager.Events.MainSecurityO riginChanged, securityOrigin); 67 this.dispatchEventToListeners(SDK.SecurityOriginManager.Events.MainSecurityO riginChanged, securityOrigin);
75 } 68 }
76 }; 69 };
77 70
78 /** @enum {symbol} */ 71 /** @enum {symbol} */
79 SDK.SecurityOriginManager.Events = { 72 SDK.SecurityOriginManager.Events = {
80 SecurityOriginAdded: Symbol('SecurityOriginAdded'), 73 SecurityOriginAdded: Symbol('SecurityOriginAdded'),
81 SecurityOriginRemoved: Symbol('SecurityOriginRemoved'), 74 SecurityOriginRemoved: Symbol('SecurityOriginRemoved'),
82 MainSecurityOriginChanged: Symbol('MainSecurityOriginChanged') 75 MainSecurityOriginChanged: Symbol('MainSecurityOriginChanged')
83 }; 76 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698