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

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

Issue 5025001: Removed Labs section from Chrome OS settings page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bound prefs and flags Created 10 years, 1 month 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
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>
11 11
12 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/singleton.h" 14 #include "base/singleton.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 20
21 namespace about_flags { 21 namespace about_flags {
22 22
23 namespace { 23 namespace {
24 24
25 const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS; 25 const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS;
26 26
27 // Names for former Chrome OS Labs experiments, shared with prefs migration
28 // code.
29 const char kMediaPlayerExperimentName[] = "media-player";
30 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
31 const char kVerticalTabsExperimentName[] = "vertical-tabs";
32
27 const Experiment kExperiments[] = { 33 const Experiment kExperiments[] = {
28 { 34 {
29 "expose-for-tabs", // Do not change; see above. 35 "expose-for-tabs", // Do not change; see above.
30 IDS_FLAGS_TABPOSE_NAME, 36 IDS_FLAGS_TABPOSE_NAME,
31 IDS_FLAGS_TABPOSE_DESCRIPTION, 37 IDS_FLAGS_TABPOSE_DESCRIPTION,
32 kOsMac, 38 kOsMac,
33 #if defined(OS_MACOSX) 39 #if defined(OS_MACOSX)
34 // The switch exists only on OS X. 40 // The switch exists only on OS X.
35 switches::kEnableExposeForTabs 41 switches::kEnableExposeForTabs
36 #else 42 #else
37 "" 43 ""
38 #endif 44 #endif
39 }, 45 },
40 { 46 {
41 "vertical-tabs", // Do not change; see above. 47 kMediaPlayerExperimentName,
48 IDS_FLAGS_MEDIA_PLAYER_NAME,
49 IDS_FLAGS_MEDIA_PLAYER_DESCRIPTION,
50 kOsCrOS,
51 #if defined(OS_CHROMEOS)
52 // The switch exists only on Chrome OS.
53 switches::kEnableMediaPlayer
54 #else
55 ""
56 #endif
57 },
58 {
59 kAdvancedFileSystemExperimentName,
60 IDS_FLAGS_ADVANCED_FS_NAME,
61 IDS_FLAGS_ADVANCED_FS_DESCRIPTION,
62 kOsCrOS,
63 #if defined(OS_CHROMEOS)
64 // The switch exists only on Chrome OS.
65 switches::kEnableAdvancedFileSystem
66 #else
67 ""
68 #endif
69 },
70 {
71 kVerticalTabsExperimentName,
42 IDS_FLAGS_SIDE_TABS_NAME, 72 IDS_FLAGS_SIDE_TABS_NAME,
43 IDS_FLAGS_SIDE_TABS_DESCRIPTION, 73 IDS_FLAGS_SIDE_TABS_DESCRIPTION,
44 // TODO(thakis): Move sidetabs to about:flags on ChromeOS 74 kOsWin | kOsCrOS,
45 // http://crbug.com/57634
46 kOsWin,
47 switches::kEnableVerticalTabs 75 switches::kEnableVerticalTabs
48 }, 76 },
49 { 77 {
50 "tabbed-options", // Do not change; see above. 78 "tabbed-options", // Do not change; see above.
51 IDS_FLAGS_TABBED_OPTIONS_NAME, 79 IDS_FLAGS_TABBED_OPTIONS_NAME,
52 IDS_FLAGS_TABBED_OPTIONS_DESCRIPTION, 80 IDS_FLAGS_TABBED_OPTIONS_DESCRIPTION,
53 kOsWin | kOsLinux | kOsMac, // Enabled by default on CrOS. 81 kOsWin | kOsLinux | kOsMac, // Enabled by default on CrOS.
54 switches::kEnableTabbedOptions 82 switches::kEnableTabbedOptions
55 }, 83 },
56 { 84 {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return Singleton<FlagsState>::get(); 249 return Singleton<FlagsState>::get();
222 } 250 }
223 251
224 private: 252 private:
225 bool needs_restart_; 253 bool needs_restart_;
226 std::set<std::string> flags_switches_; 254 std::set<std::string> flags_switches_;
227 255
228 DISALLOW_COPY_AND_ASSIGN(FlagsState); 256 DISALLOW_COPY_AND_ASSIGN(FlagsState);
229 }; 257 };
230 258
259 #if defined(OS_CHROMEOS)
260 void MigrateChromeOSLabsPrefs(const PrefService* prefs,
261 std::set<std::string>* result) {
262 DCHECK(prefs);
263 DCHECK(result);
264 if (prefs->GetBoolean(prefs::kLabsMediaplayerEnabled))
265 result->insert(kMediaPlayerExperimentName);
266 if (prefs->GetBoolean(prefs::kLabsAdvancedFilesystemEnabled))
267 result->insert(kAdvancedFileSystemExperimentName);
268 if (prefs->GetBoolean(prefs::kUseVerticalTabs))
269 result->insert(kVerticalTabsExperimentName);
Nico 2010/11/16 17:32:07 do you want to remove the booleans from |prefs| af
whywhat 2010/11/16 17:55:15 Can I remove them? I only found how I can set them
Nico 2010/11/16 18:01:31 PrefService::ClearPref
whywhat 2010/11/16 18:05:03 This sets the value to default one. If it ever bec
270 }
271 #endif
272
231 // Extracts the list of enabled lab experiments from preferences and stores them 273 // Extracts the list of enabled lab experiments from preferences and stores them
232 // in a set. 274 // in a set.
233 void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) { 275 void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
234 const ListValue* enabled_experiments = prefs->GetList( 276 const ListValue* enabled_experiments = prefs->GetList(
235 prefs::kEnabledLabsExperiments); 277 prefs::kEnabledLabsExperiments);
236 if (!enabled_experiments) 278 if (!enabled_experiments)
237 return; 279 return;
238 280
239 for (ListValue::const_iterator it = enabled_experiments->begin(); 281 for (ListValue::const_iterator it = enabled_experiments->begin();
240 it != enabled_experiments->end(); 282 it != enabled_experiments->end();
241 ++it) { 283 ++it) {
242 std::string experiment_name; 284 std::string experiment_name;
243 if (!(*it)->GetAsString(&experiment_name)) { 285 if (!(*it)->GetAsString(&experiment_name)) {
244 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments; 286 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
245 continue; 287 continue;
246 } 288 }
247 result->insert(experiment_name); 289 result->insert(experiment_name);
248 } 290 }
291
292 #if defined(OS_CHROMEOS)
293 // Some experiments were implemented via prefs on Chrome OS and we want to
294 // seamlessly migrate these prefs to about:flags for updated users.
295 MigrateChromeOSLabsPrefs(prefs, result);
Nico 2010/11/16 17:32:07 I'd do this at the spot marked XXX below instead.
whywhat 2010/11/16 17:55:15 Done.
296 #endif
249 } 297 }
250 298
251 // Takes a set of enabled lab experiments 299 // Takes a set of enabled lab experiments
252 void SetEnabledFlags( 300 void SetEnabledFlags(
253 PrefService* prefs, const std::set<std::string>& enabled_experiments) { 301 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
254 ListValue* experiments_list = prefs->GetMutableList( 302 ListValue* experiments_list = prefs->GetMutableList(
255 prefs::kEnabledLabsExperiments); 303 prefs::kEnabledLabsExperiments);
256 if (!experiments_list) 304 if (!experiments_list)
257 return; 305 return;
258 306
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 ////////////////////////////////////////////////////////////////////////////// 427 //////////////////////////////////////////////////////////////////////////////
380 // FlagsState implementation. 428 // FlagsState implementation.
381 429
382 namespace { 430 namespace {
383 431
384 void FlagsState::ConvertFlagsToSwitches( 432 void FlagsState::ConvertFlagsToSwitches(
385 PrefService* prefs, CommandLine* command_line) { 433 PrefService* prefs, CommandLine* command_line) {
386 if (command_line->HasSwitch(switches::kNoExperiments)) 434 if (command_line->HasSwitch(switches::kNoExperiments))
387 return; 435 return;
388 436
389 std::set<std::string> enabled_experiments; 437 std::set<std::string> enabled_experiments;
Nico 2010/11/16 17:32:07 XXX
whywhat 2010/11/16 17:55:15 Done.
390 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments); 438 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
391 439
392 std::map<std::string, const Experiment*> experiment_map; 440 std::map<std::string, const Experiment*> experiment_map;
393 for (size_t i = 0; i < num_experiments; ++i) 441 for (size_t i = 0; i < num_experiments; ++i)
394 experiment_map[experiments[i].internal_name] = &experiments[i]; 442 experiment_map[experiments[i].internal_name] = &experiments[i];
395 443
396 command_line->AppendSwitch(switches::kFlagSwitchesBegin); 444 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
397 flags_switches_.insert(switches::kFlagSwitchesBegin); 445 flags_switches_.insert(switches::kFlagSwitchesBegin);
398 for (std::set<std::string>::iterator it = enabled_experiments.begin(); 446 for (std::set<std::string>::iterator it = enabled_experiments.begin();
399 it != enabled_experiments.end(); 447 it != enabled_experiments.end();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 num_experiments = arraysize(kExperiments); 506 num_experiments = arraysize(kExperiments);
459 } else { 507 } else {
460 experiments = e; 508 experiments = e;
461 num_experiments = count; 509 num_experiments = count;
462 } 510 }
463 } 511 }
464 512
465 } // namespace testing 513 } // namespace testing
466 514
467 } // namespace about_flags 515 } // namespace about_flags
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698