Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/browser/about_flags.cc

Issue 6389002: Patch to restore 6267009 (move about:flags from profile to local state) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return Singleton<FlagsState>::get(); 307 return Singleton<FlagsState>::get();
308 } 308 }
309 309
310 private: 310 private:
311 bool needs_restart_; 311 bool needs_restart_;
312 std::set<std::string> flags_switches_; 312 std::set<std::string> flags_switches_;
313 313
314 DISALLOW_COPY_AND_ASSIGN(FlagsState); 314 DISALLOW_COPY_AND_ASSIGN(FlagsState);
315 }; 315 };
316 316
317 #if defined(OS_CHROMEOS)
318 // Migrates Chrome OS Labs settings to experiments adding flags to enabled
319 // experiment list if the corresponding pref is on.
320 void MigrateChromeOSLabsPrefs(PrefService* prefs,
321 std::set<std::string>* result) {
322 DCHECK(prefs);
323 DCHECK(result);
324 if (prefs->GetBoolean(prefs::kLabsMediaplayerEnabled))
325 result->insert(kMediaPlayerExperimentName);
326 if (prefs->GetBoolean(prefs::kLabsAdvancedFilesystemEnabled))
327 result->insert(kAdvancedFileSystemExperimentName);
328 if (prefs->GetBoolean(prefs::kUseVerticalTabs))
329 result->insert(kVerticalTabsExperimentName);
330 prefs->SetBoolean(prefs::kLabsMediaplayerEnabled, false);
331 prefs->SetBoolean(prefs::kLabsAdvancedFilesystemEnabled, false);
332 prefs->SetBoolean(prefs::kUseVerticalTabs, false);
333 }
334 #endif
335
336 // Extracts the list of enabled lab experiments from preferences and stores them 317 // Extracts the list of enabled lab experiments from preferences and stores them
337 // in a set. 318 // in a set.
338 void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) { 319 void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
339 const ListValue* enabled_experiments = prefs->GetList( 320 const ListValue* enabled_experiments = prefs->GetList(
340 prefs::kEnabledLabsExperiments); 321 prefs::kEnabledLabsExperiments);
341 if (!enabled_experiments) 322 if (!enabled_experiments)
342 return; 323 return;
343 324
344 for (ListValue::const_iterator it = enabled_experiments->begin(); 325 for (ListValue::const_iterator it = enabled_experiments->begin();
345 it != enabled_experiments->end(); 326 it != enabled_experiments->end();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 531
551 namespace { 532 namespace {
552 533
553 void FlagsState::ConvertFlagsToSwitches( 534 void FlagsState::ConvertFlagsToSwitches(
554 PrefService* prefs, CommandLine* command_line) { 535 PrefService* prefs, CommandLine* command_line) {
555 if (command_line->HasSwitch(switches::kNoExperiments)) 536 if (command_line->HasSwitch(switches::kNoExperiments))
556 return; 537 return;
557 538
558 std::set<std::string> enabled_experiments; 539 std::set<std::string> enabled_experiments;
559 540
560 #if defined(OS_CHROMEOS)
561 // Some experiments were implemented via prefs on Chrome OS and we want to
562 // seamlessly migrate these prefs to about:flags for updated users.
563 MigrateChromeOSLabsPrefs(prefs, &enabled_experiments);
564 #endif
565
566 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments); 541 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
567 542
568 typedef std::map<std::string, std::string> NameToSwitchMap; 543 typedef std::map<std::string, std::string> NameToSwitchMap;
569 NameToSwitchMap name_to_switch_map; 544 NameToSwitchMap name_to_switch_map;
570 for (size_t i = 0; i < num_experiments; ++i) { 545 for (size_t i = 0; i < num_experiments; ++i) {
571 const Experiment& e = experiments[i]; 546 const Experiment& e = experiments[i];
572 if (e.type == Experiment::SINGLE_VALUE) { 547 if (e.type == Experiment::SINGLE_VALUE) {
573 name_to_switch_map[e.internal_name] = e.command_line; 548 name_to_switch_map[e.internal_name] = e.command_line;
574 } else { 549 } else {
575 for (int j = 0; j < e.num_choices; ++j) 550 for (int j = 0; j < e.num_choices; ++j)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 } 671 }
697 672
698 const Experiment* GetExperiments(size_t* count) { 673 const Experiment* GetExperiments(size_t* count) {
699 *count = num_experiments; 674 *count = num_experiments;
700 return experiments; 675 return experiments;
701 } 676 }
702 677
703 } // namespace testing 678 } // namespace testing
704 679
705 } // namespace about_flags 680 } // namespace about_flags
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698