Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Security.SecurityPanel = class extends UI.PanelWithSidebar { | 8 Security.SecurityPanel = class extends UI.PanelWithSidebar { |
| 9 constructor() { | 9 constructor() { |
| 10 super('security'); | 10 super('security'); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 */ | 88 */ |
| 89 setDisplayedInsecureContentStyle(securityState) { | 89 setDisplayedInsecureContentStyle(securityState) { |
| 90 this._displayedInsecureContentStyle = securityState; | 90 this._displayedInsecureContentStyle = securityState; |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * @param {!Protocol.Security.SecurityState} newSecurityState | 94 * @param {!Protocol.Security.SecurityState} newSecurityState |
| 95 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations | 95 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations |
| 96 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus | 96 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus |
| 97 * @param {boolean} schemeIsCryptographic | 97 * @param {boolean} schemeIsCryptographic |
| 98 * @param {boolean} interstitialIsShowing | |
| 98 */ | 99 */ |
| 99 _updateSecurityState(newSecurityState, explanations, insecureContentStatus, sc hemeIsCryptographic) { | 100 _updateSecurityState(newSecurityState, explanations, insecureContentStatus, sc hemeIsCryptographic, interstitialIsShowing) { |
| 100 this._sidebarMainViewElement.setSecurityState(newSecurityState); | 101 this._sidebarMainViewElement.setSecurityState(newSecurityState); |
| 101 this._mainView.updateSecurityState(newSecurityState, explanations, insecureC ontentStatus, schemeIsCryptographic); | 102 this._mainView.updateSecurityState(newSecurityState, explanations, insecureC ontentStatus, schemeIsCryptographic, interstitialIsShowing); |
| 102 } | 103 } |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * @param {!Common.Event} event | 106 * @param {!Common.Event} event |
| 106 */ | 107 */ |
| 107 _onSecurityStateChanged(event) { | 108 _onSecurityStateChanged(event) { |
| 108 var data = /** @type {!Security.PageSecurityState} */ (event.data); | 109 var data = /** @type {!Security.PageSecurityState} */ (event.data); |
| 109 var securityState = /** @type {!Protocol.Security.SecurityState} */ (data.se curityState); | 110 var securityState = /** @type {!Protocol.Security.SecurityState} */ (data.se curityState); |
| 110 var explanations = /** @type {!Array<!Protocol.Security.SecurityStateExplana tion>} */ (data.explanations); | 111 var explanations = /** @type {!Array<!Protocol.Security.SecurityStateExplana tion>} */ (data.explanations); |
| 111 var insecureContentStatus = /** @type {?Protocol.Security.InsecureContentSta tus} */ (data.insecureContentStatus); | 112 var insecureContentStatus = /** @type {?Protocol.Security.InsecureContentSta tus} */ (data.insecureContentStatus); |
| 112 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptograph ic); | 113 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptograph ic); |
| 113 this._updateSecurityState(securityState, explanations, insecureContentStatus , schemeIsCryptographic); | 114 var interstitialIsShowing = /** @type {boolean} */ (data.interstitialIsShowi ng); |
| 115 this._updateSecurityState(securityState, explanations, insecureContentStatus , schemeIsCryptographic, interstitialIsShowing); | |
| 114 } | 116 } |
| 115 | 117 |
| 116 selectAndSwitchToMainView() { | 118 selectAndSwitchToMainView() { |
| 117 // The sidebar element will trigger displaying the main view. Rather than ma king a redundant call to display the main view, we rely on this. | 119 // The sidebar element will trigger displaying the main view. Rather than ma king a redundant call to display the main view, we rely on this. |
| 118 this._sidebarMainViewElement.select(); | 120 this._sidebarMainViewElement.select(); |
| 119 } | 121 } |
| 122 | |
| 123 /** | |
| 124 * @param {boolean} hidden | |
| 125 */ | |
| 126 toggleOriginsList(hidden) { | |
| 127 this._sidebarTree.toggleOriginsList(hidden); | |
| 128 } | |
| 129 | |
| 120 /** | 130 /** |
| 121 * @param {!Security.SecurityPanel.Origin} origin | 131 * @param {!Security.SecurityPanel.Origin} origin |
| 122 */ | 132 */ |
| 123 showOrigin(origin) { | 133 showOrigin(origin) { |
| 124 var originState = this._origins.get(origin); | 134 var originState = this._origins.get(origin); |
| 125 if (!originState.originView) | 135 if (!originState.originView) |
| 126 originState.originView = new Security.SecurityOriginView(this, origin, ori ginState); | 136 originState.originView = new Security.SecurityOriginView(this, origin, ori ginState); |
| 127 | 137 |
| 128 this._setVisibleView(originState.originView); | 138 this._setVisibleView(originState.originView); |
| 129 } | 139 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 if (this._target) | 290 if (this._target) |
| 281 return; | 291 return; |
| 282 | 292 |
| 283 var listeners = []; | 293 var listeners = []; |
| 284 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); | 294 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); |
| 285 if (resourceTreeModel) { | 295 if (resourceTreeModel) { |
| 286 listeners = listeners.concat([ | 296 listeners = listeners.concat([ |
| 287 resourceTreeModel.addEventListener( | 297 resourceTreeModel.addEventListener( |
| 288 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFrameNa vigated, this), | 298 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFrameNa vigated, this), |
| 289 resourceTreeModel.addEventListener( | 299 resourceTreeModel.addEventListener( |
| 290 SDK.ResourceTreeModel.Events.InterstitialShown, this._onInterstitial Shown, this), | 300 SDK.ResourceTreeModel.Events.InterstitialShown, this.onInterstitialS hown, this), |
| 291 resourceTreeModel.addEventListener( | 301 resourceTreeModel.addEventListener( |
| 292 SDK.ResourceTreeModel.Events.InterstitialHidden, this._onInterstitia lHidden, this), | 302 SDK.ResourceTreeModel.Events.InterstitialHidden, this.onInterstitial Hidden, this), |
| 293 ]); | 303 ]); |
| 294 } | 304 } |
| 295 | 305 |
| 296 var networkManager = SDK.NetworkManager.fromTarget(target); | 306 var networkManager = SDK.NetworkManager.fromTarget(target); |
| 297 if (networkManager) { | 307 if (networkManager) { |
| 298 listeners = listeners.concat([ | 308 listeners = listeners.concat([ |
| 299 networkManager.addEventListener(SDK.NetworkManager.Events.ResponseReceiv ed, this._onResponseReceived, this), | 309 networkManager.addEventListener(SDK.NetworkManager.Events.ResponseReceiv ed, this._onResponseReceived, this), |
| 300 networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinishe d, this._onRequestFinished, this), | 310 networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinishe d, this._onRequestFinished, this), |
| 301 ]); | 311 ]); |
| 302 } | 312 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 // explanations to reflect the new counts. | 351 // explanations to reflect the new counts. |
| 342 this._mainView.refreshExplanations(); | 352 this._mainView.refreshExplanations(); |
| 343 | 353 |
| 344 if (request) { | 354 if (request) { |
| 345 var origin = Common.ParsedURL.extractOrigin(request.url); | 355 var origin = Common.ParsedURL.extractOrigin(request.url); |
| 346 this._sidebarTree.setMainOrigin(origin); | 356 this._sidebarTree.setMainOrigin(origin); |
| 347 this._processRequest(request); | 357 this._processRequest(request); |
| 348 } | 358 } |
| 349 } | 359 } |
| 350 | 360 |
| 351 _onInterstitialShown() { | 361 onInterstitialShown() { |
| 352 // The panel might have been displaying the origin view on the | 362 // The panel might have been displaying the origin view on the |
| 353 // previously loaded page. When showing an interstitial, switch | 363 // previously loaded page. When showing an interstitial, switch |
| 354 // back to the Overview view. | 364 // back to the Overview view. |
| 355 this.selectAndSwitchToMainView(); | 365 this.selectAndSwitchToMainView(); |
| 356 this._sidebarTree.toggleOriginsList(true /* hidden */); | 366 this._sidebarTree.toggleOriginsList(true /* hidden */); |
| 357 } | 367 } |
| 358 | 368 |
| 359 _onInterstitialHidden() { | 369 onInterstitialHidden() { |
| 360 this._sidebarTree.toggleOriginsList(false /* hidden */); | 370 this._sidebarTree.toggleOriginsList(false /* hidden */); |
| 361 } | 371 } |
| 362 }; | 372 }; |
| 363 | 373 |
| 364 /** @typedef {string} */ | 374 /** @typedef {string} */ |
| 365 Security.SecurityPanel.Origin; | 375 Security.SecurityPanel.Origin; |
| 366 | 376 |
| 367 /** | 377 /** |
| 368 * @typedef {Object} | 378 * @typedef {Object} |
| 369 * @property {!Protocol.Security.SecurityState} securityState - Current security state of the origin. | 379 * @property {!Protocol.Security.SecurityState} securityState - Current security state of the origin. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 383 * @param {function(!Security.SecurityPanel.Origin)} showOriginInPanel | 393 * @param {function(!Security.SecurityPanel.Origin)} showOriginInPanel |
| 384 */ | 394 */ |
| 385 constructor(mainViewElement, showOriginInPanel) { | 395 constructor(mainViewElement, showOriginInPanel) { |
| 386 super(); | 396 super(); |
| 387 this.registerRequiredCSS('security/sidebar.css'); | 397 this.registerRequiredCSS('security/sidebar.css'); |
| 388 this.registerRequiredCSS('security/lockIcon.css'); | 398 this.registerRequiredCSS('security/lockIcon.css'); |
| 389 this.appendChild(mainViewElement); | 399 this.appendChild(mainViewElement); |
| 390 | 400 |
| 391 this._showOriginInPanel = showOriginInPanel; | 401 this._showOriginInPanel = showOriginInPanel; |
| 392 this._mainOrigin = null; | 402 this._mainOrigin = null; |
| 403 this._originsAreHidden = false; | |
| 393 | 404 |
| 394 /** @type {!Map<!Security.SecurityPanelSidebarTree.OriginGroupName, !TreeEle ment>} */ | 405 /** @type {!Map<!Security.SecurityPanelSidebarTree.OriginGroupName, !TreeEle ment>} */ |
| 395 this._originGroups = new Map(); | 406 this._originGroups = new Map(); |
| 396 | 407 |
| 397 for (var key in Security.SecurityPanelSidebarTree.OriginGroupName) { | 408 for (var key in Security.SecurityPanelSidebarTree.OriginGroupName) { |
| 398 var originGroupName = Security.SecurityPanelSidebarTree.OriginGroupName[ke y]; | 409 var originGroupName = Security.SecurityPanelSidebarTree.OriginGroupName[ke y]; |
| 399 var originGroup = new TreeElement(originGroupName, true); | 410 var originGroup = new TreeElement(originGroupName, true); |
| 400 originGroup.selectable = false; | 411 originGroup.selectable = false; |
| 401 originGroup.expand(); | 412 originGroup.expand(); |
| 402 originGroup.listItemElement.classList.add('security-sidebar-origins'); | 413 originGroup.listItemElement.classList.add('security-sidebar-origins'); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 413 .appendChild(mainViewReloadMessage); | 424 .appendChild(mainViewReloadMessage); |
| 414 | 425 |
| 415 /** @type {!Map<!Security.SecurityPanel.Origin, !Security.SecurityPanelSideb arTreeElement>} */ | 426 /** @type {!Map<!Security.SecurityPanel.Origin, !Security.SecurityPanelSideb arTreeElement>} */ |
| 416 this._elementsByOrigin = new Map(); | 427 this._elementsByOrigin = new Map(); |
| 417 } | 428 } |
| 418 | 429 |
| 419 /** | 430 /** |
| 420 * @param {boolean} hidden | 431 * @param {boolean} hidden |
| 421 */ | 432 */ |
| 422 toggleOriginsList(hidden) { | 433 toggleOriginsList(hidden) { |
| 434 this._originsAreHidden = hidden; | |
| 423 for (var key in Security.SecurityPanelSidebarTree.OriginGroupName) { | 435 for (var key in Security.SecurityPanelSidebarTree.OriginGroupName) { |
| 424 var originGroupName = Security.SecurityPanelSidebarTree.OriginGroupName[ke y]; | 436 var originGroupName = Security.SecurityPanelSidebarTree.OriginGroupName[ke y]; |
| 425 var group = this._originGroups.get(originGroupName); | 437 var group = this._originGroups.get(originGroupName); |
| 426 if (group) | 438 if (group) |
| 427 group.hidden = hidden; | 439 group.hidden = hidden; |
| 428 } | 440 } |
| 429 } | 441 } |
| 430 | 442 |
| 431 /** | 443 /** |
| 432 * @param {!Security.SecurityPanel.Origin} origin | 444 * @param {!Security.SecurityPanel.Origin} origin |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 } | 486 } |
| 475 | 487 |
| 476 var oldParent = originElement.parent; | 488 var oldParent = originElement.parent; |
| 477 if (oldParent !== newParent) { | 489 if (oldParent !== newParent) { |
| 478 if (oldParent) { | 490 if (oldParent) { |
| 479 oldParent.removeChild(originElement); | 491 oldParent.removeChild(originElement); |
| 480 if (oldParent.childCount() === 0) | 492 if (oldParent.childCount() === 0) |
| 481 oldParent.hidden = true; | 493 oldParent.hidden = true; |
| 482 } | 494 } |
| 483 newParent.appendChild(originElement); | 495 newParent.appendChild(originElement); |
| 484 newParent.hidden = false; | 496 newParent.hidden = this._originsAreHidden; |
|
estark
2016/11/21 22:42:06
This is the drive-by bug fix I mentioned in the CL
| |
| 485 } | 497 } |
| 486 } | 498 } |
| 487 | 499 |
| 488 _clearOriginGroups() { | 500 _clearOriginGroups() { |
| 489 for (var originGroup of this._originGroups.values()) { | 501 for (var originGroup of this._originGroups.values()) { |
| 490 originGroup.removeChildren(); | 502 originGroup.removeChildren(); |
| 491 originGroup.hidden = true; | 503 originGroup.hidden = true; |
| 492 } | 504 } |
| 493 this._originGroups.get(Security.SecurityPanelSidebarTree.OriginGroupName.Mai nOrigin).hidden = false; | 505 this._originGroups.get(Security.SecurityPanelSidebarTree.OriginGroupName.Mai nOrigin).hidden = false; |
| 494 } | 506 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 } | 643 } |
| 632 | 644 |
| 633 return text; | 645 return text; |
| 634 } | 646 } |
| 635 | 647 |
| 636 /** | 648 /** |
| 637 * @param {!Protocol.Security.SecurityState} newSecurityState | 649 * @param {!Protocol.Security.SecurityState} newSecurityState |
| 638 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations | 650 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations |
| 639 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus | 651 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus |
| 640 * @param {boolean} schemeIsCryptographic | 652 * @param {boolean} schemeIsCryptographic |
| 653 * @param {boolean} interstitialIsShowing | |
| 641 */ | 654 */ |
| 642 updateSecurityState(newSecurityState, explanations, insecureContentStatus, sch emeIsCryptographic) { | 655 updateSecurityState(newSecurityState, explanations, insecureContentStatus, sch emeIsCryptographic, interstitialIsShowing) { |
| 643 // Remove old state. | 656 // Remove old state. |
| 644 // It's safe to call this even when this._securityState is undefined. | 657 // It's safe to call this even when this._securityState is undefined. |
| 645 this._summarySection.classList.remove('security-summary-' + this._securitySt ate); | 658 this._summarySection.classList.remove('security-summary-' + this._securitySt ate); |
| 646 | 659 |
| 647 // Add new state. | 660 // Add new state. |
| 648 this._securityState = newSecurityState; | 661 this._securityState = newSecurityState; |
| 649 this._summarySection.classList.add('security-summary-' + this._securityState ); | 662 this._summarySection.classList.add('security-summary-' + this._securityState ); |
| 650 var summaryExplanationStrings = { | 663 var summaryExplanationStrings = { |
| 651 'unknown': Common.UIString('The security of this page is unknown.'), | 664 'unknown': Common.UIString('The security of this page is unknown.'), |
| 652 'insecure': Common.UIString('This page is not secure (broken HTTPS).'), | 665 'insecure': Common.UIString('This page is not secure (broken HTTPS).'), |
| 653 'neutral': Common.UIString('This page is not secure.'), | 666 'neutral': Common.UIString('This page is not secure.'), |
| 654 'secure': Common.UIString('This page is secure (valid HTTPS).') | 667 'secure': Common.UIString('This page is secure (valid HTTPS).') |
| 655 }; | 668 }; |
| 656 this._summaryText.textContent = summaryExplanationStrings[this._securityStat e]; | 669 this._summaryText.textContent = summaryExplanationStrings[this._securityStat e]; |
| 657 | 670 |
| 658 this._explanations = explanations, this._insecureContentStatus = insecureCon tentStatus; | 671 this._explanations = explanations, this._insecureContentStatus = insecureCon tentStatus; |
| 659 this._schemeIsCryptographic = schemeIsCryptographic; | 672 this._schemeIsCryptographic = schemeIsCryptographic; |
| 660 | 673 |
| 661 this._panel.setRanInsecureContentStyle(insecureContentStatus.ranInsecureCont entStyle); | 674 this._panel.setRanInsecureContentStyle(insecureContentStatus.ranInsecureCont entStyle); |
| 662 this._panel.setDisplayedInsecureContentStyle(insecureContentStatus.displayed InsecureContentStyle); | 675 this._panel.setDisplayedInsecureContentStyle(insecureContentStatus.displayed InsecureContentStyle); |
| 663 | 676 |
| 664 this.refreshExplanations(); | 677 this.refreshExplanations(); |
| 678 | |
| 679 // If an interstitial is showing, show the Overview view and hide the origin s list. | |
| 680 if (interstitialIsShowing) | |
| 681 this._panel.onInterstitialShown(); | |
| 682 else | |
| 683 this._panel.onInterstitialHidden(); | |
| 665 } | 684 } |
| 666 | 685 |
| 667 refreshExplanations() { | 686 refreshExplanations() { |
| 668 this._securityExplanationsMain.removeChildren(); | 687 this._securityExplanationsMain.removeChildren(); |
| 669 this._securityExplanationsExtra.removeChildren(); | 688 this._securityExplanationsExtra.removeChildren(); |
| 670 for (var explanation of this._explanations) { | 689 for (var explanation of this._explanations) { |
| 671 if (explanation.securityState === Protocol.Security.SecurityState.Info) | 690 if (explanation.securityState === Protocol.Security.SecurityState.Info) |
| 672 this._addExplanation(this._securityExplanationsExtra, explanation); | 691 this._addExplanation(this._securityExplanationsExtra, explanation); |
| 673 else | 692 else |
| 674 this._addExplanation(this._securityExplanationsMain, explanation); | 693 this._addExplanation(this._securityExplanationsMain, explanation); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 var row = this._element.createChild('div', 'details-table-row'); | 1052 var row = this._element.createChild('div', 'details-table-row'); |
| 1034 row.createChild('div').textContent = key; | 1053 row.createChild('div').textContent = key; |
| 1035 | 1054 |
| 1036 var valueDiv = row.createChild('div'); | 1055 var valueDiv = row.createChild('div'); |
| 1037 if (typeof value === 'string') | 1056 if (typeof value === 'string') |
| 1038 valueDiv.textContent = value; | 1057 valueDiv.textContent = value; |
| 1039 else | 1058 else |
| 1040 valueDiv.appendChild(value); | 1059 valueDiv.appendChild(value); |
| 1041 } | 1060 } |
| 1042 }; | 1061 }; |
| OLD | NEW |