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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/security/SecurityPanel.js

Issue 2542533004: Override DevTools security summary when a Safe Browsing warning shows. (Closed)
Patch Set: Address review feedback Created 4 years 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 unified diff | Download patch
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 /** 86 /**
87 * @param {!Protocol.Security.SecurityState} securityState 87 * @param {!Protocol.Security.SecurityState} securityState
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 {?string} summary
96 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus 97 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus
97 * @param {boolean} schemeIsCryptographic 98 * @param {boolean} schemeIsCryptographic
98 */ 99 */
99 _updateSecurityState(newSecurityState, explanations, insecureContentStatus, sc hemeIsCryptographic) { 100 _updateSecurityState(newSecurityState, explanations, summary, insecureContentS tatus, schemeIsCryptographic) {
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, summary, insecureContentStatus, schemeIsCryptographic);
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);
112 var summary = /** @type {?string} */ (data.summary);
111 var insecureContentStatus = /** @type {?Protocol.Security.InsecureContentSta tus} */ (data.insecureContentStatus); 113 var insecureContentStatus = /** @type {?Protocol.Security.InsecureContentSta tus} */ (data.insecureContentStatus);
112 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptograph ic); 114 var schemeIsCryptographic = /** @type {boolean} */ (data.schemeIsCryptograph ic);
113 this._updateSecurityState(securityState, explanations, insecureContentStatus , schemeIsCryptographic); 115 this._updateSecurityState(securityState, explanations, summary, insecureCont entStatus, schemeIsCryptographic);
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 }
120 /** 122 /**
121 * @param {!Security.SecurityPanel.Origin} origin 123 * @param {!Security.SecurityPanel.Origin} origin
122 */ 124 */
123 showOrigin(origin) { 125 showOrigin(origin) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 text.appendChild( 634 text.appendChild(
633 Security.SecurityPanel.createCertificateViewerButton(Common.UIString(' View certificate'), this._panel)); 635 Security.SecurityPanel.createCertificateViewerButton(Common.UIString(' View certificate'), this._panel));
634 } 636 }
635 637
636 return text; 638 return text;
637 } 639 }
638 640
639 /** 641 /**
640 * @param {!Protocol.Security.SecurityState} newSecurityState 642 * @param {!Protocol.Security.SecurityState} newSecurityState
641 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations 643 * @param {!Array<!Protocol.Security.SecurityStateExplanation>} explanations
644 * @param {?string} summary
642 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus 645 * @param {?Protocol.Security.InsecureContentStatus} insecureContentStatus
643 * @param {boolean} schemeIsCryptographic 646 * @param {boolean} schemeIsCryptographic
644 */ 647 */
645 updateSecurityState(newSecurityState, explanations, insecureContentStatus, sch emeIsCryptographic) { 648 updateSecurityState(newSecurityState, explanations, summary, insecureContentSt atus, schemeIsCryptographic) {
646 // Remove old state. 649 // Remove old state.
647 // It's safe to call this even when this._securityState is undefined. 650 // It's safe to call this even when this._securityState is undefined.
648 this._summarySection.classList.remove('security-summary-' + this._securitySt ate); 651 this._summarySection.classList.remove('security-summary-' + this._securitySt ate);
649 652
650 // Add new state. 653 // Add new state.
651 this._securityState = newSecurityState; 654 this._securityState = newSecurityState;
652 this._summarySection.classList.add('security-summary-' + this._securityState ); 655 this._summarySection.classList.add('security-summary-' + this._securityState );
653 var summaryExplanationStrings = { 656 var summaryExplanationStrings = {
654 'unknown': Common.UIString('The security of this page is unknown.'), 657 'unknown': Common.UIString('The security of this page is unknown.'),
655 'insecure': Common.UIString('This page is not secure (broken HTTPS).'), 658 'insecure': Common.UIString('This page is not secure (broken HTTPS).'),
656 'neutral': Common.UIString('This page is not secure.'), 659 'neutral': Common.UIString('This page is not secure.'),
657 'secure': Common.UIString('This page is secure (valid HTTPS).') 660 'secure': Common.UIString('This page is secure (valid HTTPS).')
658 }; 661 };
659 this._summaryText.textContent = summaryExplanationStrings[this._securityStat e]; 662
663 // Use override summary if present, otherwise use base explanation
664 this._summaryText.textContent = summary || summaryExplanationStrings[this._s ecurityState];
660 665
661 this._explanations = explanations, this._insecureContentStatus = insecureCon tentStatus; 666 this._explanations = explanations, this._insecureContentStatus = insecureCon tentStatus;
662 this._schemeIsCryptographic = schemeIsCryptographic; 667 this._schemeIsCryptographic = schemeIsCryptographic;
663 668
664 this._panel.setRanInsecureContentStyle(insecureContentStatus.ranInsecureCont entStyle); 669 this._panel.setRanInsecureContentStyle(insecureContentStatus.ranInsecureCont entStyle);
665 this._panel.setDisplayedInsecureContentStyle(insecureContentStatus.displayed InsecureContentStyle); 670 this._panel.setDisplayedInsecureContentStyle(insecureContentStatus.displayed InsecureContentStyle);
666 671
667 this.refreshExplanations(); 672 this.refreshExplanations();
668 } 673 }
669 674
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 var row = this._element.createChild('div', 'details-table-row'); 1041 var row = this._element.createChild('div', 'details-table-row');
1037 row.createChild('div').textContent = key; 1042 row.createChild('div').textContent = key;
1038 1043
1039 var valueDiv = row.createChild('div'); 1044 var valueDiv = row.createChild('div');
1040 if (typeof value === 'string') 1045 if (typeof value === 'string')
1041 valueDiv.textContent = value; 1046 valueDiv.textContent = value;
1042 else 1047 else
1043 valueDiv.appendChild(value); 1048 valueDiv.appendChild(value);
1044 } 1049 }
1045 }; 1050 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698