Skip to content

Commit

Permalink
Inform user that Dictation sends audio to Google.
Browse files Browse the repository at this point in the history
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: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575875}
  • Loading branch information
Zach Helfinstein authored and Commit Bot committed Jul 18, 2018
1 parent 44010e1 commit 83cb1c0
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 8 deletions.
42 changes: 39 additions & 3 deletions ash/accessibility/accessibility_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <memory>
#include <utility>

#include "ash/accelerators/accelerator_controller.h"
#include "ash/accessibility/accessibility_highlight_controller.h"
#include "ash/accessibility/accessibility_observer.h"
#include "ash/accessibility/accessibility_panel_layout_manager.h"
Expand Down Expand Up @@ -89,6 +90,7 @@ constexpr const char* const kCopiedOnSigninAccessibilityPrefs[]{
prefs::kHighContrastAcceleratorDialogHasBeenAccepted,
prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted,
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted,
prefs::kDictationAcceleratorDialogHasBeenAccepted,
};

// Returns true if |pref_service| is the one used for the signin screen.
Expand Down Expand Up @@ -278,6 +280,8 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry,
prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, false);
registry->RegisterBooleanPref(
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted, false);
registry->RegisterBooleanPref(
prefs::kDictationAcceleratorDialogHasBeenAccepted, false);
return;
}

Expand Down Expand Up @@ -305,6 +309,8 @@ void AccessibilityController::RegisterProfilePrefs(PrefRegistrySimple* registry,
prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted);
registry->RegisterForeignPref(
prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted);
registry->RegisterForeignPref(
prefs::kDictationAcceleratorDialogHasBeenAccepted);
}

void AccessibilityController::SetHighContrastAcceleratorDialogAccepted() {
Expand Down Expand Up @@ -352,6 +358,21 @@ bool AccessibilityController::HasDockedMagnifierAcceleratorDialogBeenAccepted()
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) {
observers_.AddObserver(observer);
}
Expand Down Expand Up @@ -405,9 +426,24 @@ void AccessibilityController::SetDictationEnabled(bool enabled) {
if (!active_user_prefs_)
return;

active_user_prefs_->SetBoolean(prefs::kAccessibilityDictationEnabled,
enabled);
active_user_prefs_->CommitPendingWrite();
const bool dialog_ever_accepted = HasDictationAcceleratorDialogBeenAccepted();

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 {
Expand Down
2 changes: 2 additions & 0 deletions ash/accessibility/accessibility_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ASH_EXPORT AccessibilityController
bool HasScreenMagnifierAcceleratorDialogBeenAccepted() const;
void SetDockedMagnifierAcceleratorDialogAccepted();
bool HasDockedMagnifierAcceleratorDialogBeenAccepted() const;
void SetDictationAcceleratorDialogAccepted();
bool HasDictationAcceleratorDialogBeenAccepted() const;

void SetAutoclickEnabled(bool enabled);
bool IsAutoclickEnabled() const;
Expand Down
6 changes: 6 additions & 0 deletions ash/ash_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -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.">
Dictation
</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.">
High contrast mode
</message>
Expand Down
4 changes: 4 additions & 0 deletions ash/public/cpp/ash_pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ const char kHighContrastAcceleratorDialogHasBeenAccepted[] =
// dialog has ever been shown.
const char kScreenMagnifierAcceleratorDialogHasBeenAccepted[] =
"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.
const char kDisplayMixedMirrorModeParams[] =
Expand Down
2 changes: 2 additions & 0 deletions ash/public/cpp/ash_pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ ASH_PUBLIC_EXPORT extern const char
kHighContrastAcceleratorDialogHasBeenAccepted[];
ASH_PUBLIC_EXPORT extern const char
kScreenMagnifierAcceleratorDialogHasBeenAccepted[];
ASH_PUBLIC_EXPORT extern const char
kDictationAcceleratorDialogHasBeenAccepted[];

ASH_PUBLIC_EXPORT extern const char kDisplayMixedMirrorModeParams[];
ASH_PUBLIC_EXPORT extern const char kDisplayPowerState[];
Expand Down
16 changes: 12 additions & 4 deletions ash/system/accessibility/dictation_button_tray_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,20 @@ class DictationButtonTrayTest : public AshTestBase {
// Ensures that creation doesn't cause any crashes and adds the image icon.
// Also checks that the tray is visible.
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(GetTray()->visible());
}

// Test that clicking the button activates dictation.
TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true);
AccessibilityController* controller =
Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
TestAccessibilityControllerClient client;
controller->SetClient(client.CreateInterfacePtrAndBind());

Expand All @@ -107,7 +111,10 @@ TEST_F(DictationButtonTrayTest, ButtonActivatesDictation) {

// Test that activating dictation causes the button to activate.
TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true);
AccessibilityController* controller =
Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
Shell::Get()->OnDictationStarted();
EXPECT_TRUE(GetTray()->is_active());

Expand All @@ -118,9 +125,10 @@ TEST_F(DictationButtonTrayTest, ActivatingDictationActivatesButton) {
// Tests that the tray only renders as active while dictation is listening. Any
// termination of dictation clears the active state.
TEST_F(DictationButtonTrayTest, ActiveStateOnlyDuringDictation) {
Shell::Get()->accessibility_controller()->SetDictationEnabled(true);
AccessibilityController* controller =
Shell::Get()->accessibility_controller();
controller->SetDictationAcceleratorDialogAccepted();
controller->SetDictationEnabled(true);
TestAccessibilityControllerClient client;
controller->SetClient(client.CreateInterfacePtrAndBind());

Expand Down
3 changes: 3 additions & 0 deletions chrome/app/settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@
<message name="IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL" desc="Label for checkbox which enables an on-screen keyboard.">
Enable on-screen keyboard
</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">
Enable dictation (speak to type)
</message>
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/chromeos/preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ void Preferences::RegisterProfilePrefs(
registry->RegisterBooleanPref(
ash::prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted, false,
PrefRegistry::PUBLIC);
registry->RegisterBooleanPref(
ash::prefs::kDictationAcceleratorDialogHasBeenAccepted, false,
PrefRegistry::PUBLIC);
registry->RegisterBooleanPref(
ash::prefs::kAccessibilityScreenMagnifierEnabled, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF | PrefRegistry::PUBLIC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ <h2>$i18n{keyboardAndTextInputHeading}</h2>
</settings-toggle-button>
<settings-toggle-button class="continuation"
pref="{{prefs.settings.a11y.dictation}}"
label="$i18n{dictationLabel}">
label="$i18n{dictationLabel}"
sub-label="$i18n{dictationDescription}">
</settings-toggle-button>
<settings-toggle-button class="continuation"
pref="{{prefs.settings.a11y.focus_highlight}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"delayBeforeClickShort", IDS_SETTINGS_DELAY_BEFORE_CLICK_SHORT},
{"delayBeforeClickLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_LONG},
{"delayBeforeClickVeryLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_VERY_LONG},
{"dictationDescription", IDS_SETTINGS_ACCESSIBILITY_DICTATION_DESCRIPTION},
{"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL},
{"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL},
{"monoAudioLabel", IDS_SETTINGS_MONO_AUDIO_LABEL},
Expand Down

0 comments on commit 83cb1c0

Please sign in to comment.