Commit ff001a53 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Settings: Fix focus restoration when exiting security page subpages.

Specifically:
 - Pass focusConfig object from parent privacy-page to security-page.
 - Populate the route hierarchy based on the PrivacySettingsRedesign
   flag.
 - Also fixing a pre-existing bug where the /certificates route was
   available even in cases when it shouldn't (bug exists on stable)

The focus config logic for the security page was initially added at
r749030, but it wasn't entirely correct and was never triggered.

Bug: 1032584
Change-Id: I6ce387485874f380c4a5c20d42c4ee5b32651245
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099298Reviewed-by: default avatarTheodore Olsauskas-Warren <sauski@google.com>
Commit-Queue: dpapad <dpapad@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749711}
parent ba0779b2
......@@ -183,8 +183,10 @@ js_library("security_page") {
"..:router",
"../people_page:sync_browser_proxy",
"../prefs:prefs_behavior",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:web_ui_listener_behavior",
"//ui/webui/resources/js/cr/ui:focus_without_ink",
]
}
......
......@@ -181,6 +181,7 @@
no-search$="[[!privacySettingsRedesignEnabled_]]"
associated-control="[[$$('#securityLinkRow')]]">
<settings-security-page prefs="{{prefs}}"
focus-config="[[focusConfig_]]"
sync-status="[[syncStatus]]">
</settings-security-page>
</settings-subpage>
......
......@@ -4,6 +4,8 @@
<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html">
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="collapse_radio_button.html">
<link rel="import" href="passwords_leak_detection_toggle.html">
<link rel="import" href="privacy_page_browser_proxy.html">
......
......@@ -80,24 +80,10 @@ Polymer({
},
},
/** @private {!Map<string, string>} */
focusConfig_: {
/** @type {!Map<string, (string|Function)>} */
focusConfig: {
type: Object,
value() {
const map = new Map();
// <if expr="use_nss_certs">
if (settings.routes.CERTIFICATES) {
map.set(settings.routes.CERTIFICATES.path, '#manageCertificates');
}
// </if>
if (settings.routes.SECURITY_KEYS) {
map.set(
settings.routes.SECURITY_KEYS.path,
'#security-keys-subpage-trigger');
}
return map;
},
observer: 'focusConfigChanged_',
},
},
......@@ -105,6 +91,29 @@ Polymer({
'onSafeBrowsingReportingPrefChange_(prefs.safebrowsing.*)',
],
/*
* @param {!Map<string, string>} newConfig
* @param {?Map<string, string>} oldConfig
* @private
*/
focusConfigChanged_(newConfig, oldConfig) {
assert(!oldConfig);
// <if expr="use_nss_certs">
if (settings.routes.CERTIFICATES) {
this.focusConfig.set(settings.routes.CERTIFICATES.path, () => {
cr.ui.focusWithoutInk(assert(this.$$('#manageCertificates')));
});
}
// </if>
if (settings.routes.SECURITY_KEYS) {
this.focusConfig.set(settings.routes.SECURITY_KEYS.path, () => {
cr.ui.focusWithoutInk(
assert(this.$$('#security-keys-subpage-trigger')));
});
}
},
/**
* @return {string}
* @private
......
......@@ -14,16 +14,25 @@ cr.define('settings', function() {
* @param {!SettingsRoutes} r
*/
function addPrivacyChildRoutes(r) {
r.CERTIFICATES = r.PRIVACY.createChild('/certificates');
r.SITE_SETTINGS = r.PRIVACY.createChild('/content');
if (loadTimeData.getBoolean('enableSecurityKeysSubpage')) {
r.SECURITY_KEYS = r.PRIVACY.createChild('/securityKeys');
}
if (loadTimeData.getBoolean('privacySettingsRedesignEnabled')) {
r.SECURITY = r.PRIVACY.createChild('/security');
r.COOKIES = r.PRIVACY.createChild('/cookies');
}
// <if expr="use_nss_certs">
r.CERTIFICATES = loadTimeData.getBoolean('privacySettingsRedesignEnabled') ?
r.SECURITY.createChild('/certificates') :
r.PRIVACY.createChild('/certificates');
// </if>
if (loadTimeData.getBoolean('enableSecurityKeysSubpage')) {
r.SECURITY_KEYS =
loadTimeData.getBoolean('privacySettingsRedesignEnabled') ?
r.SECURITY.createChild('/securityKeys') :
r.PRIVACY.createChild('/securityKeys');
}
r.SITE_SETTINGS_ALL = r.SITE_SETTINGS.createChild('all');
r.SITE_SETTINGS_SITE_DETAILS =
r.SITE_SETTINGS_ALL.createChild('/content/siteDetails');
......
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