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 <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "cc/base/switches.h" | 19 #include "cc/base/switches.h" |
| 20 #include "chrome/browser/extensions/external_component_loader.h" |
20 #include "chrome/browser/flags_storage.h" | 21 #include "chrome/browser/flags_storage.h" |
21 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "components/nacl/common/nacl_switches.h" | 24 #include "components/nacl/common/nacl_switches.h" |
24 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
25 #include "extensions/common/switches.h" | 26 #include "extensions/common/switches.h" |
26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
28 #include "grit/google_chrome_strings.h" | 29 #include "grit/google_chrome_strings.h" |
29 #include "media/base/media_switches.h" | 30 #include "media/base/media_switches.h" |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 SINGLE_VALUE_TYPE(views::switches::kDisableViewsRectBasedTargeting) | 1823 SINGLE_VALUE_TYPE(views::switches::kDisableViewsRectBasedTargeting) |
1823 }, | 1824 }, |
1824 #endif | 1825 #endif |
1825 { | 1826 { |
1826 "enable-apps-show-on-first-paint", | 1827 "enable-apps-show-on-first-paint", |
1827 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_NAME, | 1828 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_NAME, |
1828 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_DESCRIPTION, | 1829 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_DESCRIPTION, |
1829 kOsDesktop, | 1830 kOsDesktop, |
1830 SINGLE_VALUE_TYPE(switches::kEnableAppsShowOnFirstPaint) | 1831 SINGLE_VALUE_TYPE(switches::kEnableAppsShowOnFirstPaint) |
1831 }, | 1832 }, |
| 1833 { |
| 1834 "enable-enhanced-bookmarks", |
| 1835 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_NAME, |
| 1836 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION, |
| 1837 kOsDesktop, |
| 1838 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(switches::kEnableEnhancedBookmarks, "1", |
| 1839 switches::kEnableEnhancedBookmarks, "0") |
| 1840 }, |
1832 }; | 1841 }; |
1833 | 1842 |
1834 const Experiment* experiments = kExperiments; | 1843 const Experiment* experiments = kExperiments; |
1835 size_t num_experiments = arraysize(kExperiments); | 1844 size_t num_experiments = arraysize(kExperiments); |
1836 | 1845 |
1837 // Stores and encapsulates the little state that about:flags has. | 1846 // Stores and encapsulates the little state that about:flags has. |
1838 class FlagsState { | 1847 class FlagsState { |
1839 public: | 1848 public: |
1840 FlagsState() : needs_restart_(false) {} | 1849 FlagsState() : needs_restart_(false) {} |
1841 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 1850 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 if (new_enabled_experiments != enabled_experiments) | 1933 if (new_enabled_experiments != enabled_experiments) |
1925 flags_storage->SetFlags(new_enabled_experiments); | 1934 flags_storage->SetFlags(new_enabled_experiments); |
1926 } | 1935 } |
1927 | 1936 |
1928 void GetSanitizedEnabledFlags( | 1937 void GetSanitizedEnabledFlags( |
1929 FlagsStorage* flags_storage, std::set<std::string>* result) { | 1938 FlagsStorage* flags_storage, std::set<std::string>* result) { |
1930 SanitizeList(flags_storage); | 1939 SanitizeList(flags_storage); |
1931 *result = flags_storage->GetFlags(); | 1940 *result = flags_storage->GetFlags(); |
1932 } | 1941 } |
1933 | 1942 |
| 1943 bool SkipConditionalExperiment(const Experiment& experiment) { |
| 1944 if (experiment.internal_name == std::string("enable-enhanced-bookmarks")) { |
| 1945 return !extensions::ExternalComponentLoader:: |
| 1946 IsEnhancedBookmarksExperimentEnabled(); |
| 1947 } |
| 1948 return false; |
| 1949 } |
| 1950 |
| 1951 |
1934 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't | 1952 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't |
1935 // enabled on the current platform. | 1953 // enabled on the current platform. |
1936 void GetSanitizedEnabledFlagsForCurrentPlatform( | 1954 void GetSanitizedEnabledFlagsForCurrentPlatform( |
1937 FlagsStorage* flags_storage, std::set<std::string>* result) { | 1955 FlagsStorage* flags_storage, std::set<std::string>* result) { |
1938 GetSanitizedEnabledFlags(flags_storage, result); | 1956 GetSanitizedEnabledFlags(flags_storage, result); |
1939 | 1957 |
1940 // Filter out any experiments that aren't enabled on the current platform. We | 1958 // Filter out any experiments that aren't enabled on the current platform. We |
1941 // don't remove these from prefs else syncing to a platform with a different | 1959 // don't remove these from prefs else syncing to a platform with a different |
1942 // set of experiments would be lossy. | 1960 // set of experiments would be lossy. |
1943 std::set<std::string> platform_experiments; | 1961 std::set<std::string> platform_experiments; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 FlagAccess access, | 2049 FlagAccess access, |
2032 base::ListValue* supported_experiments, | 2050 base::ListValue* supported_experiments, |
2033 base::ListValue* unsupported_experiments) { | 2051 base::ListValue* unsupported_experiments) { |
2034 std::set<std::string> enabled_experiments; | 2052 std::set<std::string> enabled_experiments; |
2035 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); | 2053 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); |
2036 | 2054 |
2037 int current_platform = GetCurrentPlatform(); | 2055 int current_platform = GetCurrentPlatform(); |
2038 | 2056 |
2039 for (size_t i = 0; i < num_experiments; ++i) { | 2057 for (size_t i = 0; i < num_experiments; ++i) { |
2040 const Experiment& experiment = experiments[i]; | 2058 const Experiment& experiment = experiments[i]; |
| 2059 if (SkipConditionalExperiment(experiment)) |
| 2060 continue; |
2041 | 2061 |
2042 DictionaryValue* data = new DictionaryValue(); | 2062 DictionaryValue* data = new DictionaryValue(); |
2043 data->SetString("internal_name", experiment.internal_name); | 2063 data->SetString("internal_name", experiment.internal_name); |
2044 data->SetString("name", | 2064 data->SetString("name", |
2045 l10n_util::GetStringUTF16(experiment.visible_name_id)); | 2065 l10n_util::GetStringUTF16(experiment.visible_name_id)); |
2046 data->SetString("description", | 2066 data->SetString("description", |
2047 l10n_util::GetStringUTF16( | 2067 l10n_util::GetStringUTF16( |
2048 experiment.visible_description_id)); | 2068 experiment.visible_description_id)); |
2049 | 2069 |
2050 ListValue* supported_platforms = new ListValue(); | 2070 ListValue* supported_platforms = new ListValue(); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2322 } | 2342 } |
2323 | 2343 |
2324 const Experiment* GetExperiments(size_t* count) { | 2344 const Experiment* GetExperiments(size_t* count) { |
2325 *count = num_experiments; | 2345 *count = num_experiments; |
2326 return experiments; | 2346 return experiments; |
2327 } | 2347 } |
2328 | 2348 |
2329 } // namespace testing | 2349 } // namespace testing |
2330 | 2350 |
2331 } // namespace about_flags | 2351 } // namespace about_flags |
OLD | NEW |