| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "components/proxy_config/proxy_config_pref_names.h" | 31 #include "components/proxy_config/proxy_config_pref_names.h" |
| 32 #include "device/bluetooth/bluetooth_adapter.h" | 32 #include "device/bluetooth/bluetooth_adapter.h" |
| 33 #include "device/bluetooth/bluetooth_adapter_factory.h" | 33 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 34 #include "net/proxy/proxy_config.h" | 34 #include "net/proxy/proxy_config.h" |
| 35 | 35 |
| 36 using ::chromeos::CrosSettings; | 36 using ::chromeos::CrosSettings; |
| 37 using ::chromeos::system::TimezoneSettings; | 37 using ::chromeos::system::TimezoneSettings; |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 constexpr uint32_t kMinVersionForSendBroadcast = 1; |
| 42 |
| 41 bool GetHttpProxyServer(const ProxyConfigDictionary* proxy_config_dict, | 43 bool GetHttpProxyServer(const ProxyConfigDictionary* proxy_config_dict, |
| 42 std::string* host, | 44 std::string* host, |
| 43 int* port) { | 45 int* port) { |
| 44 std::string proxy_rules_string; | 46 std::string proxy_rules_string; |
| 45 if (!proxy_config_dict->GetProxyServer(&proxy_rules_string)) | 47 if (!proxy_config_dict->GetProxyServer(&proxy_rules_string)) |
| 46 return false; | 48 return false; |
| 47 | 49 |
| 48 net::ProxyConfig::ProxyRules proxy_rules; | 50 net::ProxyConfig::ProxyRules proxy_rules; |
| 49 proxy_rules.ParseFromString(proxy_rules_string); | 51 proxy_rules.ParseFromString(proxy_rules_string); |
| 50 | 52 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 451 |
| 450 void ArcSettingsServiceImpl::SyncLocationServiceEnabled() const { | 452 void ArcSettingsServiceImpl::SyncLocationServiceEnabled() const { |
| 451 SendBoolPrefSettingsBroadcast( | 453 SendBoolPrefSettingsBroadcast( |
| 452 prefs::kArcLocationServiceEnabled, | 454 prefs::kArcLocationServiceEnabled, |
| 453 "org.chromium.arc.intent_helper.SET_LOCATION_SERVICE_ENABLED"); | 455 "org.chromium.arc.intent_helper.SET_LOCATION_SERVICE_ENABLED"); |
| 454 } | 456 } |
| 455 | 457 |
| 456 void ArcSettingsServiceImpl::SendSettingsBroadcast( | 458 void ArcSettingsServiceImpl::SendSettingsBroadcast( |
| 457 const std::string& action, | 459 const std::string& action, |
| 458 const base::DictionaryValue& extras) const { | 460 const base::DictionaryValue& extras) const { |
| 459 if (!arc_bridge_service_->intent_helper()->instance()) { | 461 auto* instance = arc_bridge_service_->intent_helper()->GetInstanceForMethod( |
| 460 LOG(ERROR) << "IntentHelper instance is not ready."; | 462 "SendBroadcast", kMinVersionForSendBroadcast); |
| 463 if (!instance) |
| 461 return; | 464 return; |
| 462 } | |
| 463 | |
| 464 std::string extras_json; | 465 std::string extras_json; |
| 465 bool write_success = base::JSONWriter::Write(extras, &extras_json); | 466 bool write_success = base::JSONWriter::Write(extras, &extras_json); |
| 466 DCHECK(write_success); | 467 DCHECK(write_success); |
| 467 | 468 |
| 468 if (arc_bridge_service_->intent_helper()->version() >= 1) { | 469 instance->SendBroadcast(action, "org.chromium.arc.intent_helper", |
| 469 arc_bridge_service_->intent_helper()->instance()->SendBroadcast( | 470 "org.chromium.arc.intent_helper.SettingsReceiver", |
| 470 action, "org.chromium.arc.intent_helper", | 471 extras_json); |
| 471 "org.chromium.arc.intent_helper.SettingsReceiver", extras_json); | |
| 472 } | |
| 473 } | 472 } |
| 474 | 473 |
| 475 void ArcSettingsServiceImpl::DefaultNetworkChanged( | 474 void ArcSettingsServiceImpl::DefaultNetworkChanged( |
| 476 const chromeos::NetworkState* network) { | 475 const chromeos::NetworkState* network) { |
| 477 // kProxy pref and ONC policy have more priority than the default network | 476 // kProxy pref and ONC policy have more priority than the default network |
| 478 // update. | 477 // update. |
| 479 Profile* profile = ProfileManager::GetActiveUserProfile(); | 478 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 480 if (!chromeos::onc::HasPolicyForNetwork( | 479 if (!chromeos::onc::HasPolicyForNetwork( |
| 481 profile->GetPrefs(), g_browser_process->local_state(), *network) && | 480 profile->GetPrefs(), g_browser_process->local_state(), *network) && |
| 482 !IsPrefProxyConfigApplied()) { | 481 !IsPrefProxyConfigApplied()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 495 | 494 |
| 496 void ArcSettingsService::OnInstanceReady() { | 495 void ArcSettingsService::OnInstanceReady() { |
| 497 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); | 496 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); |
| 498 } | 497 } |
| 499 | 498 |
| 500 void ArcSettingsService::OnInstanceClosed() { | 499 void ArcSettingsService::OnInstanceClosed() { |
| 501 impl_.reset(); | 500 impl_.reset(); |
| 502 } | 501 } |
| 503 | 502 |
| 504 } // namespace arc | 503 } // namespace arc |
| OLD | NEW |