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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/SecurityOriginManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/SecurityOriginManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/SecurityOriginManager.js
new file mode 100644
index 0000000000000000000000000000000000000000..ba98e4f8ba3d23d35311816ee04fe879eb5220dd
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/SecurityOriginManager.js
@@ -0,0 +1,91 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @constructor
+ * @extends {WebInspector.SDKModel}
+ * @param {!WebInspector.Target} target
+ */
+WebInspector.SecurityOriginManager = function(target)
+{
+ WebInspector.SDKModel.call(this, WebInspector.SecurityOriginManager, target);
+
+ this._securityOriginCounter = new Map();
+ this._mainSecurityOrigin = "";
+}
+
+WebInspector.SecurityOriginManager.EventTypes = {
+ SecurityOriginAdded: "SecurityOriginAdded",
+ SecurityOriginRemoved: "SecurityOriginRemoved",
+ MainSecurityOriginChanged: "MainSecurityOriginChanged",
+}
+
+/**
+ * @param {!WebInspector.Target} target
+ * @return {!WebInspector.SecurityOriginManager}
+ */
+WebInspector.SecurityOriginManager.fromTarget = function(target)
+{
+ var securityOriginManager = /** @type {?WebInspector.SecurityOriginManager} */ (target.model(WebInspector.SecurityOriginManager));
+ if (!securityOriginManager)
+ securityOriginManager = new WebInspector.SecurityOriginManager(target);
+ return securityOriginManager;
+}
+
+WebInspector.SecurityOriginManager.prototype = {
+ /**
+ * @param {string} securityOrigin
+ */
+ addSecurityOrigin: function(securityOrigin)
+ {
+ var currentCount = this._securityOriginCounter.get(securityOrigin);
+ if (!currentCount) {
+ this._securityOriginCounter.set(securityOrigin, 1);
+ this.dispatchEventToListeners(WebInspector.SecurityOriginManager.EventTypes.SecurityOriginAdded, securityOrigin);
+ return;
+ }
+ this._securityOriginCounter.set(securityOrigin, currentCount + 1);
+ },
+
+ /**
+ * @param {string} securityOrigin
+ */
+ removeSecurityOrigin: function(securityOrigin)
+ {
+ var currentCount = this._securityOriginCounter.get(securityOrigin);
+ if (currentCount === 1) {
+ this._securityOriginCounter.delete(securityOrigin);
+ this.dispatchEventToListeners(WebInspector.SecurityOriginManager.EventTypes.SecurityOriginRemoved, securityOrigin);
+ return;
+ }
+ this._securityOriginCounter.set(securityOrigin, currentCount - 1);
+ },
+
+ /**
+ * @return {!Array<string>}
+ */
+ securityOrigins: function()
+ {
+ return this._securityOriginCounter.keysArray();
+ },
+
+ /**
+ * @return {string}
+ */
+ mainSecurityOrigin: function()
+ {
+ return this._mainSecurityOrigin;
+ },
+
+ /**
+ * @param {string} securityOrigin
+ */
+ setMainSecurityOrigin: function(securityOrigin)
+ {
+ this._mainSecurityOrigin = securityOrigin;
+ this.dispatchEventToListeners(WebInspector.SecurityOriginManager.EventTypes.MainSecurityOriginChanged, securityOrigin);
+ },
+
+ __proto__: WebInspector.SDKModel.prototype
+}

Powered by Google App Engine
This is Rietveld 408576698