| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 FlagsState() : needs_restart_(false) {} | 298 FlagsState() : needs_restart_(false) {} |
| 299 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); | 299 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); |
| 300 bool IsRestartNeededToCommitChanges(); | 300 bool IsRestartNeededToCommitChanges(); |
| 301 void SetExperimentEnabled( | 301 void SetExperimentEnabled( |
| 302 PrefService* prefs, const std::string& internal_name, bool enable); | 302 PrefService* prefs, const std::string& internal_name, bool enable); |
| 303 void RemoveFlagsSwitches( | 303 void RemoveFlagsSwitches( |
| 304 std::map<std::string, CommandLine::StringType>* switch_list); | 304 std::map<std::string, CommandLine::StringType>* switch_list); |
| 305 void reset(); | 305 void reset(); |
| 306 | 306 |
| 307 // Returns the singleton instance of this class | 307 // Returns the singleton instance of this class |
| 308 static FlagsState* instance() { | 308 static FlagsState* GetInstance() { |
| 309 return Singleton<FlagsState>::get(); | 309 return Singleton<FlagsState>::get(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 private: | 312 private: |
| 313 bool needs_restart_; | 313 bool needs_restart_; |
| 314 std::set<std::string> flags_switches_; | 314 std::set<std::string> flags_switches_; |
| 315 | 315 |
| 316 DISALLOW_COPY_AND_ASSIGN(FlagsState); | 316 DISALLOW_COPY_AND_ASSIGN(FlagsState); |
| 317 }; | 317 }; |
| 318 | 318 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 *is_one_selected = true; | 460 *is_one_selected = true; |
| 461 value->SetBoolean("selected", is_selected); | 461 value->SetBoolean("selected", is_selected); |
| 462 result->Append(value); | 462 result->Append(value); |
| 463 } | 463 } |
| 464 return result; | 464 return result; |
| 465 } | 465 } |
| 466 | 466 |
| 467 } // namespace | 467 } // namespace |
| 468 | 468 |
| 469 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) { | 469 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) { |
| 470 FlagsState::instance()->ConvertFlagsToSwitches(prefs, command_line); | 470 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line); |
| 471 } | 471 } |
| 472 | 472 |
| 473 ListValue* GetFlagsExperimentsData(PrefService* prefs) { | 473 ListValue* GetFlagsExperimentsData(PrefService* prefs) { |
| 474 std::set<std::string> enabled_experiments; | 474 std::set<std::string> enabled_experiments; |
| 475 GetSanitizedEnabledFlags(prefs, &enabled_experiments); | 475 GetSanitizedEnabledFlags(prefs, &enabled_experiments); |
| 476 | 476 |
| 477 int current_platform = GetCurrentPlatform(); | 477 int current_platform = GetCurrentPlatform(); |
| 478 | 478 |
| 479 ListValue* experiments_data = new ListValue(); | 479 ListValue* experiments_data = new ListValue(); |
| 480 for (size_t i = 0; i < num_experiments; ++i) { | 480 for (size_t i = 0; i < num_experiments; ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 497 &enabled)); | 497 &enabled)); |
| 498 } | 498 } |
| 499 | 499 |
| 500 data->SetBoolean("enabled", enabled); | 500 data->SetBoolean("enabled", enabled); |
| 501 experiments_data->Append(data); | 501 experiments_data->Append(data); |
| 502 } | 502 } |
| 503 return experiments_data; | 503 return experiments_data; |
| 504 } | 504 } |
| 505 | 505 |
| 506 bool IsRestartNeededToCommitChanges() { | 506 bool IsRestartNeededToCommitChanges() { |
| 507 return FlagsState::instance()->IsRestartNeededToCommitChanges(); | 507 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void SetExperimentEnabled( | 510 void SetExperimentEnabled( |
| 511 PrefService* prefs, const std::string& internal_name, bool enable) { | 511 PrefService* prefs, const std::string& internal_name, bool enable) { |
| 512 FlagsState::instance()->SetExperimentEnabled(prefs, internal_name, enable); | 512 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void RemoveFlagsSwitches( | 515 void RemoveFlagsSwitches( |
| 516 std::map<std::string, CommandLine::StringType>* switch_list) { | 516 std::map<std::string, CommandLine::StringType>* switch_list) { |
| 517 FlagsState::instance()->RemoveFlagsSwitches(switch_list); | 517 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list); |
| 518 } | 518 } |
| 519 | 519 |
| 520 int GetCurrentPlatform() { | 520 int GetCurrentPlatform() { |
| 521 #if defined(OS_MACOSX) | 521 #if defined(OS_MACOSX) |
| 522 return kOsMac; | 522 return kOsMac; |
| 523 #elif defined(OS_WIN) | 523 #elif defined(OS_WIN) |
| 524 return kOsWin; | 524 return kOsWin; |
| 525 #elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check. | 525 #elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check. |
| 526 return kOsCrOS; | 526 return kOsCrOS; |
| 527 #elif defined(OS_LINUX) | 527 #elif defined(OS_LINUX) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 676 |
| 677 } // namespace | 677 } // namespace |
| 678 | 678 |
| 679 namespace testing { | 679 namespace testing { |
| 680 | 680 |
| 681 // WARNING: '@' is also used in the html file. If you update this constant you | 681 // WARNING: '@' is also used in the html file. If you update this constant you |
| 682 // also need to update the html file. | 682 // also need to update the html file. |
| 683 const char kMultiSeparator[] = "@"; | 683 const char kMultiSeparator[] = "@"; |
| 684 | 684 |
| 685 void ClearState() { | 685 void ClearState() { |
| 686 FlagsState::instance()->reset(); | 686 FlagsState::GetInstance()->reset(); |
| 687 } | 687 } |
| 688 | 688 |
| 689 void SetExperiments(const Experiment* e, size_t count) { | 689 void SetExperiments(const Experiment* e, size_t count) { |
| 690 if (!e) { | 690 if (!e) { |
| 691 experiments = kExperiments; | 691 experiments = kExperiments; |
| 692 num_experiments = arraysize(kExperiments); | 692 num_experiments = arraysize(kExperiments); |
| 693 } else { | 693 } else { |
| 694 experiments = e; | 694 experiments = e; |
| 695 num_experiments = count; | 695 num_experiments = count; |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 | 698 |
| 699 const Experiment* GetExperiments(size_t* count) { | 699 const Experiment* GetExperiments(size_t* count) { |
| 700 *count = num_experiments; | 700 *count = num_experiments; |
| 701 return experiments; | 701 return experiments; |
| 702 } | 702 } |
| 703 | 703 |
| 704 } // namespace testing | 704 } // namespace testing |
| 705 | 705 |
| 706 } // namespace about_flags | 706 } // namespace about_flags |
| OLD | NEW |