Commit b7dbd5ef authored by danielng's avatar danielng Committed by Commit Bot

crostini: Add basic UI for Crostini Mic settings

Adding basic UI elements as outlined in the PRD attached to the bug.
Note that these are not final, or to spec (as no spec exists yet),
and it is all behind an experimental flag.

Bug:1016193

CQ-DEPEND=CL:2079711

Change-Id: I6ec7fee8247342688d883e7ad6d0c6a05940cb25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079718
Commit-Queue: Daniel Ng <danielng@google.com>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJulian Watson <juwa@google.com>
Cr-Commit-Position: refs/heads/master@{#746251}
parent fb5247f0
...@@ -918,6 +918,9 @@ ...@@ -918,6 +918,9 @@
</message> </message>
<message name="IDS_SETTINGS_CROSTINI_PORT_FORWARDING_TABLE_TITLE" desc="Title for the list display of current preferences."> <message name="IDS_SETTINGS_CROSTINI_PORT_FORWARDING_TABLE_TITLE" desc="Title for the list display of current preferences.">
Ports Ports
</message>
<message name="IDS_SETTINGS_CROSTINI_MIC_TITLE" desc="Title for sharing mic with Crostini.">
Give access to microphone
</message> </message>
<!-- Android apps page (OS settings) --> <!-- Android apps page (OS settings) -->
......
1eb24bbb984243242afcf2764922812b27418768
\ No newline at end of file
...@@ -76,9 +76,12 @@ const char kCrostiniLastDiskSize[] = "crostini.last_disk_size"; ...@@ -76,9 +76,12 @@ const char kCrostiniLastDiskSize[] = "crostini.last_disk_size";
// A dictionary preference representing a user's settings of forwarded ports // A dictionary preference representing a user's settings of forwarded ports
// to Crostini. // to Crostini.
const char kCrostiniPortForwarding[] = "crostini.port_forwarding.ports"; const char kCrostiniPortForwarding[] = "crostini.port_forwarding.ports";
// A boolean preference indicating whether Crostini is able to access the mic.
const char kCrostiniMicSharing[] = "crostini.mic_sharing";
void RegisterProfilePrefs(PrefRegistrySimple* registry) { void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kCrostiniEnabled, false); registry->RegisterBooleanPref(kCrostiniEnabled, false);
registry->RegisterBooleanPref(kCrostiniMicSharing, true);
registry->RegisterDictionaryPref(kCrostiniMimeTypes); registry->RegisterDictionaryPref(kCrostiniMimeTypes);
registry->RegisterDictionaryPref(kCrostiniRegistry); registry->RegisterDictionaryPref(kCrostiniRegistry);
registry->RegisterListPref(kCrostiniPortForwarding); registry->RegisterListPref(kCrostiniPortForwarding);
......
...@@ -33,6 +33,7 @@ extern const char kCrostiniLastLaunchTerminaKernelVersion[]; ...@@ -33,6 +33,7 @@ extern const char kCrostiniLastLaunchTerminaKernelVersion[];
extern const char kCrostiniLastLaunchTimeWindowStart[]; extern const char kCrostiniLastLaunchTimeWindowStart[];
extern const char kCrostiniLastDiskSize[]; extern const char kCrostiniLastDiskSize[];
extern const char kCrostiniPortForwarding[]; extern const char kCrostiniPortForwarding[];
extern const char kCrostiniMicSharing[];
void RegisterProfilePrefs(PrefRegistrySimple* registry); void RegisterProfilePrefs(PrefRegistrySimple* registry);
......
...@@ -448,6 +448,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() { ...@@ -448,6 +448,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
// Guest OS // Guest OS
(*s_whitelist)[crostini::prefs::kCrostiniEnabled] = (*s_whitelist)[crostini::prefs::kCrostiniEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[crostini::prefs::kCrostiniMicSharing] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[crostini::prefs::kCrostiniSharedUsbDevices] = (*s_whitelist)[crostini::prefs::kCrostiniSharedUsbDevices] =
settings_api::PrefType::PREF_TYPE_LIST; settings_api::PrefType::PREF_TYPE_LIST;
(*s_whitelist)[crostini::prefs::kCrostiniContainers] = (*s_whitelist)[crostini::prefs::kCrostiniContainers] =
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> <link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="crostini_browser_proxy.html"> <link rel="import" href="crostini_browser_proxy.html">
<link rel="import" href="../../controls/settings_toggle_button.html">
<link rel="import" href="../../i18n_setup.html"> <link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../prefs/prefs_behavior.html"> <link rel="import" href="../../prefs/prefs_behavior.html">
<link rel="import" href="../os_route.html"> <link rel="import" href="../os_route.html">
...@@ -84,6 +85,12 @@ ...@@ -84,6 +85,12 @@
role-description="$i18n{subpageArrowRoleDescription}"> role-description="$i18n{subpageArrowRoleDescription}">
</cr-link-row> </cr-link-row>
</template> </template>
<template is="dom-if" if="[[showCrostiniMic_]]">
<settings-toggle-button id="crostini-mic-sharing"
pref="{{prefs.crostini.mic_sharing}}"
label="$i18n{enableCrostiniMicTitle}">
</settings-toggle-button>
</template>
<template is="dom-if" if="[[!hideCrostiniUninstall_]]"> <template is="dom-if" if="[[!hideCrostiniUninstall_]]">
<div id="remove" class="settings-box"> <div id="remove" class="settings-box">
<div id="removeCrostiniLabel" class="start">$i18n{crostiniRemove}</div> <div id="removeCrostiniLabel" class="start">$i18n{crostiniRemove}</div>
......
...@@ -90,6 +90,17 @@ Polymer({ ...@@ -90,6 +90,17 @@ Polymer({
}, },
}, },
/**
* Whether the toggle to share the mic with Crostini should be shown.
* @private {boolean}
*/
showCrostiniMic_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('showCrostiniMic');
},
},
/* /*
* Whether the installer is showing. * Whether the installer is showing.
* @private {boolean} * @private {boolean}
......
...@@ -639,6 +639,7 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source, ...@@ -639,6 +639,7 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
{"crostiniDiskResizeTitle", IDS_SETTINGS_CROSTINI_DISK_RESIZE_TITLE}, {"crostiniDiskResizeTitle", IDS_SETTINGS_CROSTINI_DISK_RESIZE_TITLE},
{"crostiniDiskResizeShowButton", {"crostiniDiskResizeShowButton",
IDS_SETTINGS_CROSTINI_DISK_RESIZE_SHOW_BUTTON}, IDS_SETTINGS_CROSTINI_DISK_RESIZE_SHOW_BUTTON},
{"enableCrostiniMicTitle", IDS_SETTINGS_CROSTINI_MIC_TITLE},
}; };
AddLocalizedStringsBulk(html_source, kLocalizedStrings); AddLocalizedStringsBulk(html_source, kLocalizedStrings);
html_source->AddString( html_source->AddString(
...@@ -689,6 +690,9 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source, ...@@ -689,6 +690,9 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
html_source->AddBoolean( html_source->AddBoolean(
"showCrostiniDiskResize", "showCrostiniDiskResize",
base::FeatureList::IsEnabled(chromeos::features::kCrostiniDiskResizing)); base::FeatureList::IsEnabled(chromeos::features::kCrostiniDiskResizing));
html_source->AddBoolean("showCrostiniMic",
base::FeatureList::IsEnabled(
chromeos::features::kCrostiniShowMicSetting));
} }
void AddPluginVmStrings(content::WebUIDataSource* html_source, void AddPluginVmStrings(content::WebUIDataSource* html_source,
......
...@@ -9,13 +9,17 @@ let crostiniPage = null; ...@@ -9,13 +9,17 @@ let crostiniPage = null;
let crostiniBrowserProxy = null; let crostiniBrowserProxy = null;
function setCrostiniPrefs(enabled, optional = {}) { function setCrostiniPrefs(enabled, optional = {}) {
const {sharedPaths = {}, sharedUsbDevices = [], forwardedPorts = []} = const {
optional; sharedPaths = {},
sharedUsbDevices = [],
forwardedPorts = [],
micSharing = false
} = optional;
crostiniPage.prefs = { crostiniPage.prefs = {
crostini: { crostini: {
enabled: {value: enabled}, enabled: {value: enabled},
port_forwarding: {ports: {value: forwardedPorts}}, port_forwarding: {ports: {value: forwardedPorts}},
mic_sharing: {value: micSharing},
}, },
guest_os: { guest_os: {
paths_shared_to_vms: {value: sharedPaths}, paths_shared_to_vms: {value: sharedPaths},
...@@ -95,6 +99,7 @@ suite('CrostiniPageTests', function() { ...@@ -95,6 +99,7 @@ suite('CrostiniPageTests', function() {
loadTimeData.overrideValues({ loadTimeData.overrideValues({
showCrostiniExportImport: true, showCrostiniExportImport: true,
showCrostiniPortForwarding: true, showCrostiniPortForwarding: true,
showCrostiniMic: true,
}); });
const eventPromise = new Promise((resolve) => { const eventPromise = new Promise((resolve) => {
...@@ -124,6 +129,7 @@ suite('CrostiniPageTests', function() { ...@@ -124,6 +129,7 @@ suite('CrostiniPageTests', function() {
assertTrue(!!subpage.$$('#remove')); assertTrue(!!subpage.$$('#remove'));
assertTrue(!!subpage.$$('#container-upgrade')); assertTrue(!!subpage.$$('#container-upgrade'));
assertTrue(!!subpage.$$('#crostini-port-forwarding')); assertTrue(!!subpage.$$('#crostini-port-forwarding'));
assertTrue(!!subpage.$$('#crostini-mic-sharing'));
}); });
test('SharedPaths', async function() { test('SharedPaths', async function() {
...@@ -251,6 +257,21 @@ suite('CrostiniPageTests', function() { ...@@ -251,6 +257,21 @@ suite('CrostiniPageTests', function() {
assertFalse(subpage.$$('#import cr-button').disabled); assertFalse(subpage.$$('#import cr-button').disabled);
}); });
test('TogglecCrostiniMicSharing', function() {
assertTrue(!!subpage.$$('#crostini-mic-sharing'));
setCrostiniPrefs(true, {micSharing: true});
assertTrue(subpage.$$('#crostini-mic-sharing').checked);
assertTrue(subpage.$$('#crostini-mic-sharing').pref.value);
subpage.$$('#crostini-mic-sharing').click();
assertFalse(subpage.$$('#crostini-mic-sharing').checked);
assertFalse(subpage.$$('#crostini-mic-sharing').pref.value);
subpage.$$('#crostini-mic-sharing').click();
assertTrue(subpage.$$('#crostini-mic-sharing').checked);
assertTrue(subpage.$$('#crostini-mic-sharing').pref.value);
});
suite('SubPagePortForwarding', function() { suite('SubPagePortForwarding', function() {
/** @type {?SettingsCrostiniPortForwarding} */ /** @type {?SettingsCrostiniPortForwarding} */
let subpage; let subpage;
......
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