Commit abfa65ab authored by Daniel Classon's avatar Daniel Classon Committed by Commit Bot

[OsSettingsDeepLinking] Add deep links to the Crostini Page.

Adds deep links to the Crostini Page, including the Crostini Details,
Import Export, and Android ADB subpages.

Bug: 1084154
Change-Id: I0dd75e13999b5ce7f8c17b39442d20dc0bfea59b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2381072Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Daniel Classon <dclasson@google.com>
Cr-Commit-Position: refs/heads/master@{#805970}
parent 7fdffd4f
......@@ -22,6 +22,7 @@ js_type_check("closure_compile") {
js_library("crostini_arc_adb") {
deps = [
":crostini_browser_proxy",
"..:deep_linking_behavior",
"..:metrics_recorder",
"..:os_route",
"../localized_link:localized_link",
......@@ -38,6 +39,7 @@ js_library("crostini_browser_proxy") {
js_library("crostini_export_import") {
deps = [
":crostini_browser_proxy",
"..:deep_linking_behavior",
"//ui/webui/resources/js:web_ui_listener_behavior",
]
}
......@@ -53,6 +55,7 @@ js_library("crostini_disk_resize_dialog") {
js_library("crostini_page") {
deps = [
":crostini_browser_proxy",
"..:deep_linking_behavior",
"..:os_route",
"../..:router",
"../../prefs:prefs_behavior",
......@@ -104,6 +107,7 @@ js_library("crostini_port_forwarding_add_port_dialog") {
js_library("crostini_subpage") {
deps = [
":crostini_browser_proxy",
"..:deep_linking_behavior",
"..:metrics_recorder",
"..:os_route",
"..:route_origin_behavior",
......
......@@ -7,6 +7,9 @@
<link rel="import" href="crostini_browser_proxy.html">
<link rel="import" href="crostini_arc_adb_confirmation_dialog.html">
<link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="../deep_linking_behavior.html">
<link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html">
<link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../settings_shared_css.html">
......@@ -39,7 +42,8 @@
checked$="[[arcAdbEnabled_]]"
disabled="[[shouldDisable_(canChangeAdbSideloading_,
arcAdbNeedPowerwash_)]]"
on-change="onArcAdbToggleChanged_">
on-change="onArcAdbToggleChanged_"
deep-link-focus-id$="[[Setting.kCrostiniAdbDebugging]]">
</cr-toggle>
</div>
......
......@@ -10,7 +10,12 @@
Polymer({
is: 'settings-crostini-arc-adb',
behaviors: [I18nBehavior, WebUIListenerBehavior],
behaviors: [
DeepLinkingBehavior,
I18nBehavior,
settings.RouteObserverBehavior,
WebUIListenerBehavior,
],
properties: {
/** @private {boolean} */
......@@ -57,6 +62,16 @@ Polymer({
type: Boolean,
value: false,
},
/**
* Used by DeepLinkingBehavior to focus this page's deep links.
* @type {!Set<!chromeos.settings.mojom.Setting>}
*/
supportedSettingIds: {
type: Object,
value: () =>
new Set([chromeos.settings.mojom.Setting.kCrostiniAdbDebugging]),
},
},
attached() {
......@@ -80,6 +95,19 @@ Polymer({
.getCanChangeArcAdbSideloading();
},
/**
* @param {!settings.Route} route
* @param {!settings.Route} oldRoute
*/
currentRouteChanged(route, oldRoute) {
// Does not apply to this page.
if (route !== settings.routes.CROSTINI_ANDROID_ADB) {
return;
}
this.attemptDeepLink();
},
/**
* Returns whether the toggle is changeable by the user. See
* CrostiniFeatures::CanChangeAdbSideloading(). Note that the actual
......
......@@ -5,6 +5,9 @@
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="crostini_browser_proxy.html">
<link rel="import" href="crostini_import_confirmation_dialog.html">
<link rel="import" href="../deep_linking_behavior.html">
<link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html">
<link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../settings_shared_css.html">
......@@ -16,7 +19,8 @@
$i18n{crostiniExportLabel}
</div>
<cr-button on-click="onExportClick_" disabled="[[!enableButtons_]]"
aria-labelledby="exportCrostiniLabel">
aria-labelledby="exportCrostiniLabel"
deep-link-focus-id$="[[Setting.kBackupLinuxAppsAndFiles]]">
$i18n{crostiniExport}
</cr-button>
</div>
......@@ -25,7 +29,8 @@
$i18n{crostiniImportLabel}
</div>
<cr-button on-click="onImportClick_" disabled="[[!enableButtons_]]"
aria-labelledby="importCrostiniLabel">
aria-labelledby="importCrostiniLabel"
deep-link-focus-id$="[[Setting.kRestoreLinuxAppsAndFiles]]">
$i18n{crostiniImport}
</cr-button>
</div>
......
......@@ -11,7 +11,11 @@
Polymer({
is: 'settings-crostini-export-import',
behaviors: [WebUIListenerBehavior],
behaviors: [
DeepLinkingBehavior,
settings.RouteObserverBehavior,
WebUIListenerBehavior,
],
properties: {
/** @private */
......@@ -42,6 +46,17 @@ Polymer({
value: false,
},
/**
* Used by DeepLinkingBehavior to focus this page's deep links.
* @type {!Set<!chromeos.settings.mojom.Setting>}
*/
supportedSettingIds: {
type: Object,
value: () => new Set([
chromeos.settings.mojom.Setting.kBackupLinuxAppsAndFiles,
chromeos.settings.mojom.Setting.kRestoreLinuxAppsAndFiles,
]),
},
},
attached() {
......@@ -60,6 +75,19 @@ Polymer({
.requestCrostiniInstallerStatus();
},
/**
* @param {!settings.Route} route
* @param {!settings.Route} oldRoute
*/
currentRouteChanged(route, oldRoute) {
// Does not apply to this page.
if (route !== settings.routes.CROSTINI_EXPORT_IMPORT) {
return;
}
this.attemptDeepLink();
},
/** @private */
onExportClick_() {
settings.CrostiniBrowserProxyImpl.getInstance().exportCrostiniContainer();
......
......@@ -6,6 +6,7 @@
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../prefs/prefs_behavior.html">
<link rel="import" href="../deep_linking_behavior.html">
<link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html">
<link rel="import" href="../../settings_page/settings_animated_pages.html">
......@@ -55,7 +56,8 @@
disabled$="[[disableCrostiniInstall_]]"
on-click="onEnableTap_"
aria-label="$i18n{crostiniPageTitle}"
aria-describedby="secondaryText">
aria-describedby="secondaryText"
deep-link-focus-id$="[[Setting.kSetUpCrostini]]">
$i18n{crostiniEnable}
</cr-button>
</template>
......
......@@ -12,7 +12,13 @@
Polymer({
is: 'settings-crostini-page',
behaviors: [I18nBehavior, PrefsBehavior, WebUIListenerBehavior],
behaviors: [
DeepLinkingBehavior,
I18nBehavior,
PrefsBehavior,
settings.RouteObserverBehavior,
WebUIListenerBehavior,
],
properties: {
/** Preferences state. */
......@@ -67,6 +73,15 @@ Polymer({
disableCrostiniInstall_: {
type: Boolean,
},
/**
* Used by DeepLinkingBehavior to focus this page's deep links.
* @type {!Set<!chromeos.settings.mojom.Setting>}
*/
supportedSettingIds: {
type: Object,
value: () => new Set([chromeos.settings.mojom.Setting.kSetUpCrostini]),
},
},
attached() {
......@@ -82,6 +97,19 @@ Polymer({
.requestCrostiniInstallerStatus();
},
/**
* @param {!settings.Route} route
* @param {!settings.Route} oldRoute
*/
currentRouteChanged(route, oldRoute) {
// Does not apply to this page.
if (route !== settings.routes.CROSTINI) {
return;
}
this.attemptDeepLink();
},
/**
* @param {!Event} event
* @private
......
......@@ -9,6 +9,7 @@
<link rel="import" href="../../controls/settings_toggle_button.html">
<link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../prefs/prefs_behavior.html">
<link rel="import" href="../deep_linking_behavior.html">
<link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html">
<link rel="import" href="../route_origin_behavior.html">
......@@ -36,7 +37,8 @@
on-click="onContainerUpgradeClick_"
aria-labelledby="containerUpgradeLabel containerUpgradeButton"
aria-describedby="containerUpgradeDescription"
disabled="[[disableUpgradeButton_]]">
disabled="[[disableUpgradeButton_]]"
deep-link-focus-id$="[[Setting.kCrostiniContainerUpgrade]]">
$i18n{crostiniContainerUpgradeButton}
</cr-button>
</div>
......@@ -95,7 +97,8 @@
<cr-button on-click="onDiskResizeClick_" hidden="[[!canDiskResize_]]"
aria-label="[[diskResizeButtonAriaLabel_]]"
aria-describedby="diskSizeDescription"
id="showDiskResizeButton">
id="showDiskResizeButton"
deep-link-focus-id$="[[Setting.kCrostiniDiskResize]]">
[[diskResizeButtonLabel_]]
</cr-button>
</div>
......@@ -118,7 +121,8 @@
<cr-toggle id="crostini-mic-sharing-toggle"
checked="[[crostiniMicSharingEnabled_]]"
on-change="onMicSharingChange_"
aria-describedby="crostini-mic-sharing-label">
aria-describedby="crostini-mic-sharing-label"
deep-link-focus-id$="[[Setting.kCrostiniMicAccess]]">
</cr-toggle>
</div>
<template is="dom-if" if="[[!hideCrostiniUninstall_]]">
......@@ -127,7 +131,8 @@
$i18n{crostiniRemove}
</div>
<cr-button on-click="onRemoveClick_"
aria-labelledby="removeCrostiniLabel">
aria-labelledby="removeCrostiniLabel"
deep-link-focus-id$="[[Setting.kUninstallCrostini]]">
$i18n{crostiniRemoveButton}
</cr-button>
</div>
......
......@@ -19,8 +19,12 @@ const ConfirmationState = {
Polymer({
is: 'settings-crostini-subpage',
behaviors:
[PrefsBehavior, WebUIListenerBehavior, settings.RouteOriginBehavior],
behaviors: [
DeepLinkingBehavior,
PrefsBehavior,
settings.RouteOriginBehavior,
WebUIListenerBehavior,
],
properties: {
/** Preferences state. */
......@@ -175,6 +179,20 @@ Polymer({
type: Boolean,
value: false,
},
/**
* Used by DeepLinkingBehavior to focus this page's deep links.
* @type {!Set<!chromeos.settings.mojom.Setting>}
*/
supportedSettingIds: {
type: Object,
value: () => new Set([
chromeos.settings.mojom.Setting.kUninstallCrostini,
chromeos.settings.mojom.Setting.kCrostiniDiskResize,
chromeos.settings.mojom.Setting.kCrostiniMicAccess,
chromeos.settings.mojom.Setting.kCrostiniContainerUpgrade,
]),
},
},
/** settings.RouteOriginBehavior override */
......@@ -229,6 +247,19 @@ Polymer({
r.CROSTINI_PORT_FORWARDING, '#crostini-port-forwarding');
},
/**
* @param {!settings.Route} route
* @param {!settings.Route} oldRoute
*/
currentRouteChanged(route, oldRoute) {
// Does not apply to this page.
if (route !== settings.routes.CROSTINI_DETAILS) {
return;
}
this.attemptDeepLink();
},
/** @private */
onCrostiniEnabledChanged_(enabled) {
if (!enabled &&
......
......@@ -13,9 +13,13 @@ function setCrostiniPrefs(enabled, optional = {}) {
sharedPaths = {},
sharedUsbDevices = [],
forwardedPorts = [],
crostiniMicSharingEnabled = false
crostiniMicSharingEnabled = false,
arcEnabled = false,
} = optional;
crostiniPage.prefs = {
arc: {
enabled: {value: arcEnabled},
},
crostini: {
enabled: {value: enabled},
port_forwarding: {ports: {value: forwardedPorts}},
......@@ -88,6 +92,22 @@ suite('CrostiniPageTests', function() {
await test_util.flushTasks();
assertFalse(button.disabled);
});
test('Deep link to setup Crostini', async () => {
loadTimeData.overrideValues({isDeepLinkingEnabled: true});
assertTrue(loadTimeData.getBoolean('isDeepLinkingEnabled'));
const params = new URLSearchParams;
params.append('settingId', '800');
settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI, params);
const deepLinkElement = crostiniPage.$$('#enable');
await test_util.waitAfterNextRender(deepLinkElement);
assertEquals(
deepLinkElement, getDeepActiveElement(),
'Enable Crostini button should be focused for settingId=800.');
});
});
suite('SubPageDetails', function() {
......@@ -95,12 +115,13 @@ suite('CrostiniPageTests', function() {
let subpage;
setup(async function() {
setCrostiniPrefs(true);
setCrostiniPrefs(true, {arcEnabled: true});
loadTimeData.overrideValues({
showCrostiniExportImport: true,
showCrostiniContainerUpgrade: true,
showCrostiniPortForwarding: true,
showCrostiniDiskResize: true,
arcAdbSideloadingSupported: true,
});
settings.Router.getInstance().navigateTo(settings.routes.CROSTINI);
......@@ -116,6 +137,7 @@ suite('CrostiniPageTests', function() {
assertTrue(!!subpage.$$('#crostini-shared-paths'));
assertTrue(!!subpage.$$('#crostini-shared-usb-devices'));
assertTrue(!!subpage.$$('#crostini-export-import'));
assertTrue(!!subpage.$$('#crostini-enable-arc-adb'));
assertTrue(!!subpage.$$('#remove'));
assertTrue(!!subpage.$$('#container-upgrade'));
assertTrue(!!subpage.$$('#crostini-port-forwarding'));
......@@ -193,6 +215,25 @@ suite('CrostiniPageTests', function() {
1, crostiniBrowserProxy.getCallCount('exportCrostiniContainer'));
});
test('Deep link to backup linux', async () => {
loadTimeData.overrideValues({isDeepLinkingEnabled: true});
assertTrue(loadTimeData.getBoolean('isDeepLinkingEnabled'));
const params = new URLSearchParams;
params.append('settingId', '802');
settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_EXPORT_IMPORT, params);
Polymer.dom.flush();
subpage = crostiniPage.$$('settings-crostini-export-import');
const deepLinkElement = subpage.$$('#export cr-button');
await test_util.waitAfterNextRender(deepLinkElement);
assertEquals(
deepLinkElement, getDeepActiveElement(),
'Export button should be focused for settingId=802.');
});
test('Import', async function() {
assertTrue(!!subpage.$$('#crostini-export-import'));
subpage.$$('#crostini-export-import').click();
......@@ -375,6 +416,26 @@ suite('CrostiniPageTests', function() {
const dialog = subpage.$$('settings-crostini-disk-resize-dialog');
assertTrue(!!dialog);
});
test('Deep link to resize disk', async () => {
loadTimeData.overrideValues({isDeepLinkingEnabled: true});
assertTrue(loadTimeData.getBoolean('isDeepLinkingEnabled'));
assertTrue(!!subpage.$$('#showDiskResizeButton'));
await crostiniBrowserProxy.resolvePromises(
'getCrostiniDiskInfo',
{succeeded: true, canResize: true, isUserChosenSize: true});
const params = new URLSearchParams;
params.append('settingId', '805');
settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_DETAILS, params);
const deepLinkElement = subpage.$$('#showDiskResizeButton');
await test_util.waitAfterNextRender(deepLinkElement);
assertEquals(
deepLinkElement, getDeepActiveElement(),
'Resize disk button should be focused for settingId=805.');
});
});
suite('SubPagePortForwarding', function() {
......@@ -1039,4 +1100,41 @@ suite('CrostiniPageTests', function() {
assertEquals(1, subpage.shadowRoot.querySelectorAll('.toggle').length);
});
});
suite('SubPageArcAdb', function() {
let subpage;
setup(async function() {
setCrostiniPrefs(true, {arcEnabled: true});
loadTimeData.overrideValues({
arcAdbSideloadingSupported: true,
});
await test_util.flushTasks();
settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_ANDROID_ADB);
await test_util.flushTasks();
subpage = crostiniPage.$$('settings-crostini-arc-adb');
assertTrue(!!subpage);
});
test('Deep link to enable adb debugging', async () => {
loadTimeData.overrideValues({isDeepLinkingEnabled: true});
assertTrue(loadTimeData.getBoolean('isDeepLinkingEnabled'));
const params = new URLSearchParams;
params.append('settingId', '804');
settings.Router.getInstance().navigateTo(
settings.routes.CROSTINI_ANDROID_ADB, params);
Polymer.dom.flush();
const deepLinkElement = subpage.$$('#arcAdbEnabledButton');
await test_util.waitAfterNextRender(deepLinkElement);
assertEquals(
deepLinkElement, getDeepActiveElement(),
'Enable adb debugging button should be focused for settingId=804.');
});
});
});
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