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> |
| (...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1926 { | 1926 { |
| 1927 "enable-data-reduction-proxy-dev", | 1927 "enable-data-reduction-proxy-dev", |
| 1928 IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_DEV_NAME, | 1928 IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_DEV_NAME, |
| 1929 IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_DEV_DESCRIPTION, | 1929 IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_DEV_DESCRIPTION, |
| 1930 kOsAndroid, | 1930 kOsAndroid, |
| 1931 ENABLE_DISABLE_VALUE_TYPE( | 1931 ENABLE_DISABLE_VALUE_TYPE( |
| 1932 data_reduction_proxy::switches::kEnableDataReductionProxyDev, | 1932 data_reduction_proxy::switches::kEnableDataReductionProxyDev, |
| 1933 data_reduction_proxy::switches::kDisableDataReductionProxyDev) | 1933 data_reduction_proxy::switches::kDisableDataReductionProxyDev) |
| 1934 }, | 1934 }, |
| 1935 #endif | 1935 #endif |
| 1936 | |
| 1937 // Add new choice before this line. | |
| 1938 // | |
| 1939 // If it can be used on ChromeOS, please also add it to | |
| 1940 // chrome/browser/chromeos/login/report_custom_flags.cc | |
|
sky
2014/06/19 20:23:28
This is not maintainable. You need to come up with
Alexander Alekseev
2014/06/20 18:42:45
We need histogram here to know which flags lead to
| |
| 1936 }; | 1941 }; |
| 1937 | 1942 |
| 1938 const Experiment* experiments = kExperiments; | 1943 const Experiment* experiments = kExperiments; |
| 1939 size_t num_experiments = arraysize(kExperiments); | 1944 size_t num_experiments = arraysize(kExperiments); |
| 1940 | 1945 |
| 1941 // Stores and encapsulates the little state that about:flags has. | 1946 // Stores and encapsulates the little state that about:flags has. |
| 1942 class FlagsState { | 1947 class FlagsState { |
| 1943 public: | 1948 public: |
| 1944 FlagsState() : needs_restart_(false) {} | 1949 FlagsState() : needs_restart_(false) {} |
| 1945 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 1950 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2137 | 2142 |
| 2138 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 2143 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
| 2139 CommandLine* command_line, | 2144 CommandLine* command_line, |
| 2140 SentinelsMode sentinels) { | 2145 SentinelsMode sentinels) { |
| 2141 FlagsState::GetInstance()->ConvertFlagsToSwitches(flags_storage, | 2146 FlagsState::GetInstance()->ConvertFlagsToSwitches(flags_storage, |
| 2142 command_line, | 2147 command_line, |
| 2143 sentinels); | 2148 sentinels); |
| 2144 } | 2149 } |
| 2145 | 2150 |
| 2146 bool AreSwitchesIdenticalToCurrentCommandLine( | 2151 bool AreSwitchesIdenticalToCurrentCommandLine( |
| 2147 const CommandLine& new_cmdline, const CommandLine& active_cmdline) { | 2152 const CommandLine& new_cmdline, |
| 2153 const CommandLine& active_cmdline, | |
| 2154 std::set<CommandLine::StringType>* out_difference) { | |
| 2148 std::set<CommandLine::StringType> new_flags = | 2155 std::set<CommandLine::StringType> new_flags = |
| 2149 ExtractFlagsFromCommandLine(new_cmdline); | 2156 ExtractFlagsFromCommandLine(new_cmdline); |
| 2150 std::set<CommandLine::StringType> active_flags = | 2157 std::set<CommandLine::StringType> active_flags = |
| 2151 ExtractFlagsFromCommandLine(active_cmdline); | 2158 ExtractFlagsFromCommandLine(active_cmdline); |
| 2152 | 2159 |
| 2160 bool result = true; | |
| 2153 // Needed because std::equal doesn't check if the 2nd set is empty. | 2161 // Needed because std::equal doesn't check if the 2nd set is empty. |
| 2154 if (new_flags.size() != active_flags.size()) | 2162 if (new_flags.size() != active_flags.size()) { |
| 2155 return false; | 2163 result = false; |
| 2164 } else { | |
| 2165 result = | |
| 2166 std::equal(new_flags.begin(), new_flags.end(), active_flags.begin()); | |
| 2167 } | |
| 2156 | 2168 |
| 2157 return std::equal(new_flags.begin(), new_flags.end(), active_flags.begin()); | 2169 if (out_difference && !result) { |
| 2170 std::set_symmetric_difference( | |
| 2171 new_flags.begin(), | |
| 2172 new_flags.end(), | |
| 2173 active_flags.begin(), | |
| 2174 active_flags.end(), | |
| 2175 std::inserter(*out_difference, out_difference->begin())); | |
| 2176 } | |
| 2177 | |
| 2178 return result; | |
| 2158 } | 2179 } |
| 2159 | 2180 |
| 2160 void GetFlagsExperimentsData(FlagsStorage* flags_storage, | 2181 void GetFlagsExperimentsData(FlagsStorage* flags_storage, |
| 2161 FlagAccess access, | 2182 FlagAccess access, |
| 2162 base::ListValue* supported_experiments, | 2183 base::ListValue* supported_experiments, |
| 2163 base::ListValue* unsupported_experiments) { | 2184 base::ListValue* unsupported_experiments) { |
| 2164 std::set<std::string> enabled_experiments; | 2185 std::set<std::string> enabled_experiments; |
| 2165 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); | 2186 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); |
| 2166 | 2187 |
| 2167 int current_platform = GetCurrentPlatform(); | 2188 int current_platform = GetCurrentPlatform(); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2454 } | 2475 } |
| 2455 | 2476 |
| 2456 const Experiment* GetExperiments(size_t* count) { | 2477 const Experiment* GetExperiments(size_t* count) { |
| 2457 *count = num_experiments; | 2478 *count = num_experiments; |
| 2458 return experiments; | 2479 return experiments; |
| 2459 } | 2480 } |
| 2460 | 2481 |
| 2461 } // namespace testing | 2482 } // namespace testing |
| 2462 | 2483 |
| 2463 } // namespace about_flags | 2484 } // namespace about_flags |
| OLD | NEW |