Chromium Code Reviews| Index: chrome/browser/chromeos/arc/intent_helper/arc_settings_service.cc |
| diff --git a/chrome/browser/chromeos/arc/intent_helper/arc_settings_service.cc b/chrome/browser/chromeos/arc/intent_helper/arc_settings_service.cc |
| index 8959cb3fb70648cca7e4bae58b3fbd7eb33444bc..c91e5f34a32c11b062f987bc675213d83a9e49c2 100644 |
| --- a/chrome/browser/chromeos/arc/intent_helper/arc_settings_service.cc |
| +++ b/chrome/browser/chromeos/arc/intent_helper/arc_settings_service.cc |
| @@ -152,10 +152,18 @@ class ArcSettingsServiceImpl |
| // Returns the integer value of the pref. pref_name must exist. |
| int GetIntegerPref(const std::string& pref_name) const; |
| + // Gets whether this is a managed pref. |
| + bool IsPrefManaged(const std::string& pref_name) const; |
| + |
| // Sends boolean pref broadcast to the delegate. |
| void SendBoolPrefSettingsBroadcast(const std::string& pref_name, |
| const std::string& action) const; |
| + // Same as above, except sends a specific boolean value. |
| + void SendBoolValueSettingsBroadcast(bool value, |
| + bool managed, |
| + const std::string& action) const; |
| + |
| // Sends a broadcast to the delegate. |
| void SendSettingsBroadcast(const std::string& action, |
| const base::DictionaryValue& extras) const; |
| @@ -490,14 +498,39 @@ void ArcSettingsServiceImpl::SyncReportingConsent() const { |
| } |
| void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { |
| - std::string setting = |
| + // Chrome spoken feedback triggers enabling of Android spoken feedback. |
| + // There are two types of spoken feedback from Android: |
| + // 1. Talkback (default) |
| + // 2. accessibility helper (experimental, works through ChromeVox). |
| + // These two features are mutually exclusive. |
| + |
| + int enabled = GetIntegerPref(prefs::kAccessibilitySpokenFeedbackEnabled); |
| + bool managed = IsPrefManaged(prefs::kAccessibilitySpokenFeedbackEnabled); |
| + |
| + std::string talkback_setting = |
| "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"; |
| + std::string accessibility_helper_setting = |
| + "org.chromium.arc.intent_helper.SET_ACCESSIBILITY_HELPER_ENABLED"; |
| + |
| if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - chromeos::switches::kEnableChromeVoxArcSupport)) |
| - setting = "org.chromium.arc.intent_helper.SET_ACCESSIBILITY_HELPER_ENABLED"; |
| + chromeos::switches::kEnableChromeVoxArcSupport)) { |
| + SendBoolValueSettingsBroadcast(enabled, managed, |
| + accessibility_helper_setting); |
| - SendBoolPrefSettingsBroadcast(prefs::kAccessibilitySpokenFeedbackEnabled, |
| - setting); |
| + // Make sure if ChromeVox is on, TalkBack is off. |
| + if (enabled) { |
| + SendBoolValueSettingsBroadcast(false, managed, talkback_setting); |
| + } |
| + return; |
| + } |
| + |
| + SendBoolValueSettingsBroadcast(enabled, managed, talkback_setting); |
| + |
| + // Makes sure if Talkback is on, accessibility helper is off. |
| + if (enabled) { |
| + SendBoolValueSettingsBroadcast(false, managed, |
| + accessibility_helper_setting); |
| + } |
| } |
| void ArcSettingsServiceImpl::SyncTimeZone() const { |
| @@ -558,6 +591,16 @@ int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const { |
| return val; |
| } |
| +bool ArcSettingsServiceImpl::IsPrefManaged(const std::string& pref_name) const { |
| + const PrefService::Preference* pref = |
| + registrar_.prefs()->FindPreference(pref_name); |
| + DCHECK(pref); |
| + int val = -1; |
| + bool value_exists = pref->GetValue()->GetAsInteger(&val); |
|
Luis Héctor Chávez
2017/03/08 19:17:44
maybe pref->GetValue()->is_int(); to avoid the tem
David Tseng
2017/03/09 21:27:52
Done.
|
| + DCHECK(value_exists); |
| + return !pref->IsUserModifiable(); |
| +} |
| + |
| void ArcSettingsServiceImpl::SendBoolPrefSettingsBroadcast( |
| const std::string& pref_name, |
| const std::string& action) const { |
| @@ -567,9 +610,16 @@ void ArcSettingsServiceImpl::SendBoolPrefSettingsBroadcast( |
| bool enabled = false; |
| bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); |
| DCHECK(value_exists); |
| + SendBoolValueSettingsBroadcast(enabled, !pref->IsUserModifiable(), action); |
| +} |
| + |
| +void ArcSettingsServiceImpl::SendBoolValueSettingsBroadcast( |
| + bool enabled, |
| + bool managed, |
| + const std::string& action) const { |
| base::DictionaryValue extras; |
| extras.SetBoolean("enabled", enabled); |
| - extras.SetBoolean("managed", !pref->IsUserModifiable()); |
| + extras.SetBoolean("managed", managed); |
| SendSettingsBroadcast(action, extras); |
| } |