| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/net/proxy_config_handler.h" | 5 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/net/onc_utils.h" | 12 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 16 #include "chromeos/dbus/shill_service_client.h" | 16 #include "chromeos/dbus/shill_service_client.h" |
| 17 #include "chromeos/network/favorite_state.h" | |
| 18 #include "chromeos/network/network_handler_callbacks.h" | 17 #include "chromeos/network/network_handler_callbacks.h" |
| 19 #include "chromeos/network/network_profile.h" | 18 #include "chromeos/network/network_profile.h" |
| 20 #include "chromeos/network/network_profile_handler.h" | 19 #include "chromeos/network/network_profile_handler.h" |
| 20 #include "chromeos/network/network_state.h" |
| 21 #include "chromeos/network/network_state_handler.h" | 21 #include "chromeos/network/network_state_handler.h" |
| 22 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
| 23 #include "dbus/object_path.h" | 23 #include "dbus/object_path.h" |
| 24 #include "third_party/cros_system_api/dbus/service_constants.h" | 24 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 void NotifyNetworkStateHandler(const std::string& service_path) { | 30 void NotifyNetworkStateHandler(const std::string& service_path) { |
| 31 if (NetworkHandler::IsInitialized()) { | 31 if (NetworkHandler::IsInitialized()) { |
| 32 NetworkHandler::Get()->network_state_handler()->RequestUpdateForNetwork( | 32 NetworkHandler::Get()->network_state_handler()->RequestUpdateForNetwork( |
| 33 service_path); | 33 service_path); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 namespace proxy_config { | 39 namespace proxy_config { |
| 40 | 40 |
| 41 scoped_ptr<ProxyConfigDictionary> GetProxyConfigForFavoriteNetwork( | 41 scoped_ptr<ProxyConfigDictionary> GetProxyConfigForNetwork( |
| 42 const PrefService* profile_prefs, | 42 const PrefService* profile_prefs, |
| 43 const PrefService* local_state_prefs, | 43 const PrefService* local_state_prefs, |
| 44 const FavoriteState& network, | 44 const NetworkState& network, |
| 45 ::onc::ONCSource* onc_source) { | 45 ::onc::ONCSource* onc_source) { |
| 46 const base::DictionaryValue* network_policy = | 46 const base::DictionaryValue* network_policy = |
| 47 onc::GetPolicyForFavoriteNetwork( | 47 onc::GetPolicyForNetwork( |
| 48 profile_prefs, local_state_prefs, network, onc_source); | 48 profile_prefs, local_state_prefs, network, onc_source); |
| 49 | 49 |
| 50 if (network_policy) { | 50 if (network_policy) { |
| 51 const base::DictionaryValue* proxy_policy = NULL; | 51 const base::DictionaryValue* proxy_policy = NULL; |
| 52 network_policy->GetDictionaryWithoutPathExpansion( | 52 network_policy->GetDictionaryWithoutPathExpansion( |
| 53 ::onc::network_config::kProxySettings, &proxy_policy); | 53 ::onc::network_config::kProxySettings, &proxy_policy); |
| 54 if (!proxy_policy) { | 54 if (!proxy_policy) { |
| 55 // This policy doesn't set a proxy for this network. Nonetheless, this | 55 // This policy doesn't set a proxy for this network. Nonetheless, this |
| 56 // disallows changes by the user. | 56 // disallows changes by the user. |
| 57 return scoped_ptr<ProxyConfigDictionary>(); | 57 return scoped_ptr<ProxyConfigDictionary>(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 84 // No policy set for this network, read instead the user's (shared or | 84 // No policy set for this network, read instead the user's (shared or |
| 85 // unshared) configuration. | 85 // unshared) configuration. |
| 86 // The user's proxy setting is not stored in the Chrome preference yet. We | 86 // The user's proxy setting is not stored in the Chrome preference yet. We |
| 87 // still rely on Shill storing it. | 87 // still rely on Shill storing it. |
| 88 const base::DictionaryValue& value = network.proxy_config(); | 88 const base::DictionaryValue& value = network.proxy_config(); |
| 89 if (value.empty()) | 89 if (value.empty()) |
| 90 return scoped_ptr<ProxyConfigDictionary>(); | 90 return scoped_ptr<ProxyConfigDictionary>(); |
| 91 return make_scoped_ptr(new ProxyConfigDictionary(&value)); | 91 return make_scoped_ptr(new ProxyConfigDictionary(&value)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SetProxyConfigForFavoriteNetwork(const ProxyConfigDictionary& proxy_config, | 94 void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config, |
| 95 const FavoriteState& network) { | 95 const NetworkState& network) { |
| 96 chromeos::ShillServiceClient* shill_service_client = | 96 chromeos::ShillServiceClient* shill_service_client = |
| 97 DBusThreadManager::Get()->GetShillServiceClient(); | 97 DBusThreadManager::Get()->GetShillServiceClient(); |
| 98 | 98 |
| 99 // The user's proxy setting is not stored in the Chrome preference yet. We | 99 // The user's proxy setting is not stored in the Chrome preference yet. We |
| 100 // still rely on Shill storing it. | 100 // still rely on Shill storing it. |
| 101 ProxyPrefs::ProxyMode mode; | 101 ProxyPrefs::ProxyMode mode; |
| 102 if (!proxy_config.GetMode(&mode) || mode == ProxyPrefs::MODE_DIRECT) { | 102 if (!proxy_config.GetMode(&mode) || mode == ProxyPrefs::MODE_DIRECT) { |
| 103 // Return empty string for direct mode for portal check to work correctly. | 103 // Return empty string for direct mode for portal check to work correctly. |
| 104 // TODO(pneubeck): Consider removing this legacy code. | 104 // TODO(pneubeck): Consider removing this legacy code. |
| 105 shill_service_client->ClearProperty( | 105 shill_service_client->ClearProperty( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 135 false, | 135 false, |
| 136 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 136 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 137 | 137 |
| 138 registry->RegisterListPref(prefs::kOpenNetworkConfiguration, | 138 registry->RegisterListPref(prefs::kOpenNetworkConfiguration, |
| 139 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 139 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace proxy_config | 142 } // namespace proxy_config |
| 143 | 143 |
| 144 } // namespace chromeos | 144 } // namespace chromeos |
| OLD | NEW |