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=SecurityAgent.SecurityState.Unknown;}
WebInspector.SecurityModel.EventTypes={SecurityStateChanged:"SecurityStateChanged"}
WebInspector.SecurityModel.prototype={securityState:function()
{return(this._securityState);},__proto__:WebInspector.SDKModel.prototype}
WebInspector.SecurityModel.fromTarget=function(target)
{var model=(target.model(WebInspector.SecurityModel));if(!model)
model=new WebInspector.SecurityModel(target);return model;}
WebInspector.SecurityDispatcher=function(model)
{this._model=model;}
WebInspector.SecurityDispatcher.prototype={securityStateChanged:function(securityState,explanations)
{var data={"securityState":securityState,"explanations":explanations||[]};this._model.dispatchEventToListeners(WebInspector.SecurityModel.EventTypes.SecurityStateChanged,data);}};WebInspector.SecurityPanel=function(){WebInspector.PanelWithSidebar.call(this,"security");this.registerRequiredCSS("security/securityPanel.css");this.registerRequiredCSS("security/lockIcon.css");var sidebarTree=new TreeOutlineInShadow();sidebarTree.element.classList.add("sidebar-tree");this.panelSidebarElement().appendChild(sidebarTree.element);sidebarTree.registerRequiredCSS("security/lockIcon.css");this.setDefaultFocusedElement(sidebarTree.element);this._sidebarMainViewElement=new WebInspector.SecurityMainViewSidebarTreeElement(this);sidebarTree.appendChild(this._sidebarMainViewElement);this._mainView=new WebInspector.SecurityMainView();this.showMainView();this._origins=new Map();WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged,this._clear,this);WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillReloadPage,this._clear,this);WebInspector.targetManager.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated,this._clear,this);WebInspector.targetManager.observeTargets(this);}
WebInspector.SecurityPanel.prototype={_updateSecurityState:function(newSecurityState,explanations)
{this._sidebarMainViewElement.setSecurityState(newSecurityState);this._mainView.updateSecurityState(newSecurityState,explanations);},_onSecurityStateChanged:function(event)
{var securityState=(event.data.securityState);var explanations=(event.data.explanations);this._updateSecurityState(securityState,explanations);},showMainView:function()
{this._setVisibleView(this._mainView);},_setVisibleView:function(view)
{if(this._visibleView===view)
return;if(this._visibleView)
this._visibleView.detach();this._visibleView=view;if(view)
this.splitWidget().setMainWidget(view);},_onResponseReceivedSecurityDetails:function(event)
{var data=event.data;var origin=(data.origin);var securityState=(data.securityState);if(this._origins.has(origin)){var originData=this._origins.get(origin);originData.securityState=this._securityStateMin(originData.securityState,securityState);}else{var originData={};originData.securityState=securityState;if(data.securityDetails)
originData.securityDetails=data.securityDetails;this._origins.set(origin,originData);}},_securityStateMin:function(stateA,stateB)
{var ordering=["unknown","insecure","neutral","warning","secure"];return(ordering.indexOf(stateA)<ordering.indexOf(stateB))?stateA:stateB;},targetAdded:function(target)
{if(!this._target){this._target=target;this._securityModel=WebInspector.SecurityModel.fromTarget(target);this._securityModel.addEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged,this._onSecurityStateChanged,this);this._updateSecurityState(this._securityModel.securityState(),[]);this._origins.clear();this._networkManager=target.networkManager;this._networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResponseReceivedSecurityDetails,this._onResponseReceivedSecurityDetails,this);}},targetRemoved:function(target)
{if(target===this._target){this._securityModel.removeEventListener(WebInspector.SecurityModel.EventTypes.SecurityStateChanged,this._onSecurityStateChanged,this);delete this._securityModel;this._networkManager.removeEventListener(WebInspector.NetworkManager.EventTypes.ResponseReceivedSecurityDetails,this._onResponseReceivedSecurityDetails,this);delete this._networkManager;delete this._target;this._clear();}},_clear:function()
{this._updateSecurityState(SecurityAgent.SecurityState.Unknown,[]);this._origins.clear();},__proto__:WebInspector.PanelWithSidebar.prototype}
WebInspector.SecurityPanel._instance=function()
{if(!WebInspector.SecurityPanel._instanceObject)
WebInspector.SecurityPanel._instanceObject=new WebInspector.SecurityPanel();return WebInspector.SecurityPanel._instanceObject;}
WebInspector.SecurityMainViewSidebarTreeElement=function(panel)
{this._panel=panel;this.small=true;WebInspector.SidebarTreeElement.call(this,"security-sidebar-tree-item",WebInspector.UIString("Overview"));this.iconElement.classList.add("lock-icon");}
WebInspector.SecurityMainViewSidebarTreeElement.prototype={onattach:function()
{WebInspector.SidebarTreeElement.prototype.onattach.call(this);},setSecurityState:function(newSecurityState)
{for(var className of this.iconElement.classList)
if(className.indexOf("lock-icon-")===0)
this.iconElement.classList.remove(className);this.iconElement.classList.add("lock-icon-"+newSecurityState);},onselect:function()
{this._panel.showMainView();return true;},__proto__:WebInspector.SidebarTreeElement.prototype}
WebInspector.SecurityPanelFactory=function()
{}
WebInspector.SecurityPanelFactory.prototype={createPanel:function()
{return WebInspector.SecurityPanel._instance();}}
WebInspector.SecurityMainView=function()
{WebInspector.VBox.call(this);this.setMinimumSize(100,100);this.element.classList.add("security-main-view");var securityStateSection=this.element.createChild("div");this._lockIcon=securityStateSection.createChild("div","lock-icon");this._securityStateText=securityStateSection.createChild("div","security-state");securityStateSection.createChild("hr");this._securityExplanations=securityStateSection.createChild("div","security-explanations");}
WebInspector.SecurityMainView.prototype={_addExplanation:function(explanation)
{var explanationDiv=this._securityExplanations.createChild("div","security-explanation");var explanationLockIcon=explanationDiv.createChild("div","lock-icon");explanationLockIcon.classList.add("lock-icon-"+explanation.securityState);explanationDiv.createChild("div","explanation-title").textContent=explanation.summary;explanationDiv.createChild("div","explanation-text").textContent=explanation.description;},updateSecurityState:function(newSecurityState,explanations)
{this._lockIcon.classList.remove("lock-icon-"+this._securityState);this._securityState=newSecurityState;this._lockIcon.classList.add("lock-icon-"+this._securityState);this._securityStateText.textContent=WebInspector.UIString("Page security state: %s",this._securityState);this._securityExplanations.removeChildren();for(var explanation of explanations)
this._addExplanation(explanation);},__proto__:WebInspector.VBox.prototype};Runtime.cachedResources["security/lockIcon.css"]="/* Copyright (c) 2015 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.lock-icon {\n    background-size: cover;\n    height: 16px;\n    width: 16px;\n}\n\n.lock-icon-unknown {\n    background-image: url(Images/securityStateNeutral.png);\n}\n\n.lock-icon-neutral {\n    background-image: url(Images/securityStateNeutral.png);\n}\n\n.lock-icon-insecure {\n    background-image: url(Images/securityStateInsecure.png);\n}\n\n.lock-icon-warning {\n    background-image: url(Images/securityStateWarning.png);\n}\n\n.lock-icon-secure {\n    background-image: url(Images/securityStateSecure.png);\n}\n\n\n@media (-webkit-min-device-pixel-ratio: 1.5) {\n    .lock-icon-unknown {\n        background-image: url(Images/securityStateNeutral_2x.png);\n    }\n\n    .lock-icon-neutral {\n        background-image: url(Images/securityStateNeutral_2x.png);\n    }\n\n    .lock-icon-insecure {\n        background-image: url(Images/securityStateInsecure_2x.png);\n    }\n\n    .lock-icon-warning {\n        background-image: url(Images/securityStateWarning_2x.png);\n    }\n\n    .lock-icon-secure {\n        background-image: url(Images/securityStateSecure_2x.png);\n    }\n}\n\n.sidebar-tree-item .lock-icon {\n    float: left;\n    margin-right: 2px;\n}\n/*# sourceURL=security/lockIcon.css */";Runtime.cachedResources["security/securityPanel.css"]="/* Copyright (c) 2015 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.security-main-view {\n    -webkit-user-select: text;\n    margin: 1em;\n}\n\n.security-main-view .lock-icon {\n    display: inline-block;\n    margin: 0.2em;\n    vertical-align: middle;\n}\n\n.security-main-view .security-state {\n    display: inline-block;\n    font-size: 1.2em;\n    font-weight: bold;\n    margin: 0.2em;\n    vertical-align: middle;\n}\n\n.security-explanation {\n    margin: 16px 0px;\n}\n\n.security-explanation .lock-icon {\n    display: inline-block;\n    vertical-align: bottom;\n}\n\n.security-explanation .explanation-title {\n    display: inline-block;\n    font-size: 1.2em;\n    font-weight: bold;\n    margin-left: 4px;\n}\n\n.security-explanation .explanation-text {\n    margin: 4px 0px;\n}\n/*# sourceURL=security/securityPanel.css */";