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 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 SINGLE_VALUE_TYPE(views::switches::kViewsUseRectBasedTargeting) | 1825 SINGLE_VALUE_TYPE(views::switches::kViewsUseRectBasedTargeting) |
1825 }, | 1826 }, |
1826 #endif | 1827 #endif |
1827 { | 1828 { |
1828 "enable-apps-show-on-first-paint", | 1829 "enable-apps-show-on-first-paint", |
1829 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_NAME, | 1830 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_NAME, |
1830 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_DESCRIPTION, | 1831 IDS_FLAGS_ENABLE_APPS_SHOW_ON_FIRST_PAINT_DESCRIPTION, |
1831 kOsDesktop, | 1832 kOsDesktop, |
1832 SINGLE_VALUE_TYPE(switches::kEnableAppsShowOnFirstPaint) | 1833 SINGLE_VALUE_TYPE(switches::kEnableAppsShowOnFirstPaint) |
1833 }, | 1834 }, |
| 1835 { |
| 1836 "enable-enhanced-bookmarks", |
| 1837 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_NAME, |
| 1838 IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION, |
| 1839 kOsDesktop, |
| 1840 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(switches::kEnableEnhancedBookmarks, "1", |
| 1841 switches::kEnableEnhancedBookmarks, "0") |
| 1842 }, |
1834 }; | 1843 }; |
1835 | 1844 |
1836 const Experiment* experiments = kExperiments; | 1845 const Experiment* experiments = kExperiments; |
1837 size_t num_experiments = arraysize(kExperiments); | 1846 size_t num_experiments = arraysize(kExperiments); |
1838 | 1847 |
1839 // Stores and encapsulates the little state that about:flags has. | 1848 // Stores and encapsulates the little state that about:flags has. |
1840 class FlagsState { | 1849 class FlagsState { |
1841 public: | 1850 public: |
1842 FlagsState() : needs_restart_(false) {} | 1851 FlagsState() : needs_restart_(false) {} |
1843 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 1852 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 if (new_enabled_experiments != enabled_experiments) | 1935 if (new_enabled_experiments != enabled_experiments) |
1927 flags_storage->SetFlags(new_enabled_experiments); | 1936 flags_storage->SetFlags(new_enabled_experiments); |
1928 } | 1937 } |
1929 | 1938 |
1930 void GetSanitizedEnabledFlags( | 1939 void GetSanitizedEnabledFlags( |
1931 FlagsStorage* flags_storage, std::set<std::string>* result) { | 1940 FlagsStorage* flags_storage, std::set<std::string>* result) { |
1932 SanitizeList(flags_storage); | 1941 SanitizeList(flags_storage); |
1933 *result = flags_storage->GetFlags(); | 1942 *result = flags_storage->GetFlags(); |
1934 } | 1943 } |
1935 | 1944 |
| 1945 bool SkipConditionalExperiment(const Experiment& experiment) { |
| 1946 if (experiment.internal_name == std::string("enable-enhanced-bookmarks")) { |
| 1947 return !extensions::ExternalComponentLoader:: |
| 1948 IsEnhancedBookmarksExperimentEnabled(); |
| 1949 } |
| 1950 return false; |
| 1951 } |
| 1952 |
| 1953 |
1936 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't | 1954 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't |
1937 // enabled on the current platform. | 1955 // enabled on the current platform. |
1938 void GetSanitizedEnabledFlagsForCurrentPlatform( | 1956 void GetSanitizedEnabledFlagsForCurrentPlatform( |
1939 FlagsStorage* flags_storage, std::set<std::string>* result) { | 1957 FlagsStorage* flags_storage, std::set<std::string>* result) { |
1940 GetSanitizedEnabledFlags(flags_storage, result); | 1958 GetSanitizedEnabledFlags(flags_storage, result); |
1941 | 1959 |
1942 // Filter out any experiments that aren't enabled on the current platform. We | 1960 // Filter out any experiments that aren't enabled on the current platform. We |
1943 // don't remove these from prefs else syncing to a platform with a different | 1961 // don't remove these from prefs else syncing to a platform with a different |
1944 // set of experiments would be lossy. | 1962 // set of experiments would be lossy. |
1945 std::set<std::string> platform_experiments; | 1963 std::set<std::string> platform_experiments; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 FlagAccess access, | 2051 FlagAccess access, |
2034 base::ListValue* supported_experiments, | 2052 base::ListValue* supported_experiments, |
2035 base::ListValue* unsupported_experiments) { | 2053 base::ListValue* unsupported_experiments) { |
2036 std::set<std::string> enabled_experiments; | 2054 std::set<std::string> enabled_experiments; |
2037 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); | 2055 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); |
2038 | 2056 |
2039 int current_platform = GetCurrentPlatform(); | 2057 int current_platform = GetCurrentPlatform(); |
2040 | 2058 |
2041 for (size_t i = 0; i < num_experiments; ++i) { | 2059 for (size_t i = 0; i < num_experiments; ++i) { |
2042 const Experiment& experiment = experiments[i]; | 2060 const Experiment& experiment = experiments[i]; |
| 2061 if (SkipConditionalExperiment(experiment)) |
| 2062 continue; |
2043 | 2063 |
2044 DictionaryValue* data = new DictionaryValue(); | 2064 DictionaryValue* data = new DictionaryValue(); |
2045 data->SetString("internal_name", experiment.internal_name); | 2065 data->SetString("internal_name", experiment.internal_name); |
2046 data->SetString("name", | 2066 data->SetString("name", |
2047 l10n_util::GetStringUTF16(experiment.visible_name_id)); | 2067 l10n_util::GetStringUTF16(experiment.visible_name_id)); |
2048 data->SetString("description", | 2068 data->SetString("description", |
2049 l10n_util::GetStringUTF16( | 2069 l10n_util::GetStringUTF16( |
2050 experiment.visible_description_id)); | 2070 experiment.visible_description_id)); |
2051 | 2071 |
2052 ListValue* supported_platforms = new ListValue(); | 2072 ListValue* supported_platforms = new ListValue(); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2324 } | 2344 } |
2325 | 2345 |
2326 const Experiment* GetExperiments(size_t* count) { | 2346 const Experiment* GetExperiments(size_t* count) { |
2327 *count = num_experiments; | 2347 *count = num_experiments; |
2328 return experiments; | 2348 return experiments; |
2329 } | 2349 } |
2330 | 2350 |
2331 } // namespace testing | 2351 } // namespace testing |
2332 | 2352 |
2333 } // namespace about_flags | 2353 } // namespace about_flags |
OLD | NEW |