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

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

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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 // 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
5 /** 4 /**
6 * @constructor 5 * @unrestricted
7 * @extends {WebInspector.SDKModel}
8 * @param {!WebInspector.Target} target
9 */ 6 */
10 WebInspector.SecurityOriginManager = function(target) 7 WebInspector.SecurityOriginManager = class extends WebInspector.SDKModel {
11 { 8 /**
12 WebInspector.SDKModel.call(this, WebInspector.SecurityOriginManager, target) ; 9 * @param {!WebInspector.Target} target
10 */
11 constructor(target) {
12 super(WebInspector.SecurityOriginManager, target);
13 13
14 this._securityOriginCounter = new Map(); 14 this._securityOriginCounter = new Map();
15 this._mainSecurityOrigin = ""; 15 this._mainSecurityOrigin = '';
16 }
17
18 /**
19 * @param {!WebInspector.Target} target
20 * @return {!WebInspector.SecurityOriginManager}
21 */
22 static fromTarget(target) {
23 var securityOriginManager =
24 /** @type {?WebInspector.SecurityOriginManager} */ (target.model(WebInsp ector.SecurityOriginManager));
25 if (!securityOriginManager)
26 securityOriginManager = new WebInspector.SecurityOriginManager(target);
27 return securityOriginManager;
28 }
29
30 /**
31 * @param {string} securityOrigin
32 */
33 addSecurityOrigin(securityOrigin) {
34 var currentCount = this._securityOriginCounter.get(securityOrigin);
35 if (!currentCount) {
36 this._securityOriginCounter.set(securityOrigin, 1);
37 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Events.Se curityOriginAdded, securityOrigin);
38 return;
39 }
40 this._securityOriginCounter.set(securityOrigin, currentCount + 1);
41 }
42
43 /**
44 * @param {string} securityOrigin
45 */
46 removeSecurityOrigin(securityOrigin) {
47 var currentCount = this._securityOriginCounter.get(securityOrigin);
48 if (currentCount === 1) {
49 this._securityOriginCounter.delete(securityOrigin);
50 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Events.Se curityOriginRemoved, securityOrigin);
51 return;
52 }
53 this._securityOriginCounter.set(securityOrigin, currentCount - 1);
54 }
55
56 /**
57 * @return {!Array<string>}
58 */
59 securityOrigins() {
60 return this._securityOriginCounter.keysArray();
61 }
62
63 /**
64 * @return {string}
65 */
66 mainSecurityOrigin() {
67 return this._mainSecurityOrigin;
68 }
69
70 /**
71 * @param {string} securityOrigin
72 */
73 setMainSecurityOrigin(securityOrigin) {
74 this._mainSecurityOrigin = securityOrigin;
75 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Events.Main SecurityOriginChanged, securityOrigin);
76 }
16 }; 77 };
17 78
18 /** @enum {symbol} */ 79 /** @enum {symbol} */
19 WebInspector.SecurityOriginManager.Events = { 80 WebInspector.SecurityOriginManager.Events = {
20 SecurityOriginAdded: Symbol("SecurityOriginAdded"), 81 SecurityOriginAdded: Symbol('SecurityOriginAdded'),
21 SecurityOriginRemoved: Symbol("SecurityOriginRemoved"), 82 SecurityOriginRemoved: Symbol('SecurityOriginRemoved'),
22 MainSecurityOriginChanged: Symbol("MainSecurityOriginChanged") 83 MainSecurityOriginChanged: Symbol('MainSecurityOriginChanged')
23 }; 84 };
24 85
25 /**
26 * @param {!WebInspector.Target} target
27 * @return {!WebInspector.SecurityOriginManager}
28 */
29 WebInspector.SecurityOriginManager.fromTarget = function(target)
30 {
31 var securityOriginManager = /** @type {?WebInspector.SecurityOriginManager} */ (target.model(WebInspector.SecurityOriginManager));
32 if (!securityOriginManager)
33 securityOriginManager = new WebInspector.SecurityOriginManager(target);
34 return securityOriginManager;
35 };
36 86
37 WebInspector.SecurityOriginManager.prototype = {
38 /**
39 * @param {string} securityOrigin
40 */
41 addSecurityOrigin: function(securityOrigin)
42 {
43 var currentCount = this._securityOriginCounter.get(securityOrigin);
44 if (!currentCount) {
45 this._securityOriginCounter.set(securityOrigin, 1);
46 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Eve nts.SecurityOriginAdded, securityOrigin);
47 return;
48 }
49 this._securityOriginCounter.set(securityOrigin, currentCount + 1);
50 },
51
52 /**
53 * @param {string} securityOrigin
54 */
55 removeSecurityOrigin: function(securityOrigin)
56 {
57 var currentCount = this._securityOriginCounter.get(securityOrigin);
58 if (currentCount === 1) {
59 this._securityOriginCounter.delete(securityOrigin);
60 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Eve nts.SecurityOriginRemoved, securityOrigin);
61 return;
62 }
63 this._securityOriginCounter.set(securityOrigin, currentCount - 1);
64 },
65
66 /**
67 * @return {!Array<string>}
68 */
69 securityOrigins: function()
70 {
71 return this._securityOriginCounter.keysArray();
72 },
73
74 /**
75 * @return {string}
76 */
77 mainSecurityOrigin: function()
78 {
79 return this._mainSecurityOrigin;
80 },
81
82 /**
83 * @param {string} securityOrigin
84 */
85 setMainSecurityOrigin: function(securityOrigin)
86 {
87 this._mainSecurityOrigin = securityOrigin;
88 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Events. MainSecurityOriginChanged, securityOrigin);
89 },
90
91 __proto__: WebInspector.SDKModel.prototype
92 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698