Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 111 |
| 112 // Stops listening for Chrome settings changes. | 112 // Stops listening for Chrome settings changes. |
| 113 void StopObservingSettingsChanges(); | 113 void StopObservingSettingsChanges(); |
| 114 | 114 |
| 115 // Retrieves Chrome's state for the settings that need to be synced on each | 115 // Retrieves Chrome's state for the settings that need to be synced on each |
| 116 // Android boot and send it to Android. | 116 // Android boot and send it to Android. |
| 117 void SyncRuntimeSettings() const; | 117 void SyncRuntimeSettings() const; |
| 118 // Send settings that need to be synced only on Android first start to | 118 // Send settings that need to be synced only on Android first start to |
| 119 // Android. | 119 // Android. |
| 120 void SyncInitialSettings() const; | 120 void SyncInitialSettings() const; |
| 121 void SyncFocusHighlightEnabled() const; | |
| 121 void SyncFontSize() const; | 122 void SyncFontSize() const; |
| 122 void SyncLocale() const; | 123 void SyncLocale() const; |
| 123 void SyncProxySettings() const; | 124 void SyncProxySettings() const; |
| 124 void SyncReportingConsent() const; | 125 void SyncReportingConsent() const; |
| 125 void SyncSpokenFeedbackEnabled() const; | 126 void SyncSpokenFeedbackEnabled() const; |
| 126 void SyncTimeZone() const; | 127 void SyncTimeZone() const; |
| 127 void SyncUse24HourClock() const; | 128 void SyncUse24HourClock() const; |
| 128 void SyncBackupEnabled() const; | 129 void SyncBackupEnabled() const; |
| 129 void SyncLocationServiceEnabled() const; | 130 void SyncLocationServiceEnabled() const; |
| 130 void SyncAccessibilityVirtualKeyboardEnabled() const; | 131 void SyncAccessibilityVirtualKeyboardEnabled() const; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); | 189 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); |
| 189 AddPrefToObserve(prefs::kWebKitDefaultFontSize); | 190 AddPrefToObserve(prefs::kWebKitDefaultFontSize); |
| 190 AddPrefToObserve(prefs::kWebKitMinimumFontSize); | 191 AddPrefToObserve(prefs::kWebKitMinimumFontSize); |
| 191 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); | 192 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); |
| 192 AddPrefToObserve(prefs::kUse24HourClock); | 193 AddPrefToObserve(prefs::kUse24HourClock); |
| 193 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); | 194 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); |
| 194 AddPrefToObserve(proxy_config::prefs::kProxy); | 195 AddPrefToObserve(proxy_config::prefs::kProxy); |
| 195 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); | 196 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); |
| 196 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); | 197 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); |
| 197 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); | 198 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); |
| 199 AddPrefToObserve(prefs::kAccessibilityFocusHighlightEnabled); | |
|
Luis Héctor Chávez
2017/01/19 17:17:56
nit: Can you sort these lexicographically?
yawano
2017/01/20 06:52:31
Done.
| |
| 198 | 200 |
| 199 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( | 201 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
| 200 chromeos::kStatsReportingPref, | 202 chromeos::kStatsReportingPref, |
| 201 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, | 203 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, |
| 202 base::Unretained(this))); | 204 base::Unretained(this))); |
| 203 | 205 |
| 204 TimezoneSettings::GetInstance()->AddObserver(this); | 206 TimezoneSettings::GetInstance()->AddObserver(this); |
| 205 | 207 |
| 206 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 208 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| 207 device::BluetoothAdapterFactory::GetAdapter( | 209 device::BluetoothAdapterFactory::GetAdapter( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 228 | 230 |
| 229 void ArcSettingsServiceImpl::SyncRuntimeSettings() const { | 231 void ArcSettingsServiceImpl::SyncRuntimeSettings() const { |
| 230 SyncFontSize(); | 232 SyncFontSize(); |
| 231 SyncLocale(); | 233 SyncLocale(); |
| 232 SyncProxySettings(); | 234 SyncProxySettings(); |
| 233 SyncReportingConsent(); | 235 SyncReportingConsent(); |
| 234 SyncSpokenFeedbackEnabled(); | 236 SyncSpokenFeedbackEnabled(); |
| 235 SyncTimeZone(); | 237 SyncTimeZone(); |
| 236 SyncUse24HourClock(); | 238 SyncUse24HourClock(); |
| 237 SyncAccessibilityVirtualKeyboardEnabled(); | 239 SyncAccessibilityVirtualKeyboardEnabled(); |
| 240 SyncFocusHighlightEnabled(); | |
|
Luis Héctor Chávez
2017/01/19 17:17:56
nit: sort lexicographically
yawano
2017/01/20 06:52:31
Done.
| |
| 238 | 241 |
| 239 const PrefService* const prefs = | 242 const PrefService* const prefs = |
| 240 ProfileManager::GetActiveUserProfile()->GetPrefs(); | 243 ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 241 if (prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) | 244 if (prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) |
| 242 SyncBackupEnabled(); | 245 SyncBackupEnabled(); |
| 243 if (prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) | 246 if (prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) |
| 244 SyncLocationServiceEnabled(); | 247 SyncLocationServiceEnabled(); |
| 245 } | 248 } |
| 246 | 249 |
| 247 void ArcSettingsServiceImpl::SyncInitialSettings() const { | 250 void ArcSettingsServiceImpl::SyncInitialSettings() const { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 266 void ArcSettingsServiceImpl::AdapterPoweredChanged( | 269 void ArcSettingsServiceImpl::AdapterPoweredChanged( |
| 267 device::BluetoothAdapter* adapter, | 270 device::BluetoothAdapter* adapter, |
| 268 bool powered) { | 271 bool powered) { |
| 269 base::DictionaryValue extras; | 272 base::DictionaryValue extras; |
| 270 extras.SetBoolean("enable", powered); | 273 extras.SetBoolean("enable", powered); |
| 271 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", | 274 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", |
| 272 extras); | 275 extras); |
| 273 } | 276 } |
| 274 | 277 |
| 275 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { | 278 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { |
| 276 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { | 279 if (pref_name == prefs::kAccessibilityFocusHighlightEnabled) { |
| 280 SyncFocusHighlightEnabled(); | |
| 281 } else if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { | |
| 277 SyncSpokenFeedbackEnabled(); | 282 SyncSpokenFeedbackEnabled(); |
| 278 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || | 283 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || |
| 279 pref_name == prefs::kWebKitDefaultFontSize || | 284 pref_name == prefs::kWebKitDefaultFontSize || |
| 280 pref_name == prefs::kWebKitMinimumFontSize) { | 285 pref_name == prefs::kWebKitMinimumFontSize) { |
| 281 SyncFontSize(); | 286 SyncFontSize(); |
| 282 } else if (pref_name == prefs::kUse24HourClock) { | 287 } else if (pref_name == prefs::kUse24HourClock) { |
| 283 SyncUse24HourClock(); | 288 SyncUse24HourClock(); |
| 284 } else if (pref_name == proxy_config::prefs::kProxy) { | 289 } else if (pref_name == proxy_config::prefs::kProxy) { |
| 285 SyncProxySettings(); | 290 SyncProxySettings(); |
| 286 } else if (pref_name == onc::prefs::kDeviceOpenNetworkConfiguration || | 291 } else if (pref_name == onc::prefs::kDeviceOpenNetworkConfiguration || |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 DCHECK(pref); | 340 DCHECK(pref); |
| 336 bool enabled = false; | 341 bool enabled = false; |
| 337 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); | 342 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); |
| 338 DCHECK(value_exists); | 343 DCHECK(value_exists); |
| 339 base::DictionaryValue extras; | 344 base::DictionaryValue extras; |
| 340 extras.SetBoolean("enabled", enabled); | 345 extras.SetBoolean("enabled", enabled); |
| 341 extras.SetBoolean("managed", !pref->IsUserModifiable()); | 346 extras.SetBoolean("managed", !pref->IsUserModifiable()); |
| 342 SendSettingsBroadcast(action, extras); | 347 SendSettingsBroadcast(action, extras); |
| 343 } | 348 } |
| 344 | 349 |
| 350 void ArcSettingsServiceImpl::SyncFocusHighlightEnabled() const { | |
| 351 SendBoolPrefSettingsBroadcast( | |
| 352 prefs::kAccessibilityFocusHighlightEnabled, | |
| 353 "org.chromium.arc.intent_helper.SET_FOCUS_HIGHLIGHT_ENABLED"); | |
| 354 } | |
| 355 | |
| 345 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { | 356 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { |
| 346 SendBoolPrefSettingsBroadcast( | 357 SendBoolPrefSettingsBroadcast( |
| 347 prefs::kAccessibilitySpokenFeedbackEnabled, | 358 prefs::kAccessibilitySpokenFeedbackEnabled, |
| 348 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"); | 359 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"); |
| 349 } | 360 } |
| 350 | 361 |
| 351 void ArcSettingsServiceImpl::SyncLocale() const { | 362 void ArcSettingsServiceImpl::SyncLocale() const { |
| 352 const PrefService::Preference* pref = | 363 const PrefService::Preference* pref = |
| 353 registrar_.prefs()->FindPreference(prefs::kApplicationLocale); | 364 registrar_.prefs()->FindPreference(prefs::kApplicationLocale); |
| 354 DCHECK(pref); | 365 DCHECK(pref); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 | 513 |
| 503 void ArcSettingsService::OnInstanceReady() { | 514 void ArcSettingsService::OnInstanceReady() { |
| 504 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); | 515 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); |
| 505 } | 516 } |
| 506 | 517 |
| 507 void ArcSettingsService::OnInstanceClosed() { | 518 void ArcSettingsService::OnInstanceClosed() { |
| 508 impl_.reset(); | 519 impl_.reset(); |
| 509 } | 520 } |
| 510 | 521 |
| 511 } // namespace arc | 522 } // namespace arc |
| OLD | NEW |