| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/flags_ui.h" | 5 #include "chrome/browser/ui/webui/flags_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 flags_experiments_requested_ = true; | 167 flags_experiments_requested_ = true; |
| 168 // Bail out if the handler hasn't been initialized yet. The request will be | 168 // Bail out if the handler hasn't been initialized yet. The request will be |
| 169 // handled after the initialization. | 169 // handled after the initialization. |
| 170 if (!flags_storage_) | 170 if (!flags_storage_) |
| 171 return; | 171 return; |
| 172 | 172 |
| 173 base::DictionaryValue results; | 173 base::DictionaryValue results; |
| 174 | 174 |
| 175 scoped_ptr<base::ListValue> supported_experiments(new base::ListValue); | 175 scoped_ptr<base::ListValue> supported_experiments(new base::ListValue); |
| 176 scoped_ptr<base::ListValue> unsupported_experiments(new base::ListValue); | 176 scoped_ptr<base::ListValue> unsupported_experiments(new base::ListValue); |
| 177 about_flags::GetFlagsExperimentsData(flags_storage_.get(), | 177 about_flags::GetFlagsEntryData(flags_storage_.get(), |
| 178 access_, | 178 access_, |
| 179 supported_experiments.get(), | 179 supported_experiments.get(), |
| 180 unsupported_experiments.get()); | 180 unsupported_experiments.get()); |
| 181 results.Set("supportedExperiments", supported_experiments.release()); | 181 results.Set("supportedExperiments", supported_experiments.release()); |
| 182 results.Set("unsupportedExperiments", unsupported_experiments.release()); | 182 results.Set("unsupportedExperiments", unsupported_experiments.release()); |
| 183 results.SetBoolean("needsRestart", | 183 results.SetBoolean("needsRestart", |
| 184 about_flags::IsRestartNeededToCommitChanges()); | 184 about_flags::IsRestartNeededToCommitChanges()); |
| 185 results.SetBoolean("showOwnerWarning", | 185 results.SetBoolean("showOwnerWarning", |
| 186 access_ == about_flags::kGeneralAccessFlagsOnly); | 186 access_ == about_flags::kGeneralAccessFlagsOnly); |
| 187 | 187 |
| 188 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | 188 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 189 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 189 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 190 results.SetBoolean("showBetaChannelPromotion", | 190 results.SetBoolean("showBetaChannelPromotion", |
| 191 channel == chrome::VersionInfo::CHANNEL_STABLE); | 191 channel == chrome::VersionInfo::CHANNEL_STABLE); |
| 192 results.SetBoolean("showDevChannelPromotion", | 192 results.SetBoolean("showDevChannelPromotion", |
| 193 channel == chrome::VersionInfo::CHANNEL_BETA); | 193 channel == chrome::VersionInfo::CHANNEL_BETA); |
| 194 #else | 194 #else |
| 195 results.SetBoolean("showBetaChannelPromotion", false); | 195 results.SetBoolean("showBetaChannelPromotion", false); |
| 196 results.SetBoolean("showDevChannelPromotion", false); | 196 results.SetBoolean("showDevChannelPromotion", false); |
| 197 #endif | 197 #endif |
| 198 web_ui()->CallJavascriptFunction("returnFlagsExperiments", results); | 198 web_ui()->CallJavascriptFunction("returnFlagsExperiments", results); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void FlagsDOMHandler::HandleEnableFlagsExperimentMessage( | 201 void FlagsDOMHandler::HandleEnableFlagsExperimentMessage( |
| 202 const base::ListValue* args) { | 202 const base::ListValue* args) { |
| 203 DCHECK(flags_storage_); | 203 DCHECK(flags_storage_); |
| 204 DCHECK_EQ(2u, args->GetSize()); | 204 DCHECK_EQ(2u, args->GetSize()); |
| 205 if (args->GetSize() != 2) | 205 if (args->GetSize() != 2) |
| 206 return; | 206 return; |
| 207 | 207 |
| 208 std::string experiment_internal_name; | 208 std::string entry_internal_name; |
| 209 std::string enable_str; | 209 std::string enable_str; |
| 210 if (!args->GetString(0, &experiment_internal_name) || | 210 if (!args->GetString(0, &entry_internal_name) || |
| 211 !args->GetString(1, &enable_str)) | 211 !args->GetString(1, &enable_str)) |
| 212 return; | 212 return; |
| 213 | 213 |
| 214 about_flags::SetExperimentEnabled( | 214 about_flags::SetEntryEnabled(flags_storage_.get(), entry_internal_name, |
| 215 flags_storage_.get(), | 215 enable_str == "true"); |
| 216 experiment_internal_name, | |
| 217 enable_str == "true"); | |
| 218 } | 216 } |
| 219 | 217 |
| 220 void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) { | 218 void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) { |
| 221 DCHECK(flags_storage_); | 219 DCHECK(flags_storage_); |
| 222 #if defined(OS_CHROMEOS) | 220 #if defined(OS_CHROMEOS) |
| 223 // On ChromeOS be less intrusive and restart inside the user session after | 221 // On ChromeOS be less intrusive and restart inside the user session after |
| 224 // we apply the newly selected flags. | 222 // we apply the newly selected flags. |
| 225 base::CommandLine user_flags(base::CommandLine::NO_PROGRAM); | 223 base::CommandLine user_flags(base::CommandLine::NO_PROGRAM); |
| 226 about_flags::ConvertFlagsToSwitches(flags_storage_.get(), | 224 about_flags::ConvertFlagsToSwitches(flags_storage_.get(), |
| 227 &user_flags, | 225 &user_flags, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 registry->RegisterListPref(prefs::kEnabledLabsExperiments); | 328 registry->RegisterListPref(prefs::kEnabledLabsExperiments); |
| 331 } | 329 } |
| 332 | 330 |
| 333 #if defined(OS_CHROMEOS) | 331 #if defined(OS_CHROMEOS) |
| 334 // static | 332 // static |
| 335 void FlagsUI::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 333 void FlagsUI::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 336 registry->RegisterListPref(prefs::kEnabledLabsExperiments); | 334 registry->RegisterListPref(prefs::kEnabledLabsExperiments); |
| 337 } | 335 } |
| 338 | 336 |
| 339 #endif | 337 #endif |
| OLD | NEW |