diff options
author | tengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-12 07:52:58 +0000 |
---|---|---|
committer | tengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-12 07:52:58 +0000 |
commit | 1c881566bfc202570c21eca4902c69711d8219f1 (patch) | |
tree | 1fabb0f37babec4f6e377d7e80e6168256327750 | |
parent | 1a55d7dcd4228615daf374e31d7d7b7314fce96d (diff) | |
download | chromium_src-1c881566bfc202570c21eca4902c69711d8219f1.zip chromium_src-1c881566bfc202570c21eca4902c69711d8219f1.tar.gz chromium_src-1c881566bfc202570c21eca4902c69711d8219f1.tar.bz2 |
Add autoclick feature to ChromeOS accessibility manager.
BUG=272401
TEST=updated browser_test
Review URL: https://codereview.chromium.org/26895004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228337 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/accessibility/accessibility_manager.cc | 34 | ||||
-rw-r--r-- | chrome/browser/chromeos/accessibility/accessibility_manager.h | 9 | ||||
-rw-r--r-- | chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc | 48 | ||||
-rw-r--r-- | chrome/browser/chromeos/preferences.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 2 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
6 files changed, 96 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc index e6ef40b..a841988 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc @@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "ash/autoclick/autoclick_controller.h" #include "ash/high_contrast/high_contrast_controller.h" #include "ash/shell.h" #include "ash/system/tray/system_tray_notifier.h" @@ -264,6 +265,7 @@ AccessibilityManager::AccessibilityManager() large_cursor_pref_handler_(prefs::kLargeCursorEnabled), spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), high_contrast_pref_handler_(prefs::kHighContrastEnabled), + autoclick_pref_handler_(prefs::kAutoclickEnabled), large_cursor_enabled_(false), sticky_keys_enabled_(false), spoken_feedback_enabled_(false), @@ -548,6 +550,32 @@ bool AccessibilityManager::IsHighContrastEnabled() { return high_contrast_enabled_; } +void AccessibilityManager::EnableAutoclick(bool enabled) { + if (!profile_) + return; + + PrefService* pref_service = profile_->GetPrefs(); + pref_service->SetBoolean(prefs::kAutoclickEnabled, enabled); + pref_service->CommitPendingWrite(); +} + +bool AccessibilityManager::IsAutoclickEnabled() { + return autoclick_enabled_; +} + +void AccessibilityManager::UpdateAutoclickFromPref() { + bool enabled = + profile_->GetPrefs()->GetBoolean(prefs::kAutoclickEnabled); + + if (autoclick_enabled_ == enabled) + return; + autoclick_enabled_ = enabled; + +#if defined(USE_ASH) + ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); +#endif +} + void AccessibilityManager::SetProfile(Profile* profile) { pref_change_registrar_.reset(); local_state_pref_change_registrar_.reset(); @@ -572,6 +600,10 @@ void AccessibilityManager::SetProfile(Profile* profile) { prefs::kHighContrastEnabled, base::Bind(&AccessibilityManager::UpdateHighContrastFromPref, base::Unretained(this))); + pref_change_registrar_->Add( + prefs::kAutoclickEnabled, + base::Bind(&AccessibilityManager::UpdateAutoclickFromPref, + base::Unretained(this))); local_state_pref_change_registrar_.reset(new PrefChangeRegistrar); local_state_pref_change_registrar_->Init(g_browser_process->local_state()); @@ -589,12 +621,14 @@ void AccessibilityManager::SetProfile(Profile* profile) { large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); + autoclick_pref_handler_.HandleProfileChanged(profile_, profile); profile_ = profile; UpdateLargeCursorFromPref(); UpdateStickyKeysFromPref(); UpdateSpokenFeedbackFromPref(); UpdateHighContrastFromPref(); + UpdateAutoclickFromPref(); } void AccessibilityManager::SetProfileForTest(Profile* profile) { diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h index c582130..418eade 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.h +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h @@ -94,6 +94,12 @@ class AccessibilityManager : public content::NotificationObserver { // Returns true if High Contrast is enabled, or false if not. bool IsHighContrastEnabled(); + // Enables or disables autoclick. + void EnableAutoclick(bool enabled); + + // Returns true if autoclick is enabled. + bool IsAutoclickEnabled(); + void SetProfileForTest(Profile* profile); protected: @@ -111,6 +117,7 @@ class AccessibilityManager : public content::NotificationObserver { void UpdateStickyKeysFromPref(); void UpdateSpokenFeedbackFromPref(); void UpdateHighContrastFromPref(); + void UpdateAutoclickFromPref(); void LocalePrefChanged(); void SetProfile(Profile* profile); @@ -137,11 +144,13 @@ class AccessibilityManager : public content::NotificationObserver { PrefHandler large_cursor_pref_handler_; PrefHandler spoken_feedback_pref_handler_; PrefHandler high_contrast_pref_handler_; + PrefHandler autoclick_pref_handler_; bool large_cursor_enabled_; bool sticky_keys_enabled_; bool spoken_feedback_enabled_; bool high_contrast_enabled_; + bool autoclick_enabled_; ash::AccessibilityNotificationVisibility spoken_feedback_notification_; diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc b/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc index ca71445..1cf3328 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc @@ -115,6 +115,14 @@ bool IsSpokenFeedbackEnabled() { return AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); } +void SetAutoclickEnabled(bool enabled) { + return AccessibilityManager::Get()->EnableAutoclick(enabled); +} + +bool IsAutoclickEnabled() { + return AccessibilityManager::Get()->IsAutoclickEnabled(); +} + Profile* GetProfile() { Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); DCHECK(profile); @@ -137,6 +145,10 @@ void SetSpokenFeedbackEnabledPref(bool enabled) { GetPrefs()->SetBoolean(prefs::kSpokenFeedbackEnabled, enabled); } +void SetAutoclickEnabledPref(bool enabled) { + GetPrefs()->SetBoolean(prefs::kAutoclickEnabled, enabled); +} + bool GetLargeCursorEnabledFromPref() { return GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled); } @@ -149,6 +161,10 @@ bool GetSpokenFeedbackEnabledFromPref() { return GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); } +bool GetAutoclickEnabledFromPref() { + return GetPrefs()->GetBoolean(prefs::kAutoclickEnabled); +} + } // anonymouse namespace class AccessibilityManagerTest : public InProcessBrowserTest { @@ -177,6 +193,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { EXPECT_FALSE(IsLargeCursorEnabled()); EXPECT_FALSE(IsSpokenFeedbackEnabled()); EXPECT_FALSE(IsHighContrastEnabled()); + EXPECT_FALSE(IsAutoclickEnabled()); // Logs in. UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); @@ -185,6 +202,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { EXPECT_FALSE(IsLargeCursorEnabled()); EXPECT_FALSE(IsSpokenFeedbackEnabled()); EXPECT_FALSE(IsHighContrastEnabled()); + EXPECT_FALSE(IsAutoclickEnabled()); UserManager::Get()->SessionStarted(); @@ -192,6 +210,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { EXPECT_FALSE(IsLargeCursorEnabled()); EXPECT_FALSE(IsSpokenFeedbackEnabled()); EXPECT_FALSE(IsHighContrastEnabled()); + EXPECT_FALSE(IsAutoclickEnabled()); // Enables large cursor. SetLargeCursorEnabled(true); @@ -207,6 +226,11 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { SetHighContrastEnabled(true); // Confirms that high cotrast is enabled. EXPECT_TRUE(IsHighContrastEnabled()); + + // Enables autoclick. + SetAutoclickEnabled(true); + // Confirms that autoclick is enabled. + EXPECT_TRUE(IsAutoclickEnabled()); } IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { @@ -218,6 +242,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { EXPECT_FALSE(IsLargeCursorEnabled()); EXPECT_FALSE(IsSpokenFeedbackEnabled()); EXPECT_FALSE(IsHighContrastEnabled()); + EXPECT_FALSE(IsAutoclickEnabled()); // Sets the pref as true to enable the large cursor. SetLargeCursorEnabledPref(true); @@ -229,11 +254,16 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { // Confirms that the spoken feedback is enabled. EXPECT_TRUE(IsSpokenFeedbackEnabled()); - // Enables the high contrast mode. - SetHighContrastEnabled(true); + // Sets the pref as true to enable high contrast mode. + SetHighContrastEnabledPref(true); // Confirms that the high contrast mode is enabled. EXPECT_TRUE(IsHighContrastEnabled()); + // Sets the pref as true to enable autoclick. + SetAutoclickEnabledPref(true); + // Confirms that autoclick is enabled. + EXPECT_TRUE(IsAutoclickEnabled()); + SetLargeCursorEnabledPref(false); EXPECT_FALSE(IsLargeCursorEnabled()); @@ -242,6 +272,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { SetHighContrastEnabledPref(false); EXPECT_FALSE(IsHighContrastEnabled()); + + SetAutoclickEnabledPref(false); + EXPECT_FALSE(IsAutoclickEnabled()); } IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { @@ -260,6 +293,10 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { SetHighContrastEnabledPref(true); EXPECT_FALSE(IsHighContrastEnabled()); + // Sets the pref to enable autoclick before login. + SetAutoclickEnabledPref(true); + EXPECT_FALSE(IsAutoclickEnabled()); + // Logs in. UserManager::Get()->SessionStarted(); @@ -267,6 +304,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { EXPECT_TRUE(IsLargeCursorEnabled()); EXPECT_TRUE(IsSpokenFeedbackEnabled()); EXPECT_TRUE(IsHighContrastEnabled()); + EXPECT_TRUE(IsAutoclickEnabled()); } IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, @@ -385,6 +423,9 @@ IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, // Enables high contrast. SetHighContrastEnabled(true); EXPECT_TRUE(IsHighContrastEnabled()); + // Enables autoclick. + SetAutoclickEnabled(true); + EXPECT_TRUE(IsAutoclickEnabled()); // Logs in. const char* user_name = GetParam(); @@ -394,6 +435,7 @@ IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, EXPECT_TRUE(IsLargeCursorEnabled()); EXPECT_TRUE(IsSpokenFeedbackEnabled()); EXPECT_TRUE(IsHighContrastEnabled()); + EXPECT_TRUE(IsAutoclickEnabled()); UserManager::Get()->SessionStarted(); @@ -401,11 +443,13 @@ IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, EXPECT_TRUE(IsLargeCursorEnabled()); EXPECT_TRUE(IsSpokenFeedbackEnabled()); EXPECT_TRUE(IsHighContrastEnabled()); + EXPECT_TRUE(IsAutoclickEnabled()); // Confirms that the prefs have been copied to the user's profile. EXPECT_TRUE(GetLargeCursorEnabledFromPref()); EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); EXPECT_TRUE(GetHighContrastEnabledFromPref()); + EXPECT_TRUE(GetAutoclickEnabledFromPref()); } } // namespace chromeos diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index a890916..5271c72 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -159,6 +159,10 @@ void Preferences::RegisterProfilePrefs( std::numeric_limits<double>::min(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterBooleanPref( + prefs::kAutoclickEnabled, + false, + user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); + registry->RegisterBooleanPref( prefs::kShouldAlwaysShowAccessibilityMenu, false, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 04a2000..b5f8302 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -715,6 +715,8 @@ const char kScreenMagnifierScale[] = "settings.a11y.screen_magnifier_scale"; // A boolean pref which determines whether virtual keyboard is enabled. // TODO(hashimoto): Remove this pref. const char kVirtualKeyboardEnabled[] = "settings.a11y.virtual_keyboard"; +// A boolean pref which determines whether autoclick is enabled. +const char kAutoclickEnabled[] = "settings.a11y.autoclick"; // A boolean pref which determines whether the accessibility menu shows // regardless of the state of a11y features. const char kShouldAlwaysShowAccessibilityMenu[] = "settings.a11y.enable_menu"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 5f61a7c..fba31cc 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -250,6 +250,7 @@ extern const char kScreenMagnifierEnabled[]; extern const char kScreenMagnifierType[]; extern const char kScreenMagnifierScale[]; extern const char kVirtualKeyboardEnabled[]; +extern const char kAutoclickEnabled[]; extern const char kShouldAlwaysShowAccessibilityMenu[]; extern const char kLabsAdvancedFilesystemEnabled[]; extern const char kLabsMediaplayerEnabled[]; |