| 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/about_flags.h" | 5 #include "chrome/browser/about_flags.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 if (new_enabled_experiments != enabled_experiments) | 2010 if (new_enabled_experiments != enabled_experiments) |
| 2011 flags_storage->SetFlags(new_enabled_experiments); | 2011 flags_storage->SetFlags(new_enabled_experiments); |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 void GetSanitizedEnabledFlags( | 2014 void GetSanitizedEnabledFlags( |
| 2015 FlagsStorage* flags_storage, std::set<std::string>* result) { | 2015 FlagsStorage* flags_storage, std::set<std::string>* result) { |
| 2016 SanitizeList(flags_storage); | 2016 SanitizeList(flags_storage); |
| 2017 *result = flags_storage->GetFlags(); | 2017 *result = flags_storage->GetFlags(); |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 bool SkipConditionalExperiment(const Experiment& experiment) { | 2020 bool SkipConditionalExperiment(const Experiment& experiment, |
| 2021 FlagsStorage* flags_storage) { |
| 2021 if (experiment.internal_name == | 2022 if (experiment.internal_name == |
| 2022 std::string("enhanced-bookmarks-experiment")) { | 2023 std::string("enhanced-bookmarks-experiment")) { |
| 2023 #if defined(OS_ANDROID) | 2024 #if defined(OS_ANDROID) |
| 2024 // On Android, user can opt in. | 2025 // On Android, user can opt in. |
| 2025 return false; | 2026 return false; |
| 2026 #else | 2027 #else |
| 2027 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 2028 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 2028 // Dont't skip experiment if it has non default value. | 2029 // Dont't skip experiment if it has non default value. |
| 2029 // It means user selected it. | 2030 // It means user selected it. |
| 2030 if (command_line->HasSwitch(switches::kEnhancedBookmarksExperiment)) | 2031 if (command_line->HasSwitch(switches::kEnhancedBookmarksExperiment)) |
| 2031 return false; | 2032 return false; |
| 2032 | 2033 |
| 2033 return !IsEnhancedBookmarksExperimentEnabled(); | 2034 return !IsEnhancedBookmarksExperimentEnabled(flags_storage); |
| 2034 #endif | 2035 #endif |
| 2035 } | 2036 } |
| 2036 | 2037 |
| 2037 if ((experiment.internal_name == std::string("manual-enhanced-bookmarks")) || | 2038 if ((experiment.internal_name == std::string("manual-enhanced-bookmarks")) || |
| 2038 (experiment.internal_name == | 2039 (experiment.internal_name == |
| 2039 std::string("manual-enhanced-bookmarks-optout"))) { | 2040 std::string("manual-enhanced-bookmarks-optout"))) { |
| 2040 return true; | 2041 return true; |
| 2041 } | 2042 } |
| 2042 | 2043 |
| 2043 #if defined(OS_ANDROID) | 2044 #if defined(OS_ANDROID) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 FlagAccess access, | 2166 FlagAccess access, |
| 2166 base::ListValue* supported_experiments, | 2167 base::ListValue* supported_experiments, |
| 2167 base::ListValue* unsupported_experiments) { | 2168 base::ListValue* unsupported_experiments) { |
| 2168 std::set<std::string> enabled_experiments; | 2169 std::set<std::string> enabled_experiments; |
| 2169 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); | 2170 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); |
| 2170 | 2171 |
| 2171 int current_platform = GetCurrentPlatform(); | 2172 int current_platform = GetCurrentPlatform(); |
| 2172 | 2173 |
| 2173 for (size_t i = 0; i < num_experiments; ++i) { | 2174 for (size_t i = 0; i < num_experiments; ++i) { |
| 2174 const Experiment& experiment = experiments[i]; | 2175 const Experiment& experiment = experiments[i]; |
| 2175 if (SkipConditionalExperiment(experiment)) | 2176 if (SkipConditionalExperiment(experiment, flags_storage)) |
| 2176 continue; | 2177 continue; |
| 2177 | 2178 |
| 2178 base::DictionaryValue* data = new base::DictionaryValue(); | 2179 base::DictionaryValue* data = new base::DictionaryValue(); |
| 2179 data->SetString("internal_name", experiment.internal_name); | 2180 data->SetString("internal_name", experiment.internal_name); |
| 2180 data->SetString("name", | 2181 data->SetString("name", |
| 2181 l10n_util::GetStringUTF16(experiment.visible_name_id)); | 2182 l10n_util::GetStringUTF16(experiment.visible_name_id)); |
| 2182 data->SetString("description", | 2183 data->SetString("description", |
| 2183 l10n_util::GetStringUTF16( | 2184 l10n_util::GetStringUTF16( |
| 2184 experiment.visible_description_id)); | 2185 experiment.visible_description_id)); |
| 2185 | 2186 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 it != enabled_experiments.end(); | 2363 it != enabled_experiments.end(); |
| 2363 ++it) { | 2364 ++it) { |
| 2364 const std::string& experiment_name = *it; | 2365 const std::string& experiment_name = *it; |
| 2365 NameToSwitchAndValueMap::const_iterator name_to_switch_it = | 2366 NameToSwitchAndValueMap::const_iterator name_to_switch_it = |
| 2366 name_to_switch_map.find(experiment_name); | 2367 name_to_switch_map.find(experiment_name); |
| 2367 if (name_to_switch_it == name_to_switch_map.end()) { | 2368 if (name_to_switch_it == name_to_switch_map.end()) { |
| 2368 NOTREACHED(); | 2369 NOTREACHED(); |
| 2369 continue; | 2370 continue; |
| 2370 } | 2371 } |
| 2371 | 2372 |
| 2373 #if defined(OS_CHROMEOS) |
| 2374 // On Chrome OS setting command line flag may make browser to restart on |
| 2375 // user login. As this flag eventually will be set to a significant number |
| 2376 // of users skip manual-enhanced-bookmarks to avoid restart. |
| 2377 if (experiment_name == "manual-enhanced-bookmarks") |
| 2378 continue; |
| 2379 #endif |
| 2380 |
| 2372 const std::pair<std::string, std::string>& | 2381 const std::pair<std::string, std::string>& |
| 2373 switch_and_value_pair = name_to_switch_it->second; | 2382 switch_and_value_pair = name_to_switch_it->second; |
| 2374 | 2383 |
| 2375 CHECK(!switch_and_value_pair.first.empty()); | 2384 CHECK(!switch_and_value_pair.first.empty()); |
| 2376 command_line->AppendSwitchASCII(switch_and_value_pair.first, | 2385 command_line->AppendSwitchASCII(switch_and_value_pair.first, |
| 2377 switch_and_value_pair.second); | 2386 switch_and_value_pair.second); |
| 2378 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second; | 2387 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second; |
| 2379 } | 2388 } |
| 2380 if (sentinels == kAddSentinels) { | 2389 if (sentinels == kAddSentinels) { |
| 2381 command_line->AppendSwitch(switches::kFlagSwitchesEnd); | 2390 command_line->AppendSwitch(switches::kFlagSwitchesEnd); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 } | 2502 } |
| 2494 | 2503 |
| 2495 const Experiment* GetExperiments(size_t* count) { | 2504 const Experiment* GetExperiments(size_t* count) { |
| 2496 *count = num_experiments; | 2505 *count = num_experiments; |
| 2497 return experiments; | 2506 return experiments; |
| 2498 } | 2507 } |
| 2499 | 2508 |
| 2500 } // namespace testing | 2509 } // namespace testing |
| 2501 | 2510 |
| 2502 } // namespace about_flags | 2511 } // namespace about_flags |
| OLD | NEW |