| 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/arc_settings_service.h" | 5 #include "chrome/browser/chromeos/arc/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/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" |
| 16 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 14 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chromeos/network/network_handler.h" |
| 21 #include "chromeos/network/network_state.h" |
| 22 #include "chromeos/network/network_state_handler.h" |
| 23 #include "chromeos/network/network_state_handler_observer.h" |
| 17 #include "chromeos/settings/cros_settings_names.h" | 24 #include "chromeos/settings/cros_settings_names.h" |
| 18 #include "chromeos/settings/timezone_settings.h" | 25 #include "chromeos/settings/timezone_settings.h" |
| 19 #include "components/arc/intent_helper/font_size_util.h" | 26 #include "components/arc/intent_helper/font_size_util.h" |
| 20 #include "components/prefs/pref_change_registrar.h" | 27 #include "components/prefs/pref_change_registrar.h" |
| 21 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
| 29 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
| 22 #include "components/proxy_config/proxy_config_dictionary.h" | 30 #include "components/proxy_config/proxy_config_dictionary.h" |
| 23 #include "components/proxy_config/proxy_config_pref_names.h" | 31 #include "components/proxy_config/proxy_config_pref_names.h" |
| 24 #include "device/bluetooth/bluetooth_adapter.h" | 32 #include "device/bluetooth/bluetooth_adapter.h" |
| 25 #include "device/bluetooth/bluetooth_adapter_factory.h" | 33 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 26 #include "net/proxy/proxy_config.h" | 34 #include "net/proxy/proxy_config.h" |
| 27 | 35 |
| 28 using ::chromeos::CrosSettings; | 36 using ::chromeos::CrosSettings; |
| 29 using ::chromeos::system::TimezoneSettings; | 37 using ::chromeos::system::TimezoneSettings; |
| 30 | 38 |
| 31 namespace { | 39 namespace { |
| 32 | 40 |
| 33 bool GetHttpProxyServer(const ProxyConfigDictionary& proxy_config_dict, | 41 bool GetHttpProxyServer(const ProxyConfigDictionary* proxy_config_dict, |
| 34 std::string* host, | 42 std::string* host, |
| 35 int* port) { | 43 int* port) { |
| 36 std::string proxy_rules_string; | 44 std::string proxy_rules_string; |
| 37 if (!proxy_config_dict.GetProxyServer(&proxy_rules_string)) | 45 if (!proxy_config_dict->GetProxyServer(&proxy_rules_string)) |
| 38 return false; | 46 return false; |
| 39 | 47 |
| 40 net::ProxyConfig::ProxyRules proxy_rules; | 48 net::ProxyConfig::ProxyRules proxy_rules; |
| 41 proxy_rules.ParseFromString(proxy_rules_string); | 49 proxy_rules.ParseFromString(proxy_rules_string); |
| 42 | 50 |
| 43 const net::ProxyList* proxy_list = nullptr; | 51 const net::ProxyList* proxy_list = nullptr; |
| 44 if (proxy_rules.type == net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY) { | 52 if (proxy_rules.type == net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY) { |
| 45 proxy_list = &proxy_rules.single_proxies; | 53 proxy_list = &proxy_rules.single_proxies; |
| 46 } else if (proxy_rules.type == | 54 } else if (proxy_rules.type == |
| 47 net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME) { | 55 net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME) { |
| 48 proxy_list = proxy_rules.MapUrlSchemeToProxyList(url::kHttpScheme); | 56 proxy_list = proxy_rules.MapUrlSchemeToProxyList(url::kHttpScheme); |
| 49 } | 57 } |
| 50 if (!proxy_list || proxy_list->IsEmpty()) | 58 if (!proxy_list || proxy_list->IsEmpty()) |
| 51 return false; | 59 return false; |
| 52 | 60 |
| 53 const net::ProxyServer& server = proxy_list->Get(); | 61 const net::ProxyServer& server = proxy_list->Get(); |
| 54 *host = server.host_port_pair().host(); | 62 *host = server.host_port_pair().host(); |
| 55 *port = server.host_port_pair().port(); | 63 *port = server.host_port_pair().port(); |
| 56 return !host->empty() && *port; | 64 return !host->empty() && *port; |
| 57 } | 65 } |
| 58 | 66 |
| 67 // Returns whether kProxy pref proxy config is applied. |
| 68 bool IsPrefProxyConfigApplied() { |
| 69 net::ProxyConfig config; |
| 70 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 71 return PrefProxyConfigTrackerImpl::PrefPrecedes( |
| 72 PrefProxyConfigTrackerImpl::ReadPrefConfig(profile->GetPrefs(), &config)); |
| 73 } |
| 74 |
| 59 } // namespace | 75 } // namespace |
| 60 | 76 |
| 61 namespace arc { | 77 namespace arc { |
| 62 | 78 |
| 63 // Listens to changes for select Chrome settings (prefs) that Android cares | 79 // Listens to changes for select Chrome settings (prefs) that Android cares |
| 64 // about and sends the new values to Android to keep the state in sync. | 80 // about and sends the new values to Android to keep the state in sync. |
| 65 class ArcSettingsServiceImpl | 81 class ArcSettingsServiceImpl |
| 66 : public chromeos::system::TimezoneSettings::Observer, | 82 : public chromeos::system::TimezoneSettings::Observer, |
| 67 public device::BluetoothAdapter::Observer, | 83 public device::BluetoothAdapter::Observer, |
| 68 public ArcAuthService::Observer { | 84 public ArcAuthService::Observer, |
| 85 public chromeos::NetworkStateHandlerObserver { |
| 69 public: | 86 public: |
| 70 explicit ArcSettingsServiceImpl(ArcBridgeService* arc_bridge_service); | 87 explicit ArcSettingsServiceImpl(ArcBridgeService* arc_bridge_service); |
| 71 ~ArcSettingsServiceImpl() override; | 88 ~ArcSettingsServiceImpl() override; |
| 72 | 89 |
| 73 // Called when a Chrome pref we have registered an observer for has changed. | 90 // Called when a Chrome pref we have registered an observer for has changed. |
| 74 // Obtains the new pref value and sends it to Android. | 91 // Obtains the new pref value and sends it to Android. |
| 75 void OnPrefChanged(const std::string& pref_name) const; | 92 void OnPrefChanged(const std::string& pref_name) const; |
| 76 | 93 |
| 77 // TimezoneSettings::Observer: | 94 // TimezoneSettings::Observer: |
| 78 void TimezoneChanged(const icu::TimeZone& timezone) override; | 95 void TimezoneChanged(const icu::TimeZone& timezone) override; |
| 79 | 96 |
| 80 // BluetoothAdapter::Observer: | 97 // BluetoothAdapter::Observer: |
| 81 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | 98 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
| 82 bool powered) override; | 99 bool powered) override; |
| 83 | 100 |
| 84 // ArcAuthService::Observer: | 101 // ArcAuthService::Observer: |
| 85 void OnInitialStart() override; | 102 void OnInitialStart() override; |
| 86 | 103 |
| 104 // NetworkStateHandlerObserver: |
| 105 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; |
| 106 |
| 87 private: | 107 private: |
| 88 // Registers to observe changes for Chrome settings we care about. | 108 // Registers to observe changes for Chrome settings we care about. |
| 89 void StartObservingSettingsChanges(); | 109 void StartObservingSettingsChanges(); |
| 90 | 110 |
| 91 // Stops listening for Chrome settings changes. | 111 // Stops listening for Chrome settings changes. |
| 92 void StopObservingSettingsChanges(); | 112 void StopObservingSettingsChanges(); |
| 93 | 113 |
| 94 // Retrieves Chrome's state for the settings that need to be synced on each | 114 // Retrieves Chrome's state for the settings that need to be synced on each |
| 95 // Android boot and send it to Android. | 115 // Android boot and send it to Android. |
| 96 void SyncRuntimeSettings() const; | 116 void SyncRuntimeSettings() const; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 181 |
| 162 void ArcSettingsServiceImpl::StartObservingSettingsChanges() { | 182 void ArcSettingsServiceImpl::StartObservingSettingsChanges() { |
| 163 Profile* profile = ProfileManager::GetActiveUserProfile(); | 183 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 164 registrar_.Init(profile->GetPrefs()); | 184 registrar_.Init(profile->GetPrefs()); |
| 165 | 185 |
| 166 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); | 186 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); |
| 167 AddPrefToObserve(prefs::kWebKitDefaultFontSize); | 187 AddPrefToObserve(prefs::kWebKitDefaultFontSize); |
| 168 AddPrefToObserve(prefs::kWebKitMinimumFontSize); | 188 AddPrefToObserve(prefs::kWebKitMinimumFontSize); |
| 169 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); | 189 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); |
| 170 AddPrefToObserve(prefs::kUse24HourClock); | 190 AddPrefToObserve(prefs::kUse24HourClock); |
| 191 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); |
| 171 AddPrefToObserve(proxy_config::prefs::kProxy); | 192 AddPrefToObserve(proxy_config::prefs::kProxy); |
| 172 AddPrefToObserve(prefs::kArcBackupRestoreEnabled); | 193 AddPrefToObserve(prefs::kDeviceOpenNetworkConfiguration); |
| 194 AddPrefToObserve(prefs::kOpenNetworkConfiguration); |
| 173 | 195 |
| 174 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( | 196 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
| 175 chromeos::kStatsReportingPref, | 197 chromeos::kStatsReportingPref, |
| 176 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, | 198 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, |
| 177 base::Unretained(this))); | 199 base::Unretained(this))); |
| 178 | 200 |
| 179 TimezoneSettings::GetInstance()->AddObserver(this); | 201 TimezoneSettings::GetInstance()->AddObserver(this); |
| 180 | 202 |
| 181 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 203 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| 182 device::BluetoothAdapterFactory::GetAdapter( | 204 device::BluetoothAdapterFactory::GetAdapter( |
| 183 base::Bind(&ArcSettingsServiceImpl::OnBluetoothAdapterInitialized, | 205 base::Bind(&ArcSettingsServiceImpl::OnBluetoothAdapterInitialized, |
| 184 weak_factory_.GetWeakPtr())); | 206 weak_factory_.GetWeakPtr())); |
| 185 } | 207 } |
| 208 |
| 209 chromeos::NetworkHandler::Get()->network_state_handler()->AddObserver( |
| 210 this, FROM_HERE); |
| 186 } | 211 } |
| 187 | 212 |
| 188 void ArcSettingsServiceImpl::OnBluetoothAdapterInitialized( | 213 void ArcSettingsServiceImpl::OnBluetoothAdapterInitialized( |
| 189 scoped_refptr<device::BluetoothAdapter> adapter) { | 214 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 190 DCHECK(adapter); | 215 DCHECK(adapter); |
| 191 bluetooth_adapter_ = adapter; | 216 bluetooth_adapter_ = adapter; |
| 192 bluetooth_adapter_->AddObserver(this); | 217 bluetooth_adapter_->AddObserver(this); |
| 193 | 218 |
| 194 AdapterPoweredChanged(adapter.get(), adapter->IsPowered()); | 219 AdapterPoweredChanged(adapter.get(), adapter->IsPowered()); |
| 195 } | 220 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 218 void ArcSettingsServiceImpl::SyncInitialSettings() const { | 243 void ArcSettingsServiceImpl::SyncInitialSettings() const { |
| 219 SyncBackupEnabled(); | 244 SyncBackupEnabled(); |
| 220 SyncLocationServiceEnabled(); | 245 SyncLocationServiceEnabled(); |
| 221 } | 246 } |
| 222 | 247 |
| 223 void ArcSettingsServiceImpl::StopObservingSettingsChanges() { | 248 void ArcSettingsServiceImpl::StopObservingSettingsChanges() { |
| 224 registrar_.RemoveAll(); | 249 registrar_.RemoveAll(); |
| 225 reporting_consent_subscription_.reset(); | 250 reporting_consent_subscription_.reset(); |
| 226 | 251 |
| 227 TimezoneSettings::GetInstance()->RemoveObserver(this); | 252 TimezoneSettings::GetInstance()->RemoveObserver(this); |
| 253 chromeos::NetworkHandler::Get()->network_state_handler()->RemoveObserver( |
| 254 this, FROM_HERE); |
| 228 } | 255 } |
| 229 | 256 |
| 230 void ArcSettingsServiceImpl::AddPrefToObserve(const std::string& pref_name) { | 257 void ArcSettingsServiceImpl::AddPrefToObserve(const std::string& pref_name) { |
| 231 registrar_.Add(pref_name, base::Bind(&ArcSettingsServiceImpl::OnPrefChanged, | 258 registrar_.Add(pref_name, base::Bind(&ArcSettingsServiceImpl::OnPrefChanged, |
| 232 base::Unretained(this))); | 259 base::Unretained(this))); |
| 233 } | 260 } |
| 234 | 261 |
| 235 void ArcSettingsServiceImpl::AdapterPoweredChanged( | 262 void ArcSettingsServiceImpl::AdapterPoweredChanged( |
| 236 device::BluetoothAdapter* adapter, | 263 device::BluetoothAdapter* adapter, |
| 237 bool powered) { | 264 bool powered) { |
| 238 base::DictionaryValue extras; | 265 base::DictionaryValue extras; |
| 239 extras.SetBoolean("enable", powered); | 266 extras.SetBoolean("enable", powered); |
| 240 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", | 267 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BLUETOOTH_STATE", |
| 241 extras); | 268 extras); |
| 242 } | 269 } |
| 243 | 270 |
| 244 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { | 271 void ArcSettingsServiceImpl::OnPrefChanged(const std::string& pref_name) const { |
| 245 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { | 272 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { |
| 246 SyncSpokenFeedbackEnabled(); | 273 SyncSpokenFeedbackEnabled(); |
| 247 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || | 274 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || |
| 248 pref_name == prefs::kWebKitDefaultFontSize || | 275 pref_name == prefs::kWebKitDefaultFontSize || |
| 249 pref_name == prefs::kWebKitMinimumFontSize) { | 276 pref_name == prefs::kWebKitMinimumFontSize) { |
| 250 SyncFontSize(); | 277 SyncFontSize(); |
| 251 } else if (pref_name == prefs::kUse24HourClock) { | 278 } else if (pref_name == prefs::kUse24HourClock) { |
| 252 SyncUse24HourClock(); | 279 SyncUse24HourClock(); |
| 253 } else if (pref_name == proxy_config::prefs::kProxy) { | 280 } else if (pref_name == proxy_config::prefs::kProxy) { |
| 254 SyncProxySettings(); | 281 SyncProxySettings(); |
| 282 } else if (pref_name == prefs::kDeviceOpenNetworkConfiguration || |
| 283 pref_name == prefs::kOpenNetworkConfiguration) { |
| 284 // Only update proxy settings if kProxy pref is not applied. |
| 285 if (IsPrefProxyConfigApplied()) { |
| 286 LOG(ERROR) << "Open Network Configuration proxy settings are not applied," |
| 287 << " because kProxy preference is configured."; |
| 288 return; |
| 289 } |
| 290 SyncProxySettings(); |
| 255 } else { | 291 } else { |
| 256 LOG(ERROR) << "Unknown pref changed."; | 292 LOG(ERROR) << "Unknown pref changed."; |
| 257 } | 293 } |
| 258 } | 294 } |
| 259 | 295 |
| 260 void ArcSettingsServiceImpl::TimezoneChanged(const icu::TimeZone& timezone) { | 296 void ArcSettingsServiceImpl::TimezoneChanged(const icu::TimeZone& timezone) { |
| 261 SyncTimeZone(); | 297 SyncTimeZone(); |
| 262 } | 298 } |
| 263 | 299 |
| 264 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const { | 300 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 bool use24HourClock = false; | 378 bool use24HourClock = false; |
| 343 bool value_exists = pref->GetValue()->GetAsBoolean(&use24HourClock); | 379 bool value_exists = pref->GetValue()->GetAsBoolean(&use24HourClock); |
| 344 DCHECK(value_exists); | 380 DCHECK(value_exists); |
| 345 base::DictionaryValue extras; | 381 base::DictionaryValue extras; |
| 346 extras.SetBoolean("use24HourClock", use24HourClock); | 382 extras.SetBoolean("use24HourClock", use24HourClock); |
| 347 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_USE_24_HOUR_CLOCK", | 383 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_USE_24_HOUR_CLOCK", |
| 348 extras); | 384 extras); |
| 349 } | 385 } |
| 350 | 386 |
| 351 void ArcSettingsServiceImpl::SyncProxySettings() const { | 387 void ArcSettingsServiceImpl::SyncProxySettings() const { |
| 352 const PrefService::Preference* const pref = | 388 std::unique_ptr<ProxyConfigDictionary> proxy_config_dict = |
| 353 registrar_.prefs()->FindPreference(proxy_config::prefs::kProxy); | 389 chromeos::ProxyConfigServiceImpl::GetActiveProxyConfigDictionary( |
| 354 const base::DictionaryValue* proxy_config_value; | 390 ProfileManager::GetActiveUserProfile()->GetPrefs()); |
| 355 bool value_exists = pref->GetValue()->GetAsDictionary(&proxy_config_value); | 391 if (!proxy_config_dict) |
| 356 DCHECK(value_exists); | 392 return; |
| 357 | |
| 358 ProxyConfigDictionary proxy_config_dict(proxy_config_value); | |
| 359 | 393 |
| 360 ProxyPrefs::ProxyMode mode; | 394 ProxyPrefs::ProxyMode mode; |
| 361 if (!proxy_config_dict.GetMode(&mode)) | 395 if (!proxy_config_dict || !proxy_config_dict->GetMode(&mode)) |
| 362 mode = ProxyPrefs::MODE_DIRECT; | 396 mode = ProxyPrefs::MODE_DIRECT; |
| 363 | 397 |
| 364 base::DictionaryValue extras; | 398 base::DictionaryValue extras; |
| 365 extras.SetString("mode", ProxyPrefs::ProxyModeToString(mode)); | 399 extras.SetString("mode", ProxyPrefs::ProxyModeToString(mode)); |
| 366 | 400 |
| 367 switch (mode) { | 401 switch (mode) { |
| 368 case ProxyPrefs::MODE_DIRECT: | 402 case ProxyPrefs::MODE_DIRECT: |
| 369 break; | 403 break; |
| 370 case ProxyPrefs::MODE_SYSTEM: | 404 case ProxyPrefs::MODE_SYSTEM: |
| 371 VLOG(1) << "The system mode is not translated."; | 405 VLOG(1) << "The system mode is not translated."; |
| 372 return; | 406 return; |
| 373 case ProxyPrefs::MODE_AUTO_DETECT: | 407 case ProxyPrefs::MODE_AUTO_DETECT: |
| 374 extras.SetString("pacUrl", "http://wpad/wpad.dat"); | 408 extras.SetString("pacUrl", "http://wpad/wpad.dat"); |
| 375 break; | 409 break; |
| 376 case ProxyPrefs::MODE_PAC_SCRIPT: { | 410 case ProxyPrefs::MODE_PAC_SCRIPT: { |
| 377 std::string pac_url; | 411 std::string pac_url; |
| 378 if (!proxy_config_dict.GetPacUrl(&pac_url)) { | 412 if (!proxy_config_dict->GetPacUrl(&pac_url)) { |
| 379 LOG(ERROR) << "No pac URL for pac_script proxy mode."; | 413 LOG(ERROR) << "No pac URL for pac_script proxy mode."; |
| 380 return; | 414 return; |
| 381 } | 415 } |
| 382 extras.SetString("pacUrl", pac_url); | 416 extras.SetString("pacUrl", pac_url); |
| 383 break; | 417 break; |
| 384 } | 418 } |
| 385 case ProxyPrefs::MODE_FIXED_SERVERS: { | 419 case ProxyPrefs::MODE_FIXED_SERVERS: { |
| 386 std::string host; | 420 std::string host; |
| 387 int port = 0; | 421 int port = 0; |
| 388 if (!GetHttpProxyServer(proxy_config_dict, &host, &port)) { | 422 if (!GetHttpProxyServer(proxy_config_dict.get(), &host, &port)) { |
| 389 LOG(ERROR) << "No Http proxy server is sent."; | 423 LOG(ERROR) << "No Http proxy server is sent."; |
| 390 return; | 424 return; |
| 391 } | 425 } |
| 392 extras.SetString("host", host); | 426 extras.SetString("host", host); |
| 393 extras.SetInteger("port", port); | 427 extras.SetInteger("port", port); |
| 394 | 428 |
| 395 std::string bypass_list; | 429 std::string bypass_list; |
| 396 if (proxy_config_dict.GetBypassList(&bypass_list) && | 430 if (proxy_config_dict->GetBypassList(&bypass_list) && |
| 397 !bypass_list.empty()) { | 431 !bypass_list.empty()) { |
| 398 extras.SetString("bypassList", bypass_list); | 432 extras.SetString("bypassList", bypass_list); |
| 399 } | 433 } |
| 400 break; | 434 break; |
| 401 } | 435 } |
| 402 default: | 436 default: |
| 403 LOG(ERROR) << "Incorrect proxy mode."; | 437 LOG(ERROR) << "Incorrect proxy mode."; |
| 404 return; | 438 return; |
| 405 } | 439 } |
| 406 | 440 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 431 bool write_success = base::JSONWriter::Write(extras, &extras_json); | 465 bool write_success = base::JSONWriter::Write(extras, &extras_json); |
| 432 DCHECK(write_success); | 466 DCHECK(write_success); |
| 433 | 467 |
| 434 if (arc_bridge_service_->intent_helper()->version() >= 1) { | 468 if (arc_bridge_service_->intent_helper()->version() >= 1) { |
| 435 arc_bridge_service_->intent_helper()->instance()->SendBroadcast( | 469 arc_bridge_service_->intent_helper()->instance()->SendBroadcast( |
| 436 action, "org.chromium.arc.intent_helper", | 470 action, "org.chromium.arc.intent_helper", |
| 437 "org.chromium.arc.intent_helper.SettingsReceiver", extras_json); | 471 "org.chromium.arc.intent_helper.SettingsReceiver", extras_json); |
| 438 } | 472 } |
| 439 } | 473 } |
| 440 | 474 |
| 475 void ArcSettingsServiceImpl::DefaultNetworkChanged( |
| 476 const chromeos::NetworkState* network) { |
| 477 // kProxy pref and ONC policy have more priority than the default network |
| 478 // update. |
| 479 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 480 if (!chromeos::onc::HasPolicyForNetwork( |
| 481 profile->GetPrefs(), g_browser_process->local_state(), *network) && |
| 482 !IsPrefProxyConfigApplied()) { |
| 483 SyncProxySettings(); |
| 484 } |
| 485 } |
| 486 |
| 441 ArcSettingsService::ArcSettingsService(ArcBridgeService* bridge_service) | 487 ArcSettingsService::ArcSettingsService(ArcBridgeService* bridge_service) |
| 442 : ArcService(bridge_service) { | 488 : ArcService(bridge_service) { |
| 443 arc_bridge_service()->intent_helper()->AddObserver(this); | 489 arc_bridge_service()->intent_helper()->AddObserver(this); |
| 444 } | 490 } |
| 445 | 491 |
| 446 ArcSettingsService::~ArcSettingsService() { | 492 ArcSettingsService::~ArcSettingsService() { |
| 447 arc_bridge_service()->intent_helper()->RemoveObserver(this); | 493 arc_bridge_service()->intent_helper()->RemoveObserver(this); |
| 448 } | 494 } |
| 449 | 495 |
| 450 void ArcSettingsService::OnInstanceReady() { | 496 void ArcSettingsService::OnInstanceReady() { |
| 451 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); | 497 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); |
| 452 } | 498 } |
| 453 | 499 |
| 454 void ArcSettingsService::OnInstanceClosed() { | 500 void ArcSettingsService::OnInstanceClosed() { |
| 455 impl_.reset(); | 501 impl_.reset(); |
| 456 } | 502 } |
| 457 | 503 |
| 458 } // namespace arc | 504 } // namespace arc |
| OLD | NEW |