Commit 83cb1c00 authored by Zach Helfinstein's avatar Zach Helfinstein Committed by Commit Bot

Inform user that Dictation sends audio to Google.

Dictation is an accessibility feature that allows users who opt-in
to have their speech transcribed into any text field in ChromeOS.


Screenshot: https://screenshot.googleplex.com/EkLrrNDAohB.png

BUG=850690
TEST=None

Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I11ca4051b38a4beec7876ba35899e337f36411e4
Reviewed-on: https://chromium-review.googlesource.com/1120852
Commit-Queue: Zach Helfinstein <zhelfins@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575875}
parent 44010e12
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "ash/accelerators/accelerator_controller.h"
#include "ash/accessibility/accessibility_highlight_controller.h" #include "ash/accessibility/accessibility_highlight_controller.h"
#include "ash/accessibility/accessibility_observer.h" #include "ash/accessibility/accessibility_observer.h"
#include "ash/accessibility/accessibility_panel_layout_manager.h" #include "ash/accessibility/accessibility_panel_layout_manager.h"
...@@ -89,6 +90,7 @@ constexpr const char* const kCopiedOnSigninAccessibilityPrefs[]{ ...@@ -89,6 +90,7 @@ constexpr const char* const kCopiedOnSigninAccessibilityPrefs[]{
prefs::kHighContrastAcceleratorDialogHasBeenAccepted, prefs::kHighContrastAcceleratorDialogHasBeenAccepted,
prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted,
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted, prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted,
prefs::kDictationAcceleratorDialogHasBeenAccepted,
}; };
// Returns true if |pref_service| is the one used for the signin screen. // Returns true if |pref_service| is the one used for the signin screen.
...@@ -278,6 +280,8 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry, ...@@ -278,6 +280,8 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry,
prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, false); prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, false);
registry->RegisterBooleanPref( registry->RegisterBooleanPref(
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted, false); prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted, false);
registry->RegisterBooleanPref(
prefs::kDictationAcceleratorDialogHasBeenAccepted, false);
return; return;
} }
...@@ -305,6 +309,8 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry, ...@@ -305,6 +309,8 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry,
prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted); prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted);
registry->RegisterForeignPref( registry->RegisterForeignPref(
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted); prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted);
registry->RegisterForeignPref(
prefs::kDictationAcceleratorDialogHasBeenAccepted);
} }
void AccessibilityController::SetHighContrastAcceleratorDialogAccepted() { void AccessibilityController::SetHighContrastAcceleratorDialogAccepted() {
...@@ -352,6 +358,21 @@ bool AccessibilityController::HasDockedMagnifierAcceleratorDialogBeenAccepted() ...@@ -352,6 +358,21 @@ bool AccessibilityController::HasDockedMagnifierAcceleratorDialogBeenAccepted()
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted); prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted);
} }
void AccessibilityController::SetDictationAcceleratorDialogAccepted() {
if (!active_user_prefs_)
return;
active_user_prefs_->SetBoolean(
prefs::kDictationAcceleratorDialogHasBeenAccepted, true);
active_user_prefs_->CommitPendingWrite();
}
bool AccessibilityController::HasDictationAcceleratorDialogBeenAccepted()
const {
return active_user_prefs_ &&
active_user_prefs_->GetBoolean(
prefs::kDictationAcceleratorDialogHasBeenAccepted);
}
void AccessibilityController::AddObserver(AccessibilityObserver* observer) { void AccessibilityController::AddObserver(AccessibilityObserver* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
} }
...@@ -405,9 +426,24 @@ void AccessibilityController::SetDictationEnabled(bool enabled) { ...@@ -405,9 +426,24 @@ void AccessibilityController::SetDictationEnabled(bool enabled) {
if (!active_user_prefs_) if (!active_user_prefs_)
return; return;
active_user_prefs_->SetBoolean(prefs::kAccessibilityDictationEnabled, const bool dialog_ever_accepted = HasDictationAcceleratorDialogBeenAccepted();
enabled);
active_user_prefs_->CommitPendingWrite(); if (enabled && !dialog_ever_accepted) {
Shell::Get()->accelerator_controller()->MaybeShowConfirmationDialog(
IDS_ASH_DICTATION_CONFIRMATION_TITLE,
IDS_ASH_DICTATION_CONFIRMATION_BODY, base::BindOnce([]() {
AccessibilityController* controller =
Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->active_user_prefs_->SetBoolean(
prefs::kAccessibilityDictationEnabled, true);
controller->active_user_prefs_->CommitPendingWrite();
}));
} else {
active_user_prefs_->SetBoolean(prefs::kAccessibilityDictationEnabled,
enabled);
active_user_prefs_->CommitPendingWrite();
}
} }
bool AccessibilityController::IsDictationEnabled() const { bool AccessibilityController::IsDictationEnabled() const {
......
...@@ -64,6 +64,8 @@ class ASH_EXPORT AccessibilityController ...@@ -64,6 +64,8 @@ class ASH_EXPORT AccessibilityController
bool HasScreenMagnifierAcceleratorDialogBeenAccepted() const; bool HasScreenMagnifierAcceleratorDialogBeenAccepted() const;
void SetDockedMagnifierAcceleratorDialogAccepted(); void SetDockedMagnifierAcceleratorDialogAccepted();
bool HasDockedMagnifierAcceleratorDialogBeenAccepted() const; bool HasDockedMagnifierAcceleratorDialogBeenAccepted() const;
void SetDictationAcceleratorDialogAccepted();
bool HasDictationAcceleratorDialogBeenAccepted() const;
void SetAutoclickEnabled(bool enabled); void SetAutoclickEnabled(bool enabled);
bool IsAutoclickEnabled() const; bool IsAutoclickEnabled() const;
......
...@@ -431,6 +431,12 @@ This file contains the strings for ash. ...@@ -431,6 +431,12 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_DICTATION" desc="The label used in the accessibility menu of the system tray to toggle on/off the speak to type feature."> <message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_DICTATION" desc="The label used in the accessibility menu of the system tray to toggle on/off the speak to type feature.">
Dictation Dictation
</message> </message>
<message name="IDS_ASH_DICTATION_CONFIRMATION_TITLE" desc="The title for the modal dialog shown the first time the user enables dictation">
Dictation
</message>
<message name="IDS_ASH_DICTATION_CONFIRMATION_BODY" desc="The message shown the first time the user enables Dictation, explaining that the audio data will be sent to Google for transcription">
Dictation sends your voice to Google to allow voice typing in any text field.
</message>
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE" desc="The label used in the accessibility menu of the system tray to toggle on/off high contrast feature."> <message name="IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE" desc="The label used in the accessibility menu of the system tray to toggle on/off high contrast feature.">
High contrast mode High contrast mode
</message> </message>
......
...@@ -87,6 +87,10 @@ const char kHighContrastAcceleratorDialogHasBeenAccepted[] = ...@@ -87,6 +87,10 @@ const char kHighContrastAcceleratorDialogHasBeenAccepted[] =
// dialog has ever been shown. // dialog has ever been shown.
const char kScreenMagnifierAcceleratorDialogHasBeenAccepted[] = const char kScreenMagnifierAcceleratorDialogHasBeenAccepted[] =
"settings.a11y.screen_magnifier_accelerator_dialog_has_been_accepted"; "settings.a11y.screen_magnifier_accelerator_dialog_has_been_accepted";
// A boolean pref which indicates whether the dictation confirmation dialog has
// ever been shown.
const char kDictationAcceleratorDialogHasBeenAccepted[] =
"settings.a11y.dictation_accelerator_dialog_has_been_accepted";
// A dictionary pref that stores the mixed mirror mode parameters. // A dictionary pref that stores the mixed mirror mode parameters.
const char kDisplayMixedMirrorModeParams[] = const char kDisplayMixedMirrorModeParams[] =
......
...@@ -39,6 +39,8 @@ ASH_PUBLIC_EXPORT extern const char ...@@ -39,6 +39,8 @@ ASH_PUBLIC_EXPORT extern const char
kHighContrastAcceleratorDialogHasBeenAccepted[]; kHighContrastAcceleratorDialogHasBeenAccepted[];
ASH_PUBLIC_EXPORT extern const char ASH_PUBLIC_EXPORT extern const char
kScreenMagnifierAcceleratorDialogHasBeenAccepted[]; kScreenMagnifierAcceleratorDialogHasBeenAccepted[];
ASH_PUBLIC_EXPORT extern const char
kDictationAcceleratorDialogHasBeenAccepted[];
ASH_PUBLIC_EXPORT extern const char kDisplayMixedMirrorModeParams[]; ASH_PUBLIC_EXPORT extern const char kDisplayMixedMirrorModeParams[];
ASH_PUBLIC_EXPORT extern const char kDisplayPowerState[]; ASH_PUBLIC_EXPORT extern const char kDisplayPowerState[];
......
...@@ -81,16 +81,20 @@ class DictationButtonTrayTest : public AshTestBase { ...@@ -81,16 +81,20 @@ class DictationButtonTrayTest : public AshTestBase {
// Ensures that creation doesn't cause any crashes and adds the image icon. // Ensures that creation doesn't cause any crashes and adds the image icon.
// Also checks that the tray is visible. // Also checks that the tray is visible.
TEST_F(DictationButtonTrayTest, BasicConstruction) { TEST_F(DictationButtonTrayTest, BasicConstruction) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true); AccessibilityController* controller =
Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
EXPECT_TRUE(GetImageView(GetTray())); EXPECT_TRUE(GetImageView(GetTray()));
EXPECT_TRUE(GetTray()->visible()); EXPECT_TRUE(GetTray()->visible());
} }
// Test that clicking the button activates dictation. // Test that clicking the button activates dictation.
TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) { TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true);
AccessibilityController* controller = AccessibilityController* controller =
Shell::Get()->accessibility_controller(); Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
TestAccessibilityControllerClient client; TestAccessibilityControllerClient client;
controller->SetClient(client.CreateInterfacePtrAndBind()); controller->SetClient(client.CreateInterfacePtrAndBind());
...@@ -107,7 +111,10 @@ TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) { ...@@ -107,7 +111,10 @@ TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) {
// Test that activating dictation causes the button to activate. // Test that activating dictation causes the button to activate.
TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) { TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true); AccessibilityController* controller =
Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
Shell::Get()->OnDictationStarted(); Shell::Get()->OnDictationStarted();
EXPECT_TRUE(GetTray()->is_active()); EXPECT_TRUE(GetTray()->is_active());
...@@ -118,9 +125,10 @@ TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) { ...@@ -118,9 +125,10 @@ TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) {
// Tests that the tray only renders as active while dictation is listening. Any // Tests that the tray only renders as active while dictation is listening. Any
// termination of dictation clears the active state. // termination of dictation clears the active state.
TEST_F(DictationButtonTrayTest, ActiveStateOnlyDuringDictation) { TEST_F(DictationButtonTrayTest, ActiveStateOnlyDuringDictation) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true);
AccessibilityController* controller = AccessibilityController* controller =
Shell::Get()->accessibility_controller(); Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
TestAccessibilityControllerClient client; TestAccessibilityControllerClient client;
controller->SetClient(client.CreateInterfacePtrAndBind()); controller->SetClient(client.CreateInterfacePtrAndBind());
......
...@@ -271,6 +271,9 @@ ...@@ -271,6 +271,9 @@
<message name="IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL" desc="Label for checkbox which enables an on-screen keyboard."> <message name="IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL" desc="Label for checkbox which enables an on-screen keyboard.">
Enable on-screen keyboard Enable on-screen keyboard
</message> </message>
<message name="IDS_SETTINGS_ACCESSIBILITY_DICTATION_DESCRIPTION" desc="Description explaining that Dictation sends audio data to Google for transcription">
Send your voice to Google to allow dictation into any text field.
</message>
<message name="IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL" desc="Label for checkbox which enables the ability to speak into text fields"> <message name="IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL" desc="Label for checkbox which enables the ability to speak into text fields">
Enable dictation (speak to type) Enable dictation (speak to type)
</message> </message>
......
...@@ -243,6 +243,9 @@ void Preferences::RegisterProfilePrefs( ...@@ -243,6 +243,9 @@ void Preferences::RegisterProfilePrefs(
registry->RegisterBooleanPref( registry->RegisterBooleanPref(
ash::prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, false, ash::prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, false,
PrefRegistry::PUBLIC); PrefRegistry::PUBLIC);
registry->RegisterBooleanPref(
ash::prefs::kDictationAcceleratorDialogHasBeenAccepted, false,
PrefRegistry::PUBLIC);
registry->RegisterBooleanPref( registry->RegisterBooleanPref(
ash::prefs::kAccessibilityScreenMagnifierEnabled, false, ash::prefs::kAccessibilityScreenMagnifierEnabled, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF | PrefRegistry::PUBLIC); user_prefs::PrefRegistrySyncable::SYNCABLE_PREF | PrefRegistry::PUBLIC);
......
...@@ -156,7 +156,8 @@ ...@@ -156,7 +156,8 @@
</settings-toggle-button> </settings-toggle-button>
<settings-toggle-button class="continuation" <settings-toggle-button class="continuation"
pref="{{prefs.settings.a11y.dictation}}" pref="{{prefs.settings.a11y.dictation}}"
label="$i18n{dictationLabel}"> label="$i18n{dictationLabel}"
sub-label="$i18n{dictationDescription}">
</settings-toggle-button> </settings-toggle-button>
<settings-toggle-button class="continuation" <settings-toggle-button class="continuation"
pref="{{prefs.settings.a11y.focus_highlight}}" pref="{{prefs.settings.a11y.focus_highlight}}"
......
...@@ -199,6 +199,7 @@ void AddA11yStrings(content::WebUIDataSource* html_source) { ...@@ -199,6 +199,7 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"delayBeforeClickShort", IDS_SETTINGS_DELAY_BEFORE_CLICK_SHORT}, {"delayBeforeClickShort", IDS_SETTINGS_DELAY_BEFORE_CLICK_SHORT},
{"delayBeforeClickLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_LONG}, {"delayBeforeClickLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_LONG},
{"delayBeforeClickVeryLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_VERY_LONG}, {"delayBeforeClickVeryLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_VERY_LONG},
{"dictationDescription", IDS_SETTINGS_ACCESSIBILITY_DICTATION_DESCRIPTION},
{"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL}, {"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL},
{"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL}, {"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL},
{"monoAudioLabel", IDS_SETTINGS_MONO_AUDIO_LABEL}, {"monoAudioLabel", IDS_SETTINGS_MONO_AUDIO_LABEL},
......
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