Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 SecurityOriginChanged: "SecurityOriginChanged", | |
|
dgozman
2016/07/22 23:44:23
MainSecurityOriginChanged
eostroukhov-old
2016/07/25 18:16:59
Done.
| |
| 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 Array.from(this._securityOriginCounter.keys()); | |
|
dgozman
2016/07/22 23:44:23
Is there a keysArray() method defined in utilities
eostroukhov-old
2016/07/25 18:16:59
Done.
| |
| 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.SecurityOriginChanged, securityOrigin); | |
| 88 }, | |
| 89 | |
| 90 __proto__: WebInspector.SDKModel.prototype | |
| 91 } | |
| OLD | NEW |