Chromium Code Reviews| Index: chromeos/network/policy_applicator.cc |
| diff --git a/chromeos/network/policy_applicator.cc b/chromeos/network/policy_applicator.cc |
| index ce236b08044fc3bf5d13a65e54bd03a30c058a14..d89e16538cb5c1ae778cb0d9aa14493371ff0806 100644 |
| --- a/chromeos/network/policy_applicator.cc |
| +++ b/chromeos/network/policy_applicator.cc |
| @@ -43,11 +43,14 @@ const base::DictionaryValue* GetByGUID( |
| } // namespace |
| -PolicyApplicator::PolicyApplicator(base::WeakPtr<ConfigurationHandler> handler, |
| - const NetworkProfile& profile, |
| - const GuidToPolicyMap& all_policies, |
| - std::set<std::string>* modified_policies) |
| +PolicyApplicator::PolicyApplicator( |
| + base::WeakPtr<ConfigurationHandler> handler, |
| + const NetworkProfile& profile, |
| + const GuidToPolicyMap& all_policies, |
| + const base::DictionaryValue& global_network_config, |
| + std::set<std::string>* modified_policies) |
| : handler_(handler), profile_(profile) { |
| + global_network_config_.MergeDictionary(&global_network_config); |
| remaining_policies_.swap(*modified_policies); |
| for (GuidToPolicyMap::const_iterator it = all_policies.begin(); |
| it != all_policies.end(); ++it) { |
| @@ -191,10 +194,19 @@ void PolicyApplicator::GetEntryCallback( |
| // unclear which values originating the policy should be removed. |
| DeleteEntry(entry); |
| } else { |
| - VLOG(2) << "Ignore unmanaged entry."; |
| - |
| - // The entry wasn't managed and doesn't match any current policy. Thus |
| - // leave it as it is. |
| + // The entry wasn't managed and doesn't match any current policy. Global |
| + // network settings have to be applied. |
| + |
| + base::DictionaryValue shill_properties_to_update; |
| + GetPropertiesForUnmanagedEntry(entry_properties, |
| + &shill_properties_to_update); |
| + if (shill_properties_to_update.empty()) { |
| + VLOG(2) << "Ignore unmanaged entry."; |
| + } else { |
| + VLOG(2) << "Apply global network config to unmanaged entry."; |
| + handler_->UpdateExistingConfigurationWithPropertiesFromPolicy( |
| + entry_properties, shill_properties_to_update); |
| + } |
| } |
| } |
| @@ -232,6 +244,31 @@ void PolicyApplicator::CreateAndWriteNewShillConfiguration( |
| handler_->CreateConfigurationFromPolicy(*shill_dictionary); |
| } |
| +void PolicyApplicator::GetPropertiesForUnmanagedEntry( |
|
bartfab (slow)
2013/10/16 12:40:31
Could you comment this method a bit? It was not cl
pneubeck (no reviews)
2013/10/17 10:22:26
Done.
|
| + const base::DictionaryValue& entry_properties, |
| + base::DictionaryValue* properties_to_update) const { |
| + // kAllowAutoconnect is currently the only global config. |
| + |
| + std::string type; |
| + entry_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, &type); |
| + if (NetworkTypePattern::Ethernet().MatchesType(type)) |
| + return; // Autoconnect for Ethernet cannot be configured. |
|
bartfab (slow)
2013/10/16 12:40:31
Nit: There should be two spaces before a trailing
pneubeck (no reviews)
2013/10/17 10:22:26
Done.
|
| + |
| + bool autoconnect_allowed = true; |
| + global_network_config_.GetBooleanWithoutPathExpansion( |
| + ::onc::global_network_config::kAllowAutoconnect, &autoconnect_allowed); |
| + if (autoconnect_allowed) |
| + return; |
| + |
| + bool old_autoconnect = false; |
| + entry_properties.GetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, |
|
pneubeck (no reviews)
2013/10/16 12:38:20
if entry doesn't exist, we have to set to false ex
pneubeck (no reviews)
2013/10/17 10:22:26
Done.
|
| + &old_autoconnect); |
| + if (old_autoconnect) { |
| + properties_to_update->SetBooleanWithoutPathExpansion( |
| + shill::kAutoConnectProperty, false); |
| + } |
| +} |
| + |
| PolicyApplicator::~PolicyApplicator() { |
| ApplyRemainingPolicies(); |
| STLDeleteValues(&all_policies_); |