OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/settings/owner_flags_storage.h" | 5 #include "chrome/browser/chromeos/settings/owner_flags_storage.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/about_flags.h" | 10 #include "chrome/browser/about_flags.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/settings/cros_settings.h" | 12 #include "chrome/browser/chromeos/settings/cros_settings.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "chromeos/settings/cros_settings_names.h" | 14 #include "chromeos/settings/cros_settings_names.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 namespace about_flags { | 17 namespace about_flags { |
18 | 18 |
19 OwnerFlagsStorage::OwnerFlagsStorage(PrefService *prefs, | 19 OwnerFlagsStorage::OwnerFlagsStorage(PrefService *prefs, |
20 CrosSettings *cros_settings) | 20 CrosSettings *cros_settings) |
21 : ::about_flags::PrefServiceFlagsStorage(prefs), | 21 : ::about_flags::PrefServiceFlagsStorage(prefs), |
22 cros_settings_(cros_settings) { | 22 cros_settings_(cros_settings) { |
23 // Make this code more unit test friendly. | 23 // Make this code more unit test friendly. |
24 if (g_browser_process->local_state()) { | 24 if (g_browser_process->local_state()) { |
25 const ListValue* legacy_experiments = | 25 const base::ListValue* legacy_experiments = |
26 g_browser_process->local_state()->GetList( | 26 g_browser_process->local_state()->GetList( |
27 prefs::kEnabledLabsExperiments); | 27 prefs::kEnabledLabsExperiments); |
28 if (!legacy_experiments->empty()) { | 28 if (!legacy_experiments->empty()) { |
29 // If there are any flags set in local state migrate them to the owner's | 29 // If there are any flags set in local state migrate them to the owner's |
30 // prefs and device settings. | 30 // prefs and device settings. |
31 std::set<std::string> flags; | 31 std::set<std::string> flags; |
32 for (ListValue::const_iterator it = legacy_experiments->begin(); | 32 for (base::ListValue::const_iterator it = legacy_experiments->begin(); |
33 it != legacy_experiments->end(); ++it) { | 33 it != legacy_experiments->end(); ++it) { |
34 std::string experiment_name; | 34 std::string experiment_name; |
35 if (!(*it)->GetAsString(&experiment_name)) { | 35 if (!(*it)->GetAsString(&experiment_name)) { |
36 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments; | 36 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments; |
37 continue; | 37 continue; |
38 } | 38 } |
39 flags.insert(experiment_name); | 39 flags.insert(experiment_name); |
40 } | 40 } |
41 SetFlags(flags); | 41 SetFlags(flags); |
42 g_browser_process->local_state()->ClearPref( | 42 g_browser_process->local_state()->ClearPref( |
(...skipping 17 matching lines...) Expand all Loading... |
60 it != switches.end(); ++it) { | 60 it != switches.end(); ++it) { |
61 experiments_list.Append(new base::StringValue(*it)); | 61 experiments_list.Append(new base::StringValue(*it)); |
62 } | 62 } |
63 cros_settings_->Set(kStartUpFlags, experiments_list); | 63 cros_settings_->Set(kStartUpFlags, experiments_list); |
64 | 64 |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 } // namespace about_flags | 68 } // namespace about_flags |
69 } // namespace chromeos | 69 } // namespace chromeos |
OLD | NEW |