Chromium Code Reviews| Index: chrome/browser/chromeos/net/onc_utils.cc |
| diff --git a/chrome/browser/chromeos/net/onc_utils.cc b/chrome/browser/chromeos/net/onc_utils.cc |
| index 89d1f960135a86da203398c9309bcd8005515fd8..11f73aa08690c50e6bd0f25ee3cc11eff4b6b1b9 100644 |
| --- a/chrome/browser/chromeos/net/onc_utils.cc |
| +++ b/chrome/browser/chromeos/net/onc_utils.cc |
| @@ -21,11 +21,13 @@ |
| #include "chromeos/network/network_profile.h" |
| #include "chromeos/network/network_profile_handler.h" |
| #include "chromeos/network/network_state.h" |
| +#include "chromeos/network/network_state_handler.h" |
| #include "chromeos/network/network_ui_data.h" |
| #include "chromeos/network/onc/onc_normalizer.h" |
| #include "chromeos/network/onc/onc_signature.h" |
| #include "chromeos/network/onc/onc_translator.h" |
| #include "chromeos/network/onc/onc_utils.h" |
| +#include "chromeos/network/shill_property_util.h" |
| #include "net/base/host_port_pair.h" |
| #include "net/proxy/proxy_bypass_rules.h" |
| #include "net/proxy/proxy_server.h" |
| @@ -262,9 +264,67 @@ const base::DictionaryValue* GetNetworkConfigByGUID( |
| return NULL; |
| } |
| +const base::DictionaryValue* GetNetworkConfigForEthernetWithoutEAP( |
| + const base::ListValue& network_configs) { |
| + VLOG(2) << "Search for ethernet policy without EAP."; |
| + for (base::ListValue::const_iterator it = network_configs.begin(); |
| + it != network_configs.end(); ++it) { |
| + const base::DictionaryValue* network = NULL; |
| + (*it)->GetAsDictionary(&network); |
|
stevenjb
2013/09/17 16:22:59
if (!GetAsDictionary()) { ERROR, continue }
pneubeck (no reviews)
2013/09/30 20:08:31
Done.
|
| + |
| + std::string type; |
| + network->GetStringWithoutPathExpansion(onc::network_config::kType, &type); |
| + if (type != onc::network_type::kEthernet) |
| + continue; |
| + |
| + const base::DictionaryValue* ethernet = NULL; |
| + network->GetDictionaryWithoutPathExpansion(onc::network_config::kEthernet, |
| + ðernet); |
|
stevenjb
2013/09/17 16:22:59
if (!GetDictionary...) { ERROR, continue }
pneubeck (no reviews)
2013/09/30 20:08:31
Done.
|
| + |
| + std::string auth; |
| + ethernet->GetStringWithoutPathExpansion(onc::ethernet::kAuthentication, |
| + &auth); |
| + if (auth == onc::ethernet::kNone) |
| + return network; |
| + } |
| + return NULL; |
| +} |
| + |
| +const base::DictionaryValue* GetNetworkConfigForNetworkFromOnc( |
| + const base::ListValue& network_configs, |
| + const ManagedState& network, |
| + const std::string& network_guid) { |
|
stevenjb
2013/09/17 16:22:59
I really think all of these should just take eithe
pneubeck (no reviews)
2013/09/30 20:08:31
Done.
|
| + // In all cases except Ethernet, we use the GUID of |network|. |
| + if (!network.Matches(NetworkTypePattern::Ethernet())) |
| + return GetNetworkConfigByGUID(network_configs, network_guid); |
| + |
| + // Ethernet is always shared and thus cannot store a GUID per user. Thus we |
| + // search for any Ethernet policy intead of a matching GUID. |
| + // EthernetEAP service contains only the EAP parameters and stores the GUID of |
| + // the respective ONC policy. The EthernetEAP service itself is however never |
| + // in state "connected". An EthernetEAP policy must be applied, if an Ethernet |
| + // service is connected using the EAP parameters. |
| + const FavoriteState* ethernet_eap = NULL; |
| + if (NetworkHandler::IsInitialized()) { |
| + ethernet_eap = |
| + NetworkHandler::Get()->network_state_handler()->GetEAPForEthernet( |
| + network.path()); |
| + } |
| + |
| + // The GUID associated with the EthernetEAP service refers to the ONC policy |
| + // with "Authentication: 8021X". |
| + if (ethernet_eap) |
| + return GetNetworkConfigByGUID(network_configs, ethernet_eap->guid()); |
| + |
| + // Otherwise, EAP is not used and instead the Ethernet policy with |
| + // "Authentication: None" applies. |
| + return GetNetworkConfigForEthernetWithoutEAP(network_configs); |
| +} |
| + |
| const base::DictionaryValue* GetPolicyForNetworkFromPref( |
| const PrefService* pref_service, |
| const char* pref_name, |
| + const ManagedState& network, |
| const std::string& network_guid) { |
| if (!pref_service) { |
| VLOG(2) << "No pref service"; |
| @@ -299,33 +359,36 @@ const base::DictionaryValue* GetPolicyForNetworkFromPref( |
| onc_policy_value->GetAsList(&onc_policy); |
| DCHECK(onc_policy); |
| - return GetNetworkConfigByGUID(*onc_policy, network_guid); |
| + return GetNetworkConfigForNetworkFromOnc(*onc_policy, network, network_guid); |
| } |
| const base::DictionaryValue* GetPolicyForNetwork( |
| const PrefService* profile_prefs, |
| const PrefService* local_state_prefs, |
| - const std::string& network_path, |
| + const ManagedState& network, |
| const std::string& network_guid, |
| onc::ONCSource* onc_source) { |
| - VLOG(2) << "GetPolicyForNetwork: " << network_path; |
| + VLOG(2) << "GetPolicyForNetwork: " << network.path(); |
| *onc_source = onc::ONC_SOURCE_NONE; |
| const base::DictionaryValue* network_policy = GetPolicyForNetworkFromPref( |
| - profile_prefs, prefs::kOpenNetworkConfiguration, network_guid); |
| + profile_prefs, prefs::kOpenNetworkConfiguration, network, network_guid); |
| if (network_policy) { |
| - VLOG(1) << "Network " << network_path << " is managed by user policy."; |
| + VLOG(1) << "Network " << network.path() << " is managed by user policy."; |
| *onc_source = onc::ONC_SOURCE_USER_POLICY; |
| return network_policy; |
| } |
| - network_policy = GetPolicyForNetworkFromPref( |
| - local_state_prefs, prefs::kDeviceOpenNetworkConfiguration, network_guid); |
| + network_policy = |
| + GetPolicyForNetworkFromPref(local_state_prefs, |
| + prefs::kDeviceOpenNetworkConfiguration, |
| + network, |
| + network_guid); |
| if (network_policy) { |
| - VLOG(1) << "Network " << network_path << " is managed by device policy."; |
| + VLOG(1) << "Network " << network.path() << " is managed by device policy."; |
| *onc_source = onc::ONC_SOURCE_DEVICE_POLICY; |
| return network_policy; |
| } |
| - VLOG(2) << "Network " << network_path << " is unmanaged."; |
| + VLOG(2) << "Network " << network.path() << " is unmanaged."; |
| return NULL; |
| } |
| @@ -336,11 +399,8 @@ const base::DictionaryValue* GetPolicyForNetwork( |
| const PrefService* local_state_prefs, |
| const NetworkState& network, |
| onc::ONCSource* onc_source) { |
| - return GetPolicyForNetwork(profile_prefs, |
| - local_state_prefs, |
| - network.path(), |
| - network.guid(), |
| - onc_source); |
| + return GetPolicyForNetwork( |
| + profile_prefs, local_state_prefs, network, network.guid(), onc_source); |
| } |
| const base::DictionaryValue* GetPolicyForNetwork( |
| @@ -348,11 +408,8 @@ const base::DictionaryValue* GetPolicyForNetwork( |
| const PrefService* local_state_prefs, |
| const FavoriteState& favorite, |
| onc::ONCSource* onc_source) { |
| - return GetPolicyForNetwork(profile_prefs, |
| - local_state_prefs, |
| - favorite.path(), |
| - favorite.guid(), |
| - onc_source); |
| + return GetPolicyForNetwork( |
| + profile_prefs, local_state_prefs, favorite, favorite.guid(), onc_source); |
| } |
| } // namespace onc |