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
......@@ -919,6 +919,9 @@
<message name="IDS_SETTINGS_CROSTINI_PORT_FORWARDING_TABLE_TITLE" desc="Title for the list display of current preferences.">
Ports
</message>
<message name="IDS_SETTINGS_CROSTINI_MIC_TITLE" desc="Title for sharing mic with Crostini.">
Give access to microphone
</message>
<!-- Android apps page (OS settings) -->
<message name="IDS_SETTINGS_ANDROID_APPS_LABEL" desc="The text associated with the primary section setting.">
......
1eb24bbb984243242afcf2764922812b27418768
\ No newline at end of file
......@@ -76,9 +76,12 @@ const char kCrostiniLastDiskSize[] = "crostini.last_disk_size";
// A dictionary preference representing a user's settings of forwarded ports
// to Crostini.
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) {
registry->RegisterBooleanPref(kCrostiniEnabled, false);
registry->RegisterBooleanPref(kCrostiniMicSharing, true);
registry->RegisterDictionaryPref(kCrostiniMimeTypes);
registry->RegisterDictionaryPref(kCrostiniRegistry);
registry->RegisterListPref(kCrostiniPortForwarding);
......
......@@ -33,6 +33,7 @@ extern const char kCrostiniLastLaunchTerminaKernelVersion[];
extern const char kCrostiniLastLaunchTimeWindowStart[];
extern const char kCrostiniLastDiskSize[];
extern const char kCrostiniPortForwarding[];
extern const char kCrostiniMicSharing[];
void RegisterProfilePrefs(PrefRegistrySimple* registry);
......
......@@ -448,6 +448,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
// Guest OS
(*s_whitelist)[crostini::prefs::kCrostiniEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[crostini::prefs::kCrostiniMicSharing] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[crostini::prefs::kCrostiniSharedUsbDevices] =
settings_api::PrefType::PREF_TYPE_LIST;
(*s_whitelist)[crostini::prefs::kCrostiniContainers] =
......
......@@ -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/html/i18n_behavior.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="../../prefs/prefs_behavior.html">
<link rel="import" href="../os_route.html">
......@@ -84,6 +85,12 @@
role-description="$i18n{subpageArrowRoleDescription}">
</cr-link-row>
</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_]]">
<div id="remove" class="settings-box">
<div id="removeCrostiniLabel" class="start">$i18n{crostiniRemove}</div>
......
......@@ -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.
* @private {boolean}
......
......@@ -639,6 +639,7 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
{"crostiniDiskResizeTitle", IDS_SETTINGS_CROSTINI_DISK_RESIZE_TITLE},
{"crostiniDiskResizeShowButton",
IDS_SETTINGS_CROSTINI_DISK_RESIZE_SHOW_BUTTON},
{"enableCrostiniMicTitle", IDS_SETTINGS_CROSTINI_MIC_TITLE},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
html_source->AddString(
......@@ -689,6 +690,9 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
html_source->AddBoolean(
"showCrostiniDiskResize",
base::FeatureList::IsEnabled(chromeos::features::kCrostiniDiskResizing));
html_source->AddBoolean("showCrostiniMic",
base::FeatureList::IsEnabled(
chromeos::features::kCrostiniShowMicSetting));
}
void AddPluginVmStrings(content::WebUIDataSource* html_source,
......
......@@ -9,13 +9,17 @@ let crostiniPage = null;
let crostiniBrowserProxy = null;
function setCrostiniPrefs(enabled, optional = {}) {
const {sharedPaths = {}, sharedUsbDevices = [], forwardedPorts = []} =
optional;
const {
sharedPaths = {},
sharedUsbDevices = [],
forwardedPorts = [],
micSharing = false
} = optional;
crostiniPage.prefs = {
crostini: {
enabled: {value: enabled},
port_forwarding: {ports: {value: forwardedPorts}},
mic_sharing: {value: micSharing},
},
guest_os: {
paths_shared_to_vms: {value: sharedPaths},
......@@ -95,6 +99,7 @@ suite('CrostiniPageTests', function() {
loadTimeData.overrideValues({
showCrostiniExportImport: true,
showCrostiniPortForwarding: true,
showCrostiniMic: true,
});
const eventPromise = new Promise((resolve) => {
......@@ -124,6 +129,7 @@ suite('CrostiniPageTests', function() {
assertTrue(!!subpage.$$('#remove'));
assertTrue(!!subpage.$$('#container-upgrade'));
assertTrue(!!subpage.$$('#crostini-port-forwarding'));
assertTrue(!!subpage.$$('#crostini-mic-sharing'));
});
test('SharedPaths', async function() {
......@@ -251,6 +257,21 @@ suite('CrostiniPageTests', function() {
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() {
/** @type {?SettingsCrostiniPortForwarding} */
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