Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Unified Diff: chromeos/network/policy_applicator.cc

Issue 68213018: ONC policy: Support SSID and Security change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/policy_applicator.h ('k') | chromeos/network/shill_property_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/policy_applicator.cc
diff --git a/chromeos/network/policy_applicator.cc b/chromeos/network/policy_applicator.cc
index 462caee6690fa76f6ddf2f40ac62524ad70fabc3..1b01f674817fb4fc1357e77072dbb4eb3c5407b1 100644
--- a/chromeos/network/policy_applicator.cc
+++ b/chromeos/network/policy_applicator.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/values.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -167,22 +168,32 @@ void PolicyApplicator::GetEntryCallback(
VLOG(1) << "Not updating existing managed configuration with guid "
<< new_guid << " because the policy didn't change.";
} else {
- // Delete the entry to ensure that no old configuration remains.
- // Don't do this if a policy is reapplied (e.g. after reboot) or updated
- // (i.e. the GUID didn't change), in order to keep implicit state of
- // Shill like "connected successfully before".
- if (old_guid == new_guid) {
+ const base::DictionaryValue* user_settings =
+ ui_data ? ui_data->user_settings() : NULL;
+ scoped_ptr<base::DictionaryValue> new_shill_properties =
+ policy_util::CreateShillConfiguration(
+ profile_, new_guid, new_policy, user_settings);
+ // A new policy has to be applied to this profile entry. In order to keep
+ // implicit state of Shill like "connected successfully before", keep the
+ // entry if a policy is reapplied (e.g. after reboot) or is updated.
+ // However, some Shill properties are used to identify the network and
+ // cannot be modified after initial configuration, so we have to delete
+ // the profile entry in these cases. Also, keeping Shill's state if the
+ // SSID changed might not be a good idea anyways. If the policy GUID
+ // changed, or there was no policy before, we delete the entry at first to
+ // ensure that no old configuration remains.
+ if (old_guid == new_guid &&
+ shill_property_util::DoIdentifyingPropertiesMatch(
+ *new_shill_properties, entry_properties)) {
VLOG(1) << "Updating previously managed configuration with the "
<< "updated policy " << new_guid << ".";
} else {
+ VLOG(1) << "Deleting profile entry before writing new policy "
+ << new_guid << " because of identifying properties changed.";
DeleteEntry(entry);
}
- const base::DictionaryValue* user_settings =
- ui_data ? ui_data->user_settings() : NULL;
-
- // Write the new configuration.
- CreateAndWriteNewShillConfiguration(new_guid, *new_policy, user_settings);
+ WriteNewShillConfiguration(*new_shill_properties, *new_policy);
remaining_policies_.erase(new_guid);
}
} else if (was_managed) {
@@ -196,7 +207,6 @@ void PolicyApplicator::GetEntryCallback(
} else {
// 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);
@@ -219,10 +229,9 @@ void PolicyApplicator::DeleteEntry(const std::string& entry) {
base::Bind(&LogErrorMessage, FROM_HERE));
}
-void PolicyApplicator::CreateAndWriteNewShillConfiguration(
- const std::string& guid,
- const base::DictionaryValue& policy,
- const base::DictionaryValue* user_settings) {
+void PolicyApplicator::WriteNewShillConfiguration(
+ const base::DictionaryValue& shill_dictionary,
+ const base::DictionaryValue& policy) {
// Ethernet (non EAP) settings, like GUID or UIData, cannot be stored per
// user. Abort in that case.
std::string type;
@@ -239,10 +248,7 @@ void PolicyApplicator::CreateAndWriteNewShillConfiguration(
return;
}
- scoped_ptr<base::DictionaryValue> shill_dictionary =
- policy_util::CreateShillConfiguration(
- profile_, guid, &policy, user_settings);
- handler_->CreateConfigurationFromPolicy(*shill_dictionary);
+ handler_->CreateConfigurationFromPolicy(shill_dictionary);
}
void PolicyApplicator::GetPropertiesForUnmanagedEntry(
@@ -304,8 +310,9 @@ void PolicyApplicator::ApplyRemainingPolicies() {
VLOG(1) << "Creating new configuration managed by policy " << *it
<< " in profile " << profile_.ToDebugString() << ".";
- CreateAndWriteNewShillConfiguration(
- *it, *policy, NULL /* no user settings */);
+ scoped_ptr<base::DictionaryValue> shill_dictionary =
+ policy_util::CreateShillConfiguration(profile_, *it, policy, NULL);
+ WriteNewShillConfiguration(*shill_dictionary, *policy);
}
}
« no previous file with comments | « chromeos/network/policy_applicator.h ('k') | chromeos/network/shill_property_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698