Commit af8230d6 authored by Pavol Marko's avatar Pavol Marko Committed by Commit Bot

Display policy indicator on certificates UI

Mark policy-provided certificates using a policy indicator on the
certificates UI (chrome://settings/certificates).

UI Preview: https://screenshot.googleplex.com/fnM5QZLjBe5

Bug: 859950, 787602
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Iad7bf5e5862bb2a5965db65302e10fe8bb14735f
Reviewed-on: https://chromium-review.googlesource.com/1124853
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585428}
parent 31bc2af9
......@@ -57,6 +57,8 @@ static const char kCertificatesHandlerWebTrustAnchorField[] = "webTrustAnchor";
static const char kCertificatesHandlerReadonlyField[] = "readonly";
static const char kCertificatesHandlerSslField[] = "ssl";
static const char kCertificatesHandlerSubnodesField[] = "subnodes";
static const char kCertificatesHandlerContainsPolicyCertsField[] =
"containsPolicyCerts";
static const char kCertificatesHandlerUntrustedField[] = "untrusted";
// Field names for communicating erros to JS.
......@@ -1029,6 +1031,7 @@ void CertificatesHandler::PopulateTree(const std::string& tab_name,
// Populate second level (certs).
base::ListValue subnodes;
bool contains_policy_certs = false;
for (const auto& org_cert : org_grouping_map_entry.second) {
base::DictionaryValue cert_dict;
CERTCertificate* cert = org_cert->cert();
......@@ -1053,9 +1056,15 @@ void CertificatesHandler::PopulateTree(const std::string& tab_name,
base::Value(!org_cert->hardware_backed()));
// TODO(mattm): Other columns.
subnodes.GetList().push_back(std::move(cert_dict));
contains_policy_certs |=
org_cert->source() ==
CertificateManagerModel::CertInfo::Source::kPolicy;
}
std::sort(subnodes.GetList().begin(), subnodes.GetList().end(), comparator);
org_dict.SetKey(kCertificatesHandlerContainsPolicyCertsField,
base::Value(contains_policy_certs));
org_dict.SetKey(kCertificatesHandlerSubnodesField, std::move(subnodes));
nodes.GetList().push_back(std::move(org_dict));
}
......
......@@ -143,11 +143,12 @@ cr.define('certificate_manager', function() {
}
}
/** @return {!Certificate} */
function createSampleCertificate() {
/** @return {!CertificatesOrgGroup} */
function createSampleCertificateOrgGroup() {
return {
id: 'dummyCertificateId',
name: 'dummyCertificateName',
containsPolicyCerts: false,
subnodes: [createSampleCertificateSubnode()],
};
}
......@@ -682,10 +683,10 @@ cr.define('certificate_manager', function() {
// Simulate response for personal and CA certificates.
cr.webUIListenerCallback(
'certificates-changed', 'personalCerts',
[createSampleCertificate()]);
cr.webUIListenerCallback(
'certificates-changed', 'caCerts',
[createSampleCertificate(), createSampleCertificate()]);
[createSampleCertificateOrgGroup()]);
cr.webUIListenerCallback('certificates-changed', 'caCerts', [
createSampleCertificateOrgGroup(), createSampleCertificateOrgGroup()
]);
Polymer.dom.flush();
assertCertificateListLength(CertificateCategoryIndex.PERSONAL, 1);
......
......@@ -46,6 +46,7 @@ js_library("certificate_entry") {
deps = [
":certificate_manager_types",
":certificates_browser_proxy",
"//ui/webui/resources/cr_elements/policy:cr_policy_indicator",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:i18n_behavior",
]
......@@ -105,6 +106,7 @@ js_library("certificate_subentry") {
":certificates_browser_proxy",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
"//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
"//ui/webui/resources/cr_elements/policy:cr_policy_indicator",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:i18n_behavior",
]
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="certificate_shared_css.html">
......@@ -20,6 +21,8 @@
</style>
<div class="expand-box">
<div class="flex">[[model.id]]</div>
<cr-policy-indicator indicator-type="[[getPolicyIndicatorType_(model)]]">
</cr-policy-indicator>
<cr-expand-button expanded="{{expanded_}}"
alt="[[i18n('certificateManagerExpandA11yLabel')]]">
</cr-expand-button>
......
......@@ -11,7 +11,7 @@ Polymer({
behaviors: [I18nBehavior],
properties: {
/** @type {!Certificate} */
/** @type {!CertificatesOrgGroup} */
model: Object,
/** @type {!CertificateType} */
......@@ -26,4 +26,9 @@ Polymer({
isLast_: function(index) {
return index == this.model.subnodes.length - 1;
},
getPolicyIndicatorType_() {
return this.model.containsPolicyCerts ? CrPolicyIndicatorType.USER_POLICY :
CrPolicyIndicatorType.NONE;
},
});
......@@ -10,7 +10,7 @@ Polymer({
is: 'certificate-list',
properties: {
/** @type {!Array<!Certificate>} */
/** @type {!Array<!CertificatesOrgGroup>} */
certificates: {
type: Array,
value: function() {
......
......@@ -17,7 +17,7 @@ Polymer({
value: 0,
},
/** @type {!Array<!Certificate>} */
/** @type {!Array<!CertificatesOrgGroup>} */
personalCerts: {
type: Array,
value: function() {
......@@ -25,7 +25,7 @@ Polymer({
},
},
/** @type {!Array<!Certificate>} */
/** @type {!Array<!CertificatesOrgGroup>} */
serverCerts: {
type: Array,
value: function() {
......@@ -33,7 +33,7 @@ Polymer({
},
},
/** @type {!Array<!Certificate>} */
/** @type {!Array<!CertificatesOrgGroup>} */
caCerts: {
type: Array,
value: function() {
......@@ -41,7 +41,7 @@ Polymer({
},
},
/** @type {!Array<!Certificate>} */
/** @type {!Array<!CertificatesOrgGroup>} */
otherCerts: {
type: Array,
value: function() {
......
......@@ -2,6 +2,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
<link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
......@@ -32,6 +33,8 @@
[[i18n('certificateManagerUntrusted')]]
</div>
<div class="name">[[model.name]]</div>
<cr-policy-indicator indicator-type="[[getPolicyIndicatorType_(model)]]">
</cr-policy-indicator>
<paper-icon-button-light class="icon-more-vert">
<button id="dots" title="[[i18n('moreActions')]]" on-tap="onDotsTap_">
</button>
......
......@@ -147,4 +147,10 @@ Polymer({
var actionMenu = /** @type {!CrActionMenuElement} */ (this.$.menu.get());
actionMenu.showAt(this.$.dots);
},
/** @private */
getPolicyIndicatorType_: function(model) {
return model.policy ? CrPolicyIndicatorType.USER_POLICY :
CrPolicyIndicatorType.NONE;
},
});
......@@ -31,14 +31,19 @@ var CertificateSubnode;
var NewCertificateSubNode;
/**
* Top-level grouping node in a certificate list, representing an organization
* and containing certs that belong to the organization in |subnodes|. If a
* certificate does not have an organization name, it will be grouped under its
* own CertificatesOrgGroup with |name| set to its display name.
* @typedef {{
* id: string,
* name: string,
* containsPolicyCerts: boolean,
* subnodes: !Array<!CertificateSubnode>
* }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/
var Certificate;
var CertificatesOrgGroup;
/**
* @typedef {{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment