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> |
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 // Stores and encapsulates the little state that about:flags has. | 1286 // Stores and encapsulates the little state that about:flags has. |
1287 class FlagsState { | 1287 class FlagsState { |
1288 public: | 1288 public: |
1289 FlagsState() : needs_restart_(false) {} | 1289 FlagsState() : needs_restart_(false) {} |
1290 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); | 1290 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); |
1291 bool IsRestartNeededToCommitChanges(); | 1291 bool IsRestartNeededToCommitChanges(); |
1292 void SetExperimentEnabled( | 1292 void SetExperimentEnabled( |
1293 PrefService* prefs, const std::string& internal_name, bool enable); | 1293 PrefService* prefs, const std::string& internal_name, bool enable); |
1294 void RemoveFlagsSwitches( | 1294 void RemoveFlagsSwitches( |
1295 std::map<std::string, CommandLine::StringType>* switch_list); | 1295 std::map<std::string, CommandLine::StringType>* switch_list); |
| 1296 void ResetAllFlags(PrefService* prefs); |
1296 void reset(); | 1297 void reset(); |
1297 | 1298 |
1298 // Returns the singleton instance of this class | 1299 // Returns the singleton instance of this class |
1299 static FlagsState* GetInstance() { | 1300 static FlagsState* GetInstance() { |
1300 return Singleton<FlagsState>::get(); | 1301 return Singleton<FlagsState>::get(); |
1301 } | 1302 } |
1302 | 1303 |
1303 private: | 1304 private: |
1304 bool needs_restart_; | 1305 bool needs_restart_; |
1305 std::map<std::string, std::string> flags_switches_; | 1306 std::map<std::string, std::string> flags_switches_; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 void SetExperimentEnabled( | 1508 void SetExperimentEnabled( |
1508 PrefService* prefs, const std::string& internal_name, bool enable) { | 1509 PrefService* prefs, const std::string& internal_name, bool enable) { |
1509 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable); | 1510 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable); |
1510 } | 1511 } |
1511 | 1512 |
1512 void RemoveFlagsSwitches( | 1513 void RemoveFlagsSwitches( |
1513 std::map<std::string, CommandLine::StringType>* switch_list) { | 1514 std::map<std::string, CommandLine::StringType>* switch_list) { |
1514 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list); | 1515 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list); |
1515 } | 1516 } |
1516 | 1517 |
| 1518 void ResetAllFlags(PrefService* prefs) { |
| 1519 FlagsState::GetInstance()->ResetAllFlags(prefs); |
| 1520 } |
| 1521 |
1517 int GetCurrentPlatform() { | 1522 int GetCurrentPlatform() { |
1518 #if defined(OS_MACOSX) | 1523 #if defined(OS_MACOSX) |
1519 return kOsMac; | 1524 return kOsMac; |
1520 #elif defined(OS_WIN) | 1525 #elif defined(OS_WIN) |
1521 return kOsWin; | 1526 return kOsWin; |
1522 #elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check. | 1527 #elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check. |
1523 return kOsCrOS; | 1528 return kOsCrOS; |
1524 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 1529 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
1525 return kOsLinux; | 1530 return kOsLinux; |
1526 #elif defined(OS_ANDROID) | 1531 #elif defined(OS_ANDROID) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 } | 1677 } |
1673 | 1678 |
1674 void FlagsState::RemoveFlagsSwitches( | 1679 void FlagsState::RemoveFlagsSwitches( |
1675 std::map<std::string, CommandLine::StringType>* switch_list) { | 1680 std::map<std::string, CommandLine::StringType>* switch_list) { |
1676 for (std::map<std::string, std::string>::const_iterator | 1681 for (std::map<std::string, std::string>::const_iterator |
1677 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) { | 1682 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) { |
1678 switch_list->erase(it->first); | 1683 switch_list->erase(it->first); |
1679 } | 1684 } |
1680 } | 1685 } |
1681 | 1686 |
| 1687 void FlagsState::ResetAllFlags(PrefService* prefs) { |
| 1688 needs_restart_ = true; |
| 1689 |
| 1690 std::set<std::string> no_experiments; |
| 1691 SetEnabledFlags(prefs, no_experiments); |
| 1692 } |
| 1693 |
1682 void FlagsState::reset() { | 1694 void FlagsState::reset() { |
1683 needs_restart_ = false; | 1695 needs_restart_ = false; |
1684 flags_switches_.clear(); | 1696 flags_switches_.clear(); |
1685 } | 1697 } |
1686 | 1698 |
1687 } // namespace | 1699 } // namespace |
1688 | 1700 |
1689 namespace testing { | 1701 namespace testing { |
1690 | 1702 |
1691 // WARNING: '@' is also used in the html file. If you update this constant you | 1703 // WARNING: '@' is also used in the html file. If you update this constant you |
(...skipping 15 matching lines...) Expand all Loading... |
1707 } | 1719 } |
1708 | 1720 |
1709 const Experiment* GetExperiments(size_t* count) { | 1721 const Experiment* GetExperiments(size_t* count) { |
1710 *count = num_experiments; | 1722 *count = num_experiments; |
1711 return experiments; | 1723 return experiments; |
1712 } | 1724 } |
1713 | 1725 |
1714 } // namespace testing | 1726 } // namespace testing |
1715 | 1727 |
1716 } // namespace about_flags | 1728 } // namespace about_flags |
OLD | NEW |