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

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

Issue 2172753002: [DevTools] No longer store security origins in ResourceTreeModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the comments Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @constructor
7 * @extends {WebInspector.SDKModel}
8 * @param {!WebInspector.Target} target
9 */
10 WebInspector.SecurityOriginManager = function(target)
11 {
12 WebInspector.SDKModel.call(this, WebInspector.SecurityOriginManager, target) ;
13
14 this._securityOriginCounter = new Map();
15 this._mainSecurityOrigin = "";
16 }
17
18 WebInspector.SecurityOriginManager.EventTypes = {
19 SecurityOriginAdded: "SecurityOriginAdded",
20 SecurityOriginRemoved: "SecurityOriginRemoved",
21 MainSecurityOriginChanged: "MainSecurityOriginChanged",
22 }
23
24 /**
25 * @param {!WebInspector.Target} target
26 * @return {!WebInspector.SecurityOriginManager}
27 */
28 WebInspector.SecurityOriginManager.fromTarget = function(target)
29 {
30 var securityOriginManager = /** @type {?WebInspector.SecurityOriginManager} */ (target.model(WebInspector.SecurityOriginManager));
31 if (!securityOriginManager)
32 securityOriginManager = new WebInspector.SecurityOriginManager(target);
33 return securityOriginManager;
34 }
35
36 WebInspector.SecurityOriginManager.prototype = {
37 /**
38 * @param {string} securityOrigin
39 */
40 addSecurityOrigin: function(securityOrigin)
41 {
42 var currentCount = this._securityOriginCounter.get(securityOrigin);
43 if (!currentCount) {
44 this._securityOriginCounter.set(securityOrigin, 1);
45 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Eve ntTypes.SecurityOriginAdded, securityOrigin);
46 return;
47 }
48 this._securityOriginCounter.set(securityOrigin, currentCount + 1);
49 },
50
51 /**
52 * @param {string} securityOrigin
53 */
54 removeSecurityOrigin: function(securityOrigin)
55 {
56 var currentCount = this._securityOriginCounter.get(securityOrigin);
57 if (currentCount === 1) {
58 this._securityOriginCounter.delete(securityOrigin);
59 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.Eve ntTypes.SecurityOriginRemoved, securityOrigin);
60 return;
61 }
62 this._securityOriginCounter.set(securityOrigin, currentCount - 1);
63 },
64
65 /**
66 * @return {!Array<string>}
67 */
68 securityOrigins: function()
69 {
70 return this._securityOriginCounter.keysArray();
71 },
72
73 /**
74 * @return {string}
75 */
76 mainSecurityOrigin: function()
77 {
78 return this._mainSecurityOrigin;
79 },
80
81 /**
82 * @param {string} securityOrigin
83 */
84 setMainSecurityOrigin: function(securityOrigin)
85 {
86 this._mainSecurityOrigin = securityOrigin;
87 this.dispatchEventToListeners(WebInspector.SecurityOriginManager.EventTy pes.MainSecurityOriginChanged, securityOrigin);
88 },
89
90 __proto__: WebInspector.SDKModel.prototype
91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698