Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "cc/base/switches.h" | 20 #include "cc/base/switches.h" |
| 21 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | |
| 22 #include "chrome/browser/flags_storage.h" | 21 #include "chrome/browser/flags_storage.h" |
| 23 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
| 24 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
| 26 #include "components/autofill/core/common/autofill_switches.h" | 25 #include "components/autofill/core/common/autofill_switches.h" |
| 27 #include "components/cloud_devices/common/cloud_devices_switches.h" | 26 #include "components/cloud_devices/common/cloud_devices_switches.h" |
| 28 #include "components/metrics/metrics_hashes.h" | 27 #include "components/metrics/metrics_hashes.h" |
| 29 #include "components/nacl/common/nacl_switches.h" | 28 #include "components/nacl/common/nacl_switches.h" |
| 30 #include "components/omnibox/omnibox_switches.h" | 29 #include "components/omnibox/omnibox_switches.h" |
| 31 #include "components/proximity_auth/switches.h" | 30 #include "components/proximity_auth/switches.h" |
| (...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1668 #endif | 1667 #endif |
| 1669 { | 1668 { |
| 1670 "enhanced-bookmarks-experiment", | 1669 "enhanced-bookmarks-experiment", |
| 1671 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_NAME, | 1670 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_NAME, |
| 1672 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION, | 1671 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION, |
| 1673 kOsDesktop | kOsAndroid, | 1672 kOsDesktop | kOsAndroid, |
| 1674 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE( | 1673 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE( |
| 1675 switches::kEnhancedBookmarksExperiment, "1", | 1674 switches::kEnhancedBookmarksExperiment, "1", |
| 1676 switches::kEnhancedBookmarksExperiment, "0") | 1675 switches::kEnhancedBookmarksExperiment, "0") |
| 1677 }, | 1676 }, |
| 1678 { | |
| 1679 "manual-enhanced-bookmarks", | |
| 1680 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_NAME, | |
| 1681 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION, | |
| 1682 kOsDesktop | kOsAndroid, | |
| 1683 SINGLE_VALUE_TYPE(switches::kManualEnhancedBookmarks) | |
| 1684 }, | |
| 1685 { | |
| 1686 "manual-enhanced-bookmarks-optout", | |
| 1687 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_NAME, | |
| 1688 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION, | |
| 1689 kOsDesktop | kOsAndroid, | |
| 1690 SINGLE_VALUE_TYPE(switches::kManualEnhancedBookmarksOptout) | |
| 1691 }, | |
| 1692 #if defined(OS_ANDROID) | 1677 #if defined(OS_ANDROID) |
| 1693 { | 1678 { |
| 1694 "enable-zero-suggest-experiment", | 1679 "enable-zero-suggest-experiment", |
| 1695 IDS_FLAGS_ZERO_SUGGEST_EXPERIMENT_NAME, | 1680 IDS_FLAGS_ZERO_SUGGEST_EXPERIMENT_NAME, |
| 1696 IDS_FLAGS_ZERO_SUGGEST_EXPERIMENT_DESCRIPTION, | 1681 IDS_FLAGS_ZERO_SUGGEST_EXPERIMENT_DESCRIPTION, |
| 1697 kOsAndroid, | 1682 kOsAndroid, |
| 1698 MULTI_VALUE_TYPE(kZeroSuggestExperimentsChoices) | 1683 MULTI_VALUE_TYPE(kZeroSuggestExperimentsChoices) |
| 1699 }, | 1684 }, |
| 1700 { | 1685 { |
| 1701 "enable-reader-mode-toolbar-icon", | 1686 "enable-reader-mode-toolbar-icon", |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2366 flags_storage->SetFlags(new_enabled_experiments); | 2351 flags_storage->SetFlags(new_enabled_experiments); |
| 2367 } | 2352 } |
| 2368 | 2353 |
| 2369 void GetSanitizedEnabledFlags( | 2354 void GetSanitizedEnabledFlags( |
| 2370 FlagsStorage* flags_storage, std::set<std::string>* result) { | 2355 FlagsStorage* flags_storage, std::set<std::string>* result) { |
| 2371 SanitizeList(flags_storage); | 2356 SanitizeList(flags_storage); |
| 2372 *result = flags_storage->GetFlags(); | 2357 *result = flags_storage->GetFlags(); |
| 2373 } | 2358 } |
| 2374 | 2359 |
| 2375 bool SkipConditionalExperiment(const Experiment& experiment, | 2360 bool SkipConditionalExperiment(const Experiment& experiment, |
| 2376 FlagsStorage* flags_storage) { | 2361 FlagsStorage* flags_storage) { |
|
danduong
2015/03/18 03:16:03
Can we drop flags_stoage here from the list of par
| |
| 2377 if ((experiment.internal_name == std::string("manual-enhanced-bookmarks")) || | |
| 2378 (experiment.internal_name == | |
| 2379 std::string("manual-enhanced-bookmarks-optout"))) { | |
| 2380 return true; | |
| 2381 } | |
| 2382 | |
| 2383 #if defined(OS_ANDROID) || defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) | 2362 #if defined(OS_ANDROID) || defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) |
| 2384 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 2363 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 2385 #endif | 2364 #endif |
| 2386 | 2365 |
| 2387 #if defined(OS_ANDROID) | 2366 #if defined(OS_ANDROID) |
| 2388 // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel. | 2367 // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel. |
| 2389 if (!strcmp("enable-data-reduction-proxy-dev", experiment.internal_name) && | 2368 if (!strcmp("enable-data-reduction-proxy-dev", experiment.internal_name) && |
| 2390 channel != chrome::VersionInfo::CHANNEL_BETA && | 2369 channel != chrome::VersionInfo::CHANNEL_BETA && |
| 2391 channel != chrome::VersionInfo::CHANNEL_DEV) { | 2370 channel != chrome::VersionInfo::CHANNEL_DEV) { |
| 2392 return true; | 2371 return true; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2725 std::string())); | 2704 std::string())); |
| 2726 } | 2705 } |
| 2727 for (const std::string& experiment_name : enabled_experiments) { | 2706 for (const std::string& experiment_name : enabled_experiments) { |
| 2728 NameToSwitchAndValueMap::const_iterator name_to_switch_it = | 2707 NameToSwitchAndValueMap::const_iterator name_to_switch_it = |
| 2729 name_to_switch_map.find(experiment_name); | 2708 name_to_switch_map.find(experiment_name); |
| 2730 if (name_to_switch_it == name_to_switch_map.end()) { | 2709 if (name_to_switch_it == name_to_switch_map.end()) { |
| 2731 NOTREACHED(); | 2710 NOTREACHED(); |
| 2732 continue; | 2711 continue; |
| 2733 } | 2712 } |
| 2734 | 2713 |
| 2735 #if defined(OS_CHROMEOS) | |
| 2736 // On Chrome OS setting command line flag may make browser to restart on | |
| 2737 // user login. As this flag eventually will be set to a significant number | |
| 2738 // of users skip manual-enhanced-bookmarks to avoid restart. | |
| 2739 if (experiment_name == "manual-enhanced-bookmarks") | |
| 2740 continue; | |
| 2741 #endif | |
| 2742 | |
| 2743 const std::pair<std::string, std::string>& | 2714 const std::pair<std::string, std::string>& |
| 2744 switch_and_value_pair = name_to_switch_it->second; | 2715 switch_and_value_pair = name_to_switch_it->second; |
| 2745 | 2716 |
| 2746 CHECK(!switch_and_value_pair.first.empty()); | 2717 CHECK(!switch_and_value_pair.first.empty()); |
| 2747 command_line->AppendSwitchASCII(switch_and_value_pair.first, | 2718 command_line->AppendSwitchASCII(switch_and_value_pair.first, |
| 2748 switch_and_value_pair.second); | 2719 switch_and_value_pair.second); |
| 2749 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second; | 2720 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second; |
| 2750 } | 2721 } |
| 2751 if (sentinels == kAddSentinels) { | 2722 if (sentinels == kAddSentinels) { |
| 2752 command_line->AppendSwitch(switches::kFlagSwitchesEnd); | 2723 command_line->AppendSwitch(switches::kFlagSwitchesEnd); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2864 } | 2835 } |
| 2865 | 2836 |
| 2866 const Experiment* GetExperiments(size_t* count) { | 2837 const Experiment* GetExperiments(size_t* count) { |
| 2867 *count = num_experiments; | 2838 *count = num_experiments; |
| 2868 return experiments; | 2839 return experiments; |
| 2869 } | 2840 } |
| 2870 | 2841 |
| 2871 } // namespace testing | 2842 } // namespace testing |
| 2872 | 2843 |
| 2873 } // namespace about_flags | 2844 } // namespace about_flags |
| OLD | NEW |