| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 arc_session_manager->RemoveObserver(this); | 179 arc_session_manager->RemoveObserver(this); |
| 179 | 180 |
| 180 if (bluetooth_adapter_) | 181 if (bluetooth_adapter_) |
| 181 bluetooth_adapter_->RemoveObserver(this); | 182 bluetooth_adapter_->RemoveObserver(this); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void ArcSettingsServiceImpl::StartObservingSettingsChanges() { | 185 void ArcSettingsServiceImpl::StartObservingSettingsChanges() { |
| 185 Profile* profile = ProfileManager::GetActiveUserProfile(); | 186 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 186 registrar_.Init(profile->GetPrefs()); | 187 registrar_.Init(profile->GetPrefs()); |
| 187 | 188 |
| 189 // Keep these lines ordered lexicographically. |
| 190 AddPrefToObserve(prefs::kAccessibilityFocusHighlightEnabled); |
| 191 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); |
| 192 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); |
| 193 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); |
| 194 AddPrefToObserve(prefs::kUse24HourClock); |
| 188 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); | 195 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); |
| 189 AddPrefToObserve(prefs::kWebKitDefaultFontSize); | 196 AddPrefToObserve(prefs::kWebKitDefaultFontSize); |
| 190 AddPrefToObserve(prefs::kWebKitMinimumFontSize); | 197 AddPrefToObserve(prefs::kWebKitMinimumFontSize); |
| 191 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); | |
| 192 AddPrefToObserve(prefs::kUse24HourClock); | |
| 193 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); | |
| 194 AddPrefToObserve(proxy_config::prefs::kProxy); | 198 AddPrefToObserve(proxy_config::prefs::kProxy); |
| 195 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); | 199 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); |
| 196 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); | 200 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); |
| 197 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); | |
| 198 | 201 |
| 199 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( | 202 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
| 200 chromeos::kStatsReportingPref, | 203 chromeos::kStatsReportingPref, |
| 201 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, | 204 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, |
| 202 base::Unretained(this))); | 205 base::Unretained(this))); |
| 203 | 206 |
| 204 TimezoneSettings::GetInstance()->AddObserver(this); | 207 TimezoneSettings::GetInstance()->AddObserver(this); |
| 205 | 208 |
| 206 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 209 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| 207 device::BluetoothAdapterFactory::GetAdapter( | 210 device::BluetoothAdapterFactory::GetAdapter( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 220 bluetooth_adapter_->AddObserver(this); | 223 bluetooth_adapter_->AddObserver(this); |
| 221 | 224 |
| 222 AdapterPoweredChanged(adapter.get(), adapter->IsPowered()); | 225 AdapterPoweredChanged(adapter.get(), adapter->IsPowered()); |
| 223 } | 226 } |
| 224 | 227 |
| 225 void ArcSettingsServiceImpl::OnArcInitialStart() { | 228 void ArcSettingsServiceImpl::OnArcInitialStart() { |
| 226 SyncInitialSettings(); | 229 SyncInitialSettings(); |
| 227 } | 230 } |
| 228 | 231 |
| 229 void ArcSettingsServiceImpl::SyncRuntimeSettings() const { | 232 void ArcSettingsServiceImpl::SyncRuntimeSettings() const { |
| 233 // Keep these lines ordered lexicographically. |
| 234 SyncAccessibilityVirtualKeyboardEnabled(); |
| 235 SyncFocusHighlightEnabled(); |
| 230 SyncFontSize(); | 236 SyncFontSize(); |
| 231 SyncLocale(); | 237 SyncLocale(); |
| 232 SyncProxySettings(); | 238 SyncProxySettings(); |
| 233 SyncReportingConsent(); | 239 SyncReportingConsent(); |
| 234 SyncSpokenFeedbackEnabled(); | 240 SyncSpokenFeedbackEnabled(); |
| 235 SyncTimeZone(); | 241 SyncTimeZone(); |
| 236 SyncUse24HourClock(); | 242 SyncUse24HourClock(); |
| 237 SyncAccessibilityVirtualKeyboardEnabled(); | |
| 238 | 243 |
| 239 const PrefService* const prefs = | 244 const PrefService* const prefs = |
| 240 ProfileManager::GetActiveUserProfile()->GetPrefs(); | 245 ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 241 if (prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) | 246 if (prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) |
| 242 SyncBackupEnabled(); | 247 SyncBackupEnabled(); |
| 243 if (prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) | 248 if (prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) |
| 244 SyncLocationServiceEnabled(); | 249 SyncLocationServiceEnabled(); |
| 245 } | 250 } |
| 246 | 251 |
| 247 void ArcSettingsServiceImpl::SyncInitialSettings() const { | 252 void ArcSettingsServiceImpl::SyncInitialSettings() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 266 void ArcSettingsServiceImpl::AdapterPoweredChanged( | 271 void ArcSettingsServiceImpl::AdapterPoweredChanged( |
| 267 device::BluetoothAdapter* adapter, | 272 device::BluetoothAdapter* adapter, |
| 268 bool powered) { | 273 bool powered) { |
| 269 base::DictionaryValue extras; | 274 base::DictionaryValue extras; |
| 270 extras.SetBoolean("enable", powered); | 275 extras.SetBoolean("enable", powered); |
| 271 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", | 276 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", |
| 272 extras); | 277 extras); |
| 273 } | 278 } |
| 274 | 279 |
| 275 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { | 280 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { |
| 276 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { | 281 if (pref_name == prefs::kAccessibilityFocusHighlightEnabled) { |
| 282 SyncFocusHighlightEnabled(); |
| 283 } else if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { |
| 277 SyncSpokenFeedbackEnabled(); | 284 SyncSpokenFeedbackEnabled(); |
| 278 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || | 285 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || |
| 279 pref_name == prefs::kWebKitDefaultFontSize || | 286 pref_name == prefs::kWebKitDefaultFontSize || |
| 280 pref_name == prefs::kWebKitMinimumFontSize) { | 287 pref_name == prefs::kWebKitMinimumFontSize) { |
| 281 SyncFontSize(); | 288 SyncFontSize(); |
| 282 } else if (pref_name == prefs::kUse24HourClock) { | 289 } else if (pref_name == prefs::kUse24HourClock) { |
| 283 SyncUse24HourClock(); | 290 SyncUse24HourClock(); |
| 284 } else if (pref_name == proxy_config::prefs::kProxy) { | 291 } else if (pref_name == proxy_config::prefs::kProxy) { |
| 285 SyncProxySettings(); | 292 SyncProxySettings(); |
| 286 } 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... |
| 335 DCHECK(pref); | 342 DCHECK(pref); |
| 336 bool enabled = false; | 343 bool enabled = false; |
| 337 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); | 344 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); |
| 338 DCHECK(value_exists); | 345 DCHECK(value_exists); |
| 339 base::DictionaryValue extras; | 346 base::DictionaryValue extras; |
| 340 extras.SetBoolean("enabled", enabled); | 347 extras.SetBoolean("enabled", enabled); |
| 341 extras.SetBoolean("managed", !pref->IsUserModifiable()); | 348 extras.SetBoolean("managed", !pref->IsUserModifiable()); |
| 342 SendSettingsBroadcast(action, extras); | 349 SendSettingsBroadcast(action, extras); |
| 343 } | 350 } |
| 344 | 351 |
| 352 void ArcSettingsServiceImpl::SyncFocusHighlightEnabled() const { |
| 353 SendBoolPrefSettingsBroadcast( |
| 354 prefs::kAccessibilityFocusHighlightEnabled, |
| 355 "org.chromium.arc.intent_helper.SET_FOCUS_HIGHLIGHT_ENABLED"); |
| 356 } |
| 357 |
| 345 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { | 358 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { |
| 346 SendBoolPrefSettingsBroadcast( | 359 SendBoolPrefSettingsBroadcast( |
| 347 prefs::kAccessibilitySpokenFeedbackEnabled, | 360 prefs::kAccessibilitySpokenFeedbackEnabled, |
| 348 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"); | 361 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"); |
| 349 } | 362 } |
| 350 | 363 |
| 351 void ArcSettingsServiceImpl::SyncLocale() const { | 364 void ArcSettingsServiceImpl::SyncLocale() const { |
| 352 const PrefService::Preference* pref = | 365 const PrefService::Preference* pref = |
| 353 registrar_.prefs()->FindPreference(prefs::kApplicationLocale); | 366 registrar_.prefs()->FindPreference(prefs::kApplicationLocale); |
| 354 DCHECK(pref); | 367 DCHECK(pref); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 515 |
| 503 void ArcSettingsService::OnInstanceReady() { | 516 void ArcSettingsService::OnInstanceReady() { |
| 504 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); | 517 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); |
| 505 } | 518 } |
| 506 | 519 |
| 507 void ArcSettingsService::OnInstanceClosed() { | 520 void ArcSettingsService::OnInstanceClosed() { |
| 508 impl_.reset(); | 521 impl_.reset(); |
| 509 } | 522 } |
| 510 | 523 |
| 511 } // namespace arc | 524 } // namespace arc |
| OLD | NEW |