| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_settings_service.h" | 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_settings_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 // Stops listening for Chrome settings changes. | 114 // Stops listening for Chrome settings changes. |
| 115 void StopObservingSettingsChanges(); | 115 void StopObservingSettingsChanges(); |
| 116 | 116 |
| 117 // Retrieves Chrome's state for the settings that need to be synced on each | 117 // Retrieves Chrome's state for the settings that need to be synced on each |
| 118 // Android boot and send it to Android. | 118 // Android boot and send it to Android. |
| 119 void SyncRuntimeSettings() const; | 119 void SyncRuntimeSettings() const; |
| 120 // Send settings that need to be synced only on Android first start to | 120 // Send settings that need to be synced only on Android first start to |
| 121 // Android. | 121 // Android. |
| 122 void SyncInitialSettings() const; | 122 void SyncInitialSettings() const; |
| 123 void SyncFocusHighlightEnabled() const; |
| 123 void SyncFontSize() const; | 124 void SyncFontSize() const; |
| 124 void SyncLocale() const; | 125 void SyncLocale() const; |
| 125 void SyncProxySettings() const; | 126 void SyncProxySettings() const; |
| 126 void SyncReportingConsent() const; | 127 void SyncReportingConsent() const; |
| 127 void SyncSpokenFeedbackEnabled() const; | 128 void SyncSpokenFeedbackEnabled() const; |
| 128 void SyncTimeZone() const; | 129 void SyncTimeZone() const; |
| 129 void SyncUse24HourClock() const; | 130 void SyncUse24HourClock() const; |
| 130 void SyncBackupEnabled() const; | 131 void SyncBackupEnabled() const; |
| 131 void SyncLocationServiceEnabled() const; | 132 void SyncLocationServiceEnabled() const; |
| 132 void SyncAccessibilityVirtualKeyboardEnabled() const; | 133 void SyncAccessibilityVirtualKeyboardEnabled() const; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); | 191 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); |
| 191 AddPrefToObserve(prefs::kWebKitDefaultFontSize); | 192 AddPrefToObserve(prefs::kWebKitDefaultFontSize); |
| 192 AddPrefToObserve(prefs::kWebKitMinimumFontSize); | 193 AddPrefToObserve(prefs::kWebKitMinimumFontSize); |
| 193 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); | 194 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); |
| 194 AddPrefToObserve(prefs::kUse24HourClock); | 195 AddPrefToObserve(prefs::kUse24HourClock); |
| 195 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); | 196 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); |
| 196 AddPrefToObserve(proxy_config::prefs::kProxy); | 197 AddPrefToObserve(proxy_config::prefs::kProxy); |
| 197 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); | 198 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); |
| 198 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); | 199 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); |
| 199 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); | 200 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); |
| 201 AddPrefToObserve(prefs::kAccessibilityFocusHighlightEnabled); |
| 200 | 202 |
| 201 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( | 203 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
| 202 chromeos::kStatsReportingPref, | 204 chromeos::kStatsReportingPref, |
| 203 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, | 205 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, |
| 204 base::Unretained(this))); | 206 base::Unretained(this))); |
| 205 | 207 |
| 206 TimezoneSettings::GetInstance()->AddObserver(this); | 208 TimezoneSettings::GetInstance()->AddObserver(this); |
| 207 | 209 |
| 208 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 210 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| 209 device::BluetoothAdapterFactory::GetAdapter( | 211 device::BluetoothAdapterFactory::GetAdapter( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 230 | 232 |
| 231 void ArcSettingsServiceImpl::SyncRuntimeSettings() const { | 233 void ArcSettingsServiceImpl::SyncRuntimeSettings() const { |
| 232 SyncFontSize(); | 234 SyncFontSize(); |
| 233 SyncLocale(); | 235 SyncLocale(); |
| 234 SyncProxySettings(); | 236 SyncProxySettings(); |
| 235 SyncReportingConsent(); | 237 SyncReportingConsent(); |
| 236 SyncSpokenFeedbackEnabled(); | 238 SyncSpokenFeedbackEnabled(); |
| 237 SyncTimeZone(); | 239 SyncTimeZone(); |
| 238 SyncUse24HourClock(); | 240 SyncUse24HourClock(); |
| 239 SyncAccessibilityVirtualKeyboardEnabled(); | 241 SyncAccessibilityVirtualKeyboardEnabled(); |
| 242 SyncFocusHighlightEnabled(); |
| 240 | 243 |
| 241 const PrefService* const prefs = | 244 const PrefService* const prefs = |
| 242 ProfileManager::GetActiveUserProfile()->GetPrefs(); | 245 ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 243 if (prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) | 246 if (prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) |
| 244 SyncBackupEnabled(); | 247 SyncBackupEnabled(); |
| 245 if (prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) | 248 if (prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) |
| 246 SyncLocationServiceEnabled(); | 249 SyncLocationServiceEnabled(); |
| 247 } | 250 } |
| 248 | 251 |
| 249 void ArcSettingsServiceImpl::SyncInitialSettings() const { | 252 void ArcSettingsServiceImpl::SyncInitialSettings() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 268 void ArcSettingsServiceImpl::AdapterPoweredChanged( | 271 void ArcSettingsServiceImpl::AdapterPoweredChanged( |
| 269 device::BluetoothAdapter* adapter, | 272 device::BluetoothAdapter* adapter, |
| 270 bool powered) { | 273 bool powered) { |
| 271 base::DictionaryValue extras; | 274 base::DictionaryValue extras; |
| 272 extras.SetBoolean("enable", powered); | 275 extras.SetBoolean("enable", powered); |
| 273 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", | 276 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", |
| 274 extras); | 277 extras); |
| 275 } | 278 } |
| 276 | 279 |
| 277 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { | 280 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { |
| 278 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { | 281 if (pref_name == prefs::kAccessibilityFocusHighlightEnabled) { |
| 282 SyncFocusHighlightEnabled(); |
| 283 } else if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { |
| 279 SyncSpokenFeedbackEnabled(); | 284 SyncSpokenFeedbackEnabled(); |
| 280 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || | 285 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || |
| 281 pref_name == prefs::kWebKitDefaultFontSize || | 286 pref_name == prefs::kWebKitDefaultFontSize || |
| 282 pref_name == prefs::kWebKitMinimumFontSize) { | 287 pref_name == prefs::kWebKitMinimumFontSize) { |
| 283 SyncFontSize(); | 288 SyncFontSize(); |
| 284 } else if (pref_name == prefs::kUse24HourClock) { | 289 } else if (pref_name == prefs::kUse24HourClock) { |
| 285 SyncUse24HourClock(); | 290 SyncUse24HourClock(); |
| 286 } else if (pref_name == proxy_config::prefs::kProxy) { | 291 } else if (pref_name == proxy_config::prefs::kProxy) { |
| 287 SyncProxySettings(); | 292 SyncProxySettings(); |
| 288 } else if (pref_name == onc::prefs::kDeviceOpenNetworkConfiguration || | 293 } else if (pref_name == onc::prefs::kDeviceOpenNetworkConfiguration || |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 DCHECK(pref); | 342 DCHECK(pref); |
| 338 bool enabled = false; | 343 bool enabled = false; |
| 339 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); | 344 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); |
| 340 DCHECK(value_exists); | 345 DCHECK(value_exists); |
| 341 base::DictionaryValue extras; | 346 base::DictionaryValue extras; |
| 342 extras.SetBoolean("enabled", enabled); | 347 extras.SetBoolean("enabled", enabled); |
| 343 extras.SetBoolean("managed", !pref->IsUserModifiable()); | 348 extras.SetBoolean("managed", !pref->IsUserModifiable()); |
| 344 SendSettingsBroadcast(action, extras); | 349 SendSettingsBroadcast(action, extras); |
| 345 } | 350 } |
| 346 | 351 |
| 352 void ArcSettingsServiceImpl::SyncFocusHighlightEnabled() const { |
| 353 SendBoolPrefSettingsBroadcast( |
| 354 prefs::kAccessibilityFocusHighlightEnabled, |
| 355 "org.chromium.arc.intent_helper.SET_FOCUS_HIGHLIGHT_ENABLED"); |
| 356 } |
| 357 |
| 347 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { | 358 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { |
| 348 SendBoolPrefSettingsBroadcast( | 359 SendBoolPrefSettingsBroadcast( |
| 349 prefs::kAccessibilitySpokenFeedbackEnabled, | 360 prefs::kAccessibilitySpokenFeedbackEnabled, |
| 350 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"); | 361 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"); |
| 351 } | 362 } |
| 352 | 363 |
| 353 void ArcSettingsServiceImpl::SyncLocale() const { | 364 void ArcSettingsServiceImpl::SyncLocale() const { |
| 354 const PrefService::Preference* pref = | 365 const PrefService::Preference* pref = |
| 355 registrar_.prefs()->FindPreference(prefs::kApplicationLocale); | 366 registrar_.prefs()->FindPreference(prefs::kApplicationLocale); |
| 356 DCHECK(pref); | 367 DCHECK(pref); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 515 |
| 505 void ArcSettingsService::OnInstanceReady() { | 516 void ArcSettingsService::OnInstanceReady() { |
| 506 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); | 517 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); |
| 507 } | 518 } |
| 508 | 519 |
| 509 void ArcSettingsService::OnInstanceClosed() { | 520 void ArcSettingsService::OnInstanceClosed() { |
| 510 impl_.reset(); | 521 impl_.reset(); |
| 511 } | 522 } |
| 512 | 523 |
| 513 } // namespace arc | 524 } // namespace arc |
| OLD | NEW |