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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.PanelWithSidebar} | 7 * @extends {WebInspector.PanelWithSidebar} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.SecurityPanel = function() | 10 WebInspector.SecurityPanel = function() |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 } | 171 } |
| 172 } else { | 172 } else { |
| 173 // TODO(lgarron): Store a (deduplicated) list of different security details we have seen. https://crbug.com/503170 | 173 // TODO(lgarron): Store a (deduplicated) list of different security details we have seen. https://crbug.com/503170 |
| 174 var originState = {}; | 174 var originState = {}; |
| 175 originState.securityState = securityState; | 175 originState.securityState = securityState; |
| 176 | 176 |
| 177 var securityDetails = request.securityDetails(); | 177 var securityDetails = request.securityDetails(); |
| 178 if (securityDetails) { | 178 if (securityDetails) { |
| 179 originState.securityDetails = securityDetails; | 179 originState.securityDetails = securityDetails; |
| 180 originState.certificateDetailsPromise = request.target().network Manager.certificateDetailsPromise(securityDetails.certificateId); | 180 originState.certificateDetailsPromise = request.target().network Manager.certificateDetailsPromise(securityDetails.certificateId); |
| 181 | |
| 182 if (securityDetails.certificateValidationDetails) | |
| 183 originState.certificateTransparencySummaryPromise = request. target().networkManager.certificateTransparencySummaryPromise(securityDetails.ce rtificateValidationDetails); | |
|
pfeldman
2016/01/19 17:54:49
You issue the request here, but don't claim the re
lgarron
2016/01/22 22:51:27
I want to issue the request to the proper target f
| |
| 181 } | 184 } |
| 182 | 185 |
| 183 this._origins.set(origin, originState); | 186 this._origins.set(origin, originState); |
| 184 | 187 |
| 185 this._sidebarTree.addOrigin(origin, securityState); | 188 this._sidebarTree.addOrigin(origin, securityState); |
| 186 | 189 |
| 187 // Don't construct the origin view yet (let it happen lazily). | 190 // Don't construct the origin view yet (let it happen lazily). |
| 188 } | 191 } |
| 189 }, | 192 }, |
| 190 | 193 |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 /** | 787 /** |
| 785 * @this {WebInspector.SecurityOriginView} | 788 * @this {WebInspector.SecurityOriginView} |
| 786 * @param {?NetworkAgent.CertificateDetails} certificateDetails | 789 * @param {?NetworkAgent.CertificateDetails} certificateDetails |
| 787 */ | 790 */ |
| 788 function displayCertificateDetails(certificateDetails) | 791 function displayCertificateDetails(certificateDetails) |
| 789 { | 792 { |
| 790 var sanDiv = this._createSanDiv(certificateDetails.subject); | 793 var sanDiv = this._createSanDiv(certificateDetails.subject); |
| 791 var validFromString = new Date(1000 * certificateDetails.validFrom). toUTCString(); | 794 var validFromString = new Date(1000 * certificateDetails.validFrom). toUTCString(); |
| 792 var validUntilString = new Date(1000 * certificateDetails.validTo).t oUTCString(); | 795 var validUntilString = new Date(1000 * certificateDetails.validTo).t oUTCString(); |
| 793 | 796 |
| 797 var sctValue = WebInspector.UIString("-"); | |
| 798 if (originState.securityDetails.certificateValidationDetails) { | |
| 799 | |
| 800 var sctTypeList = []; | |
| 801 var validationDetails = originState.securityDetails.certificateV alidationDetails; | |
|
pfeldman
2016/01/19 17:54:49
Extract it above the check.
lgarron
2016/01/22 22:51:28
Done.
| |
| 802 if (validationDetails.numValidScts > 0) | |
|
pfeldman
2016/01/19 17:54:49
if (validationDetails.numValidScts)
...
lgarron
2016/01/22 22:51:27
*grumble* Okay, done.
| |
| 803 sctTypeList.push(WebInspector.UIString("%d valid SCT%s", val idationDetails.numValidScts, (validationDetails.numValidScts > 1) ? "s" : "")); | |
| 804 if (validationDetails.numInvalidScts > 0) | |
| 805 sctTypeList.push(WebInspector.UIString("%d invalid SCT%s", v alidationDetails.numInvalidScts, (validationDetails.numInvalidScts > 1) ? "s" : "")); | |
| 806 if (validationDetails.numUnknownScts > 0) | |
| 807 sctTypeList.push(WebInspector.UIString("%d SCT%s from unknow n logs", validationDetails.numUnknownScts, (validationDetails.numUnknownScts > 1 ) ? "s" : "")); | |
| 808 | |
| 809 var sctTypeCounts = (sctTypeList.length == 0) ? WebInspector.UIS tring("0 SCTs") : sctTypeList.join(", "); | |
|
pfeldman
2016/01/19 17:54:49
sctTypeList.length ? ...
lgarron
2016/01/22 22:51:28
I am checking if the list (of strings) I'm concate
| |
| 810 | |
| 811 if (originState.certificateTransparencySummaryPromise) { | |
|
pfeldman
2016/01/19 17:54:49
Issue the request here instead.
lgarron
2016/01/22 22:51:28
See above.
| |
| 812 | |
| 813 /** | |
| 814 * @param {function(string)} resolve | |
| 815 * @param {function()} reject - Unused | |
| 816 */ | |
| 817 function executor(resolve, reject) | |
| 818 { | |
| 819 /** | |
| 820 * @param {function(string)} summary | |
| 821 */ | |
| 822 function innerResolve(summary) | |
| 823 { | |
| 824 resolve(WebInspector.UIString("%s (%s)", summary, sc tTypeCounts)); | |
| 825 } | |
| 826 function innerReject() | |
| 827 { | |
| 828 resolve(sctTypeCounts); | |
| 829 } | |
| 830 originState.certificateTransparencySummaryPromise.then(i nnerResolve, innerReject); | |
| 831 } | |
| 832 sctValue = new Promise(executor); | |
|
pfeldman
2016/01/19 17:54:49
Why do you use promise here?
lgarron
2016/01/22 22:51:28
Removed in a refactor.
| |
| 833 } else { | |
| 834 // Fall back and just display the counts. | |
| 835 sctValue = sctTypeCounts; | |
| 836 } | |
| 837 } | |
| 838 | |
| 794 var table = new WebInspector.SecurityDetailsTable(); | 839 var table = new WebInspector.SecurityDetailsTable(); |
| 795 certificateSection.appendChild(table.element()); | 840 certificateSection.appendChild(table.element()); |
| 796 table.addRow("Subject", certificateDetails.subject.name); | 841 table.addRow("Subject", certificateDetails.subject.name); |
| 797 table.addRow("SAN", sanDiv); | 842 table.addRow("SAN", sanDiv); |
| 798 table.addRow("Valid From", validFromString); | 843 table.addRow("Valid From", validFromString); |
| 799 table.addRow("Valid Until", validUntilString); | 844 table.addRow("Valid Until", validUntilString); |
| 800 table.addRow("Issuer", certificateDetails.issuer); | 845 table.addRow("Issuer", certificateDetails.issuer); |
| 846 table.addRow("SCTs", sctValue); | |
|
pfeldman
2016/01/19 17:54:49
You should only pass values into the UI components
lgarron
2016/01/22 22:51:28
I wanted to satisfy two design constraints:
- Be
| |
| 801 table.addRow("", WebInspector.SecurityPanel.createCertificateViewerB utton(WebInspector.UIString("Open full certificate details"), originState.securi tyDetails.certificateId)); | 847 table.addRow("", WebInspector.SecurityPanel.createCertificateViewerB utton(WebInspector.UIString("Open full certificate details"), originState.securi tyDetails.certificateId)); |
| 802 // TODO(lgarron): Make SCT status available in certificate details a nd show it here. | |
| 803 } | 848 } |
| 804 | 849 |
| 805 function displayCertificateDetailsUnavailable () | 850 function displayCertificateDetailsUnavailable () |
| 806 { | 851 { |
| 807 certificateSection.createChild("div").textContent = WebInspector.UIS tring("Certificate details unavailable."); | 852 certificateSection.createChild("div").textContent = WebInspector.UIS tring("Certificate details unavailable."); |
| 808 } | 853 } |
| 809 | 854 |
| 810 originState.certificateDetailsPromise.then(displayCertificateDetails.bin d(this), displayCertificateDetailsUnavailable); | 855 originState.certificateDetailsPromise.then(displayCertificateDetails.bin d(this), displayCertificateDetailsUnavailable); |
| 811 | 856 |
| 812 var noteSection = this.element.createChild("div", "origin-view-section") ; | 857 var noteSection = this.element.createChild("div", "origin-view-section") ; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 /** | 941 /** |
| 897 * @return: {!Element} | 942 * @return: {!Element} |
| 898 */ | 943 */ |
| 899 element: function() | 944 element: function() |
| 900 { | 945 { |
| 901 return this._element; | 946 return this._element; |
| 902 }, | 947 }, |
| 903 | 948 |
| 904 /** | 949 /** |
| 905 * @param {string} key | 950 * @param {string} key |
| 906 * @param {string|!Node} value | 951 * @param {string|!Node|!Promise<string>} value |
|
pfeldman
2016/01/19 17:54:49
Resolve value prior to getting here, we try to not
lgarron
2016/01/22 22:51:28
Rather than allowing a promise to introduce asynch
| |
| 907 */ | 952 */ |
| 908 addRow: function(key, value) | 953 addRow: function(key, value) |
| 909 { | 954 { |
| 910 var row = this._element.createChild("div", "details-table-row"); | 955 var row = this._element.createChild("div", "details-table-row"); |
| 911 row.createChild("div").textContent = key; | 956 row.createChild("div").textContent = key; |
| 912 | 957 |
| 913 var valueDiv = row.createChild("div"); | 958 var valueDiv = row.createChild("div"); |
| 914 if (typeof value === "string") { | 959 |
| 915 valueDiv.textContent = value; | 960 /** |
| 916 } else { | 961 * @param {string|!Node} value |
| 917 valueDiv.appendChild(value); | 962 */ |
| 963 function resolve(value) { | |
|
pfeldman
2016/01/19 17:54:49
By now you are formatting {} poorly.
lgarron
2016/01/22 22:51:28
Thanks for catching; some habits die hard without
| |
| 964 if (typeof value === "string") { | |
| 965 valueDiv.textContent = value; | |
| 966 } else { | |
| 967 valueDiv.appendChild(value); | |
| 968 } | |
| 918 } | 969 } |
| 970 | |
| 971 function reject() { | |
| 972 valueDiv.textContent = WebInspector.UIString("-"); | |
| 973 } | |
| 974 | |
| 975 // We have to modify the signature of `resolve` to work around a type ch ecker limitation. | |
| 976 Promise.resolve(value).then(/** @type {function((string|!Node|!Promise<s tring>))} */(resolve), reject); | |
| 919 } | 977 } |
| 920 } | 978 } |
| OLD | NEW |