| 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/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chromeos/settings/cros_settings_names.h" | 13 #include "chromeos/settings/cros_settings_names.h" |
| 14 #include "components/flags_ui/flags_ui_pref_names.h" | 14 #include "components/flags_ui/flags_ui_pref_names.h" |
| 15 #include "components/ownership/owner_settings_service.h" | 15 #include "components/ownership/owner_settings_service.h" |
| 16 | 16 |
| 17 namespace chromeos { | 17 namespace chromeos { |
| 18 namespace about_flags { | 18 namespace about_flags { |
| 19 | 19 |
| 20 OwnerFlagsStorage::OwnerFlagsStorage( | 20 OwnerFlagsStorage::OwnerFlagsStorage( |
| 21 PrefService* prefs, | 21 PrefService* prefs, |
| 22 ownership::OwnerSettingsService* owner_settings_service) | 22 ownership::OwnerSettingsService* owner_settings_service) |
| 23 : ::flags_ui::PrefServiceFlagsStorage(prefs), | 23 : flags_ui::PrefServiceFlagsStorage(prefs), |
| 24 owner_settings_service_(owner_settings_service) { | 24 owner_settings_service_(owner_settings_service) { |
| 25 // Make this code more unit test friendly. | 25 // Make this code more unit test friendly. |
| 26 if (g_browser_process->local_state()) { | 26 if (g_browser_process->local_state()) { |
| 27 const base::ListValue* legacy_experiments = | 27 const base::ListValue* legacy_experiments = |
| 28 g_browser_process->local_state()->GetList( | 28 g_browser_process->local_state()->GetList( |
| 29 flags_ui::prefs::kEnabledLabsExperiments); | 29 flags_ui::prefs::kEnabledLabsExperiments); |
| 30 if (!legacy_experiments->empty()) { | 30 if (!legacy_experiments->empty()) { |
| 31 // If there are any flags set in local state migrate them to the owner's | 31 // If there are any flags set in local state migrate them to the owner's |
| 32 // prefs and device settings. | 32 // prefs and device settings. |
| 33 std::set<std::string> flags; | 33 std::set<std::string> flags; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 OwnerFlagsStorage::~OwnerFlagsStorage() {} | 51 OwnerFlagsStorage::~OwnerFlagsStorage() {} |
| 52 | 52 |
| 53 bool OwnerFlagsStorage::SetFlags(const std::set<std::string>& flags) { | 53 bool OwnerFlagsStorage::SetFlags(const std::set<std::string>& flags) { |
| 54 PrefServiceFlagsStorage::SetFlags(flags); | 54 PrefServiceFlagsStorage::SetFlags(flags); |
| 55 | 55 |
| 56 base::ListValue experiments_list; | 56 base::ListValue experiments_list; |
| 57 | 57 |
| 58 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 58 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 59 ::about_flags::ConvertFlagsToSwitches(this, &command_line, | 59 ::about_flags::ConvertFlagsToSwitches(this, &command_line, |
| 60 ::about_flags::kNoSentinels); | 60 flags_ui::kNoSentinels); |
| 61 base::CommandLine::StringVector switches = command_line.argv(); | 61 base::CommandLine::StringVector switches = command_line.argv(); |
| 62 for (base::CommandLine::StringVector::const_iterator it = | 62 for (base::CommandLine::StringVector::const_iterator it = |
| 63 switches.begin() + 1; | 63 switches.begin() + 1; |
| 64 it != switches.end(); ++it) { | 64 it != switches.end(); ++it) { |
| 65 experiments_list.Append(new base::StringValue(*it)); | 65 experiments_list.Append(new base::StringValue(*it)); |
| 66 } | 66 } |
| 67 owner_settings_service_->Set(kStartUpFlags, experiments_list); | 67 owner_settings_service_->Set(kStartUpFlags, experiments_list); |
| 68 | 68 |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace about_flags | 72 } // namespace about_flags |
| 73 } // namespace chromeos | 73 } // namespace chromeos |
| OLD | NEW |