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

Unified Diff: chrome/browser/chromeos/settings/device_settings_provider.cc

Issue 12452003: Move pref backing up flags from local state to device settings on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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
Index: chrome/browser/chromeos/settings/device_settings_provider.cc
diff --git a/chrome/browser/chromeos/settings/device_settings_provider.cc b/chrome/browser/chromeos/settings/device_settings_provider.cc
index 44a253483f2d3526fcd75a3ebf92865684ebd655..4bc6a0cbe6ff3fb8165d147b9baf40d21c4cc1b0 100644
--- a/chrome/browser/chromeos/settings/device_settings_provider.cc
+++ b/chrome/browser/chromeos/settings/device_settings_provider.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/string_util.h"
#include "base/threading/thread_restrictions.h"
@@ -26,6 +27,7 @@
#include "chrome/browser/policy/proto/device_management_backend.pb.h"
#include "chrome/browser/ui/options/options_util.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "chrome/installer/util/google_update_settings.h"
using google::protobuf::RepeatedPtrField;
@@ -63,6 +65,7 @@ const char* kKnownSettings[] = {
kStartUpUrls,
kStatsReportingPref,
kSystemTimezonePolicy,
+ kStartUpFlags,
};
// Legacy policy file location. Used to detect migration from pre v12 ChromeOS.
@@ -279,7 +282,7 @@ void DeviceSettingsProvider::SetInPolicy() {
i != users.end(); ++i) {
std::string email;
if ((*i)->GetAsString(&email))
- whitelist_proto->add_user_whitelist(email.c_str());
+ whitelist_proto->add_user_whitelist(email);
}
} else if (prop == kAccountsPrefEphemeralUsersEnabled) {
em::EphemeralUsersEnabledProto* ephemeral_users_enabled =
@@ -301,6 +304,17 @@ void DeviceSettingsProvider::SetInPolicy() {
} else {
NOTREACHED();
}
+ } else if (prop == kStartUpFlags) {
+ em::StartUpFlagsProto* flags_proto =
+ device_settings_.mutable_start_up_flags();
+ flags_proto->Clear();
+ base::ListValue& flags = static_cast<base::ListValue&>(*value);
Joao da Silva 2013/03/05 17:46:30 Use value->GetAsList (same for kAccountsPrefUsers
pastarmovj 2013/03/06 17:28:31 Done.
+ for (base::ListValue::const_iterator i = flags.begin();
+ i != flags.end(); ++i) {
+ std::string flag;
+ if ((*i)->GetAsString(&flag))
+ flags_proto->add_flags(flag);
+ }
} else {
// The remaining settings don't support Set(), since they are not
// intended to be customizable by the user:
@@ -406,6 +420,17 @@ void DeviceSettingsProvider::DecodeLoginPolicies(
}
}
new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list);
+
+ if (policy.has_start_up_flags()) {
+ base::ListValue* list = new base::ListValue();
+ const em::StartUpFlagsProto& flags_proto = policy.start_up_flags();
+ const RepeatedPtrField<std::string>& flags = flags_proto.flags();
+ for (RepeatedPtrField<std::string>::const_iterator it = flags.begin();
+ it != flags.end(); ++it) {
+ list->Append(new base::StringValue(*it));
+ }
+ new_values_cache->SetValue(kStartUpFlags, list);
+ }
}
void DeviceSettingsProvider::DecodeKioskPolicies(
@@ -604,6 +629,7 @@ void DeviceSettingsProvider::ApplyMetricsSetting(bool use_file,
// TODO(pastarmovj): Remove this once migration is not needed anymore.
// If the value is not set we should try to migrate legacy consent file.
if (use_file) {
+ UMA_HISTOGRAM_COUNTS("DeviceSettings.MetricsMigrated", 1);
new_value = HasOldMetricsFile();
// Make sure the values will get eventually written to the policy file.
migration_values_.SetValue(kStatsReportingPref,
@@ -643,6 +669,21 @@ void DeviceSettingsProvider::ApplySideEffects(
else
ApplyMetricsSetting(true, false);
+ // TODO(pastarmovj): Remove this after we don't need it anymore.
+ // See: http://crosbug.com/39553
+ // Migrate flags to device settings.
+ if (!settings.has_start_up_flags()) {
+ PrefService* local_state = g_browser_process->local_state();
+ if (local_state->HasPrefPath(prefs::kEnabledLabsExperiments)) {
+ UMA_HISTOGRAM_COUNTS("DeviceSettings.FlagsMigrated", 1);
+ const base::ListValue* flags =
+ local_state->GetList(prefs::kEnabledLabsExperiments);
+ migration_values_.SetValue(kStartUpFlags, flags->DeepCopy());
+ AttemptMigration();
Joao da Silva 2013/03/05 17:46:30 What happens if that fails (i.e. there is no priva
pastarmovj 2013/03/06 17:28:31 I changed the logic to avoid clearing the pref bef
+ local_state->ClearPref(prefs::kEnabledLabsExperiments);
+ }
+ }
+
// Next set the roaming setting as needed.
ApplyRoamingSetting(
settings.has_data_roaming_enabled() ?

Powered by Google App Engine
This is Rietveld 408576698