blob: fa8c868999f828fd1e3090b64e0697868cd5b404 [file] [log] [blame]
[email protected]1a47d7e2010-10-15 00:37:241// 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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_ABOUT_FLAGS_H_
6#define CHROME_BROWSER_ABOUT_FLAGS_H_
7#pragma once
8
[email protected]e2ddbc92010-10-15 20:02:079#include <map>
[email protected]1a47d7e2010-10-15 00:37:2410#include <string>
11
[email protected]e2ddbc92010-10-15 20:02:0712#include "base/command_line.h"
13
[email protected]1a47d7e2010-10-15 00:37:2414class ListValue;
15class PrefService;
16
17namespace about_flags {
18
[email protected]a314ee5a2010-10-26 21:23:2819// Enumeration of OSs.
20// This is exposed only for testing.
21enum { kOsMac = 1 << 0, kOsWin = 1 << 1, kOsLinux = 1 << 2 , kOsCrOS = 1 << 3 };
22
23// Experiment is used internally by about_flags to describe an experiment (and
24// for testing).
25// This is exposed only for testing.
26struct Experiment {
27 // The internal name of the experiment. This is never shown to the user.
28 // It _is_ however stored in the prefs file, so you shouldn't change the
29 // name of existing flags.
30 const char* internal_name;
31
32 // String id of the message containing the experiment's name.
33 int visible_name_id;
34
35 // String id of the message containing the experiment's description.
36 int visible_description_id;
37
38 // The platforms the experiment is available on
39 // Needs to be more than a compile-time #ifdef because of profile sync.
40 unsigned supported_platforms; // bitmask
41
42 // The commandline parameter that's added when this lab is active. This is
43 // different from |internal_name| so that the commandline flag can be
44 // renamed without breaking the prefs file.
45 const char* command_line;
46};
47
[email protected]1a47d7e2010-10-15 00:37:2448// Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the
49// commandline flags belonging to the active experiments to |command_line|.
50void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
51
52// Get a list of all available experiments. The caller owns the result.
53ListValue* GetFlagsExperimentsData(PrefService* prefs);
54
55// Returns true if one of the experiment flags has been flipped since startup.
56bool IsRestartNeededToCommitChanges();
57
58// Enables or disables the experiment with id |internal_name|.
59void SetExperimentEnabled(
60 PrefService* prefs, const std::string& internal_name, bool enable);
61
[email protected]e2ddbc92010-10-15 20:02:0762// Removes all switches that were added to a command line by a previous call to
63// |ConvertFlagsToSwitches()|.
64void RemoveFlagsSwitches(
65 std::map<std::string, CommandLine::StringType>* switch_list);
66
[email protected]a314ee5a2010-10-26 21:23:2867// Returns the value for the current platform. This is one of the values defined
68// by the OS enum above.
69// This is exposed only for testing.
70int GetCurrentPlatform();
71
[email protected]4bc5050c2010-11-18 17:55:5472// Sends UMA stats about experimental flag usage. This should be called once per
73// startup.
74void RecordUMAStatistics(const PrefService* prefs);
75
[email protected]e2ddbc92010-10-15 20:02:0776namespace testing {
77// Clears internal global state, for unit tests.
78void ClearState();
[email protected]a314ee5a2010-10-26 21:23:2879
80// Sets the list of experiments. Pass in NULL to use the default set. This does
81// NOT take ownership of the supplied Experiments.
82void SetExperiments(const Experiment* e, size_t count);
[email protected]e2ddbc92010-10-15 20:02:0783} // namespace testing
84
[email protected]1a47d7e2010-10-15 00:37:2485} // namespace about_flags
86
87#endif // CHROME_BROWSER_ABOUT_FLAGS_H_