Chromium Code Reviews| Index: Source/devtools/front_end/security/SecurityModel.js |
| diff --git a/Source/devtools/front_end/security/SecurityModel.js b/Source/devtools/front_end/security/SecurityModel.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3e19b74ecfc3bd45869049da3c6a1d73e65842a3 |
| --- /dev/null |
| +++ b/Source/devtools/front_end/security/SecurityModel.js |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2015 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.SecurityModel = function(target) |
| +{ |
| + WebInspector.SDKModel.call(this, WebInspector.SecurityModel, target); |
| + this._dispatcher = new WebInspector.SecurityDispatcher(this); |
| + this._securityAgent = target.securityAgent(); |
| + target.registerSecurityDispatcher(this._dispatcher); |
| + this._securityAgent.enable(); |
| + |
| + this._securityState = "unknown"; |
| +} |
| + |
| +WebInspector.SecurityModel.EventTypes = { |
| + SecurityStateChanged: "SecurityStateChanged" |
| +} |
| + |
| +WebInspector.SecurityModel.prototype = { |
| + /** |
| + * @return {!SecurityAgent.SecurityState} securityState |
| + */ |
| + securityState: function() { |
|
dgozman
2015/06/16 13:42:58
{ on next line.
|
| + return /** @type {!SecurityAgent.SecurityState} */ (this._securityState); |
| + }, |
| + |
| + __proto__: WebInspector.SDKModel.prototype |
| +} |
| + |
| +/** |
| + * @param {!WebInspector.Target} target |
| + * @return {?WebInspector.SecurityModel} |
| + */ |
| +WebInspector.SecurityModel.fromTarget = function(target) |
| +{ |
| + var model = /** @type {?WebInspector.SecurityModel} */ (target.model(WebInspector.SecurityModel)); |
| + if (!model) |
| + model = new WebInspector.SecurityModel(target); |
| + return model; |
| +} |
| + |
| +/** |
| + * @constructor |
| + * @implements {SecurityAgent.Dispatcher} |
| + */ |
| +WebInspector.SecurityDispatcher = function(manager) |
|
dgozman
2015/06/16 13:42:58
manager->model
lgarron
2015/06/16 19:25:43
Done.
|
| +{ |
| + this._manager = manager; |
| +} |
| + |
| +WebInspector.SecurityDispatcher.prototype = { |
| + /** |
| + * @override |
| + * @param {!SecurityAgent.SecurityState} securityState |
| + */ |
| + securityStateChanged: function(securityState) |
| + { |
| + this._manager._securityState = securityState; |
| + this._manager.dispatchEventToListeners(WebInspector.SecurityModel.EventTypes.SecurityStateChanged, securityState); |
| + } |
| +} |