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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 14 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
15 #include "chrome/browser/chromeos/net/onc_utils.h" | 15 #include "chrome/browser/chromeos/net/onc_utils.h" |
16 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 16 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chromeos/network/network_handler.h" | 20 #include "chromeos/network/network_handler.h" |
21 #include "chromeos/network/network_state.h" | 21 #include "chromeos/network/network_state.h" |
22 #include "chromeos/network/network_state_handler.h" | 22 #include "chromeos/network/network_state_handler.h" |
23 #include "chromeos/network/network_state_handler_observer.h" | 23 #include "chromeos/network/network_state_handler_observer.h" |
24 #include "chromeos/settings/cros_settings_names.h" | 24 #include "chromeos/settings/cros_settings_names.h" |
25 #include "chromeos/settings/timezone_settings.h" | 25 #include "chromeos/settings/timezone_settings.h" |
26 #include "components/arc/arc_bridge_service.h" | 26 #include "components/arc/arc_bridge_service.h" |
27 #include "components/arc/intent_helper/font_size_util.h" | 27 #include "components/arc/intent_helper/font_size_util.h" |
| 28 #include "components/onc/onc_pref_names.h" |
28 #include "components/prefs/pref_change_registrar.h" | 29 #include "components/prefs/pref_change_registrar.h" |
29 #include "components/prefs/pref_service.h" | 30 #include "components/prefs/pref_service.h" |
30 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" | 31 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
31 #include "components/proxy_config/proxy_config_dictionary.h" | 32 #include "components/proxy_config/proxy_config_dictionary.h" |
32 #include "components/proxy_config/proxy_config_pref_names.h" | 33 #include "components/proxy_config/proxy_config_pref_names.h" |
33 #include "device/bluetooth/bluetooth_adapter.h" | 34 #include "device/bluetooth/bluetooth_adapter.h" |
34 #include "device/bluetooth/bluetooth_adapter_factory.h" | 35 #include "device/bluetooth/bluetooth_adapter_factory.h" |
35 #include "net/proxy/proxy_config.h" | 36 #include "net/proxy/proxy_config.h" |
36 | 37 |
37 using ::chromeos::CrosSettings; | 38 using ::chromeos::CrosSettings; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 Profile* profile = ProfileManager::GetActiveUserProfile(); | 188 Profile* profile = ProfileManager::GetActiveUserProfile(); |
188 registrar_.Init(profile->GetPrefs()); | 189 registrar_.Init(profile->GetPrefs()); |
189 | 190 |
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(prefs::kDeviceOpenNetworkConfiguration); | 198 AddPrefToObserve(onc::prefs::kDeviceOpenNetworkConfiguration); |
198 AddPrefToObserve(prefs::kOpenNetworkConfiguration); | 199 AddPrefToObserve(onc::prefs::kOpenNetworkConfiguration); |
199 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); | 200 AddPrefToObserve(prefs::kAccessibilityVirtualKeyboardEnabled); |
200 | 201 |
201 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( | 202 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
202 chromeos::kStatsReportingPref, | 203 chromeos::kStatsReportingPref, |
203 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, | 204 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, |
204 base::Unretained(this))); | 205 base::Unretained(this))); |
205 | 206 |
206 TimezoneSettings::GetInstance()->AddObserver(this); | 207 TimezoneSettings::GetInstance()->AddObserver(this); |
207 | 208 |
208 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 209 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { | 279 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { |
279 SyncSpokenFeedbackEnabled(); | 280 SyncSpokenFeedbackEnabled(); |
280 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || | 281 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || |
281 pref_name == prefs::kWebKitDefaultFontSize || | 282 pref_name == prefs::kWebKitDefaultFontSize || |
282 pref_name == prefs::kWebKitMinimumFontSize) { | 283 pref_name == prefs::kWebKitMinimumFontSize) { |
283 SyncFontSize(); | 284 SyncFontSize(); |
284 } else if (pref_name == prefs::kUse24HourClock) { | 285 } else if (pref_name == prefs::kUse24HourClock) { |
285 SyncUse24HourClock(); | 286 SyncUse24HourClock(); |
286 } else if (pref_name == proxy_config::prefs::kProxy) { | 287 } else if (pref_name == proxy_config::prefs::kProxy) { |
287 SyncProxySettings(); | 288 SyncProxySettings(); |
288 } else if (pref_name == prefs::kDeviceOpenNetworkConfiguration || | 289 } else if (pref_name == onc::prefs::kDeviceOpenNetworkConfiguration || |
289 pref_name == prefs::kOpenNetworkConfiguration) { | 290 pref_name == onc::prefs::kOpenNetworkConfiguration) { |
290 // Only update proxy settings if kProxy pref is not applied. | 291 // Only update proxy settings if kProxy pref is not applied. |
291 if (IsPrefProxyConfigApplied()) { | 292 if (IsPrefProxyConfigApplied()) { |
292 LOG(ERROR) << "Open Network Configuration proxy settings are not applied," | 293 LOG(ERROR) << "Open Network Configuration proxy settings are not applied," |
293 << " because kProxy preference is configured."; | 294 << " because kProxy preference is configured."; |
294 return; | 295 return; |
295 } | 296 } |
296 SyncProxySettings(); | 297 SyncProxySettings(); |
297 } else if (pref_name == prefs::kAccessibilityVirtualKeyboardEnabled) { | 298 } else if (pref_name == prefs::kAccessibilityVirtualKeyboardEnabled) { |
298 SyncAccessibilityVirtualKeyboardEnabled(); | 299 SyncAccessibilityVirtualKeyboardEnabled(); |
299 } else { | 300 } else { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 DCHECK(value_exists); | 389 DCHECK(value_exists); |
389 base::DictionaryValue extras; | 390 base::DictionaryValue extras; |
390 extras.SetBoolean("use24HourClock", use24HourClock); | 391 extras.SetBoolean("use24HourClock", use24HourClock); |
391 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_USE_24_HOUR_CLOCK", | 392 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_USE_24_HOUR_CLOCK", |
392 extras); | 393 extras); |
393 } | 394 } |
394 | 395 |
395 void ArcSettingsServiceImpl::SyncProxySettings() const { | 396 void ArcSettingsServiceImpl::SyncProxySettings() const { |
396 std::unique_ptr<ProxyConfigDictionary> proxy_config_dict = | 397 std::unique_ptr<ProxyConfigDictionary> proxy_config_dict = |
397 chromeos::ProxyConfigServiceImpl::GetActiveProxyConfigDictionary( | 398 chromeos::ProxyConfigServiceImpl::GetActiveProxyConfigDictionary( |
398 ProfileManager::GetActiveUserProfile()->GetPrefs()); | 399 ProfileManager::GetActiveUserProfile()->GetPrefs(), |
| 400 g_browser_process->local_state()); |
399 if (!proxy_config_dict) | 401 if (!proxy_config_dict) |
400 return; | 402 return; |
401 | 403 |
402 ProxyPrefs::ProxyMode mode; | 404 ProxyPrefs::ProxyMode mode; |
403 if (!proxy_config_dict || !proxy_config_dict->GetMode(&mode)) | 405 if (!proxy_config_dict || !proxy_config_dict->GetMode(&mode)) |
404 mode = ProxyPrefs::MODE_DIRECT; | 406 mode = ProxyPrefs::MODE_DIRECT; |
405 | 407 |
406 base::DictionaryValue extras; | 408 base::DictionaryValue extras; |
407 extras.SetString("mode", ProxyPrefs::ProxyModeToString(mode)); | 409 extras.SetString("mode", ProxyPrefs::ProxyModeToString(mode)); |
408 | 410 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 505 |
504 void ArcSettingsService::OnInstanceReady() { | 506 void ArcSettingsService::OnInstanceReady() { |
505 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); | 507 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); |
506 } | 508 } |
507 | 509 |
508 void ArcSettingsService::OnInstanceClosed() { | 510 void ArcSettingsService::OnInstanceClosed() { |
509 impl_.reset(); | 511 impl_.reset(); |
510 } | 512 } |
511 | 513 |
512 } // namespace arc | 514 } // namespace arc |
OLD | NEW |