blob: 2cce8903adcee8818c4225ae23c9ea9609febf1d [file] [log] [blame]
[email protected]9c7453d2012-01-21 00:45:401// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]1a47d7e2010-10-15 00:37:242// 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_
[email protected]1a47d7e2010-10-15 00:37:247
avie4d7b6f2015-12-26 00:59:188#include <stddef.h>
[email protected]4b66a7d2014-08-15 17:13:319#include <stdint.h>
10
[email protected]e2ddbc92010-10-15 20:02:0711#include <map>
[email protected]4b66a7d2014-08-15 17:13:3112#include <set>
[email protected]1a47d7e2010-10-15 00:37:2413#include <string>
jkrcalbf073372016-07-29 07:21:3114#include <vector>
[email protected]1a47d7e2010-10-15 00:37:2415
[email protected]e2ddbc92010-10-15 20:02:0716#include "base/command_line.h"
alemate0107c3272014-09-03 04:30:0417#include "base/metrics/histogram_base.h"
[email protected]e7463412013-06-10 22:53:4618#include "base/strings/string16.h"
sdefresne246c5642015-11-16 21:47:2919#include "components/flags_ui/feature_entry.h"
sdefresne0e566342015-11-24 08:55:4620#include "components/flags_ui/flags_state.h"
[email protected]1a47d7e2010-10-15 00:37:2421
[email protected]f3a1c642011-07-12 19:15:0322namespace base {
jkrcald1d20082016-07-14 15:04:2423class FeatureList;
[email protected]f3a1c642011-07-12 19:15:0324class ListValue;
25}
26
droger888be0b2015-10-01 14:28:5227namespace flags_ui {
[email protected]e6d1c4f2013-06-12 17:37:4028class FlagsStorage;
droger888be0b2015-10-01 14:28:5229}
30
31namespace about_flags {
[email protected]e6d1c4f2013-06-12 17:37:4032
asvitkinee9ed35e2015-10-14 22:33:5933// Reads the state from |flags_storage| and adds the command line flags
34// belonging to the active feature entries to |command_line|.
droger888be0b2015-10-01 14:28:5235void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
[email protected]2f3b1cc2014-03-17 23:07:1536 base::CommandLine* command_line,
sdefresne0e566342015-11-24 08:55:4637 flags_ui::SentinelsMode sentinels);
[email protected]1a47d7e2010-10-15 00:37:2438
jkrcald1d20082016-07-14 15:04:2439// Registers variations parameter values selected for features in about:flags.
40// The selected flags are retrieved from |flags_storage|, the registered
41// variation parameters are connected to their corresponding features in
jkrcalbf073372016-07-29 07:21:3142// |feature_list|. Returns the (possibly empty) list of additional variation ids
43// to register in the MetricsService that come from variations selected using
44// chrome://flags.
45std::vector<std::string> RegisterAllFeatureVariationParameters(
jkrcald1d20082016-07-14 15:04:2446 flags_ui::FlagsStorage* flags_storage,
47 base::FeatureList* feature_list);
jkrcal1383d1d2016-06-17 12:40:5648
[email protected]6d98abf2013-06-17 23:35:5149// Compares a set of switches of the two provided command line objects and
50// returns true if they are the same and false otherwise.
[email protected]4b66a7d2014-08-15 17:13:3151// If |out_difference| is not NULL, it's filled with set_symmetric_difference
52// between sets.
[email protected]6d98abf2013-06-17 23:35:5153bool AreSwitchesIdenticalToCurrentCommandLine(
[email protected]2f3b1cc2014-03-17 23:07:1554 const base::CommandLine& new_cmdline,
[email protected]4b66a7d2014-08-15 17:13:3155 const base::CommandLine& active_cmdline,
avi3ef9ec9e2014-12-22 22:50:1756 std::set<base::CommandLine::StringType>* out_difference);
[email protected]6d98abf2013-06-17 23:35:5157
asvitkinee9ed35e2015-10-14 22:33:5958// Gets the list of feature entries. Entries that are available for the current
59// platform are appended to |supported_entries|; all other entries are appended
60// to |unsupported_entries|.
61void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
sdefresne0e566342015-11-24 08:55:4662 flags_ui::FlagAccess access,
asvitkinee9ed35e2015-10-14 22:33:5963 base::ListValue* supported_entries,
64 base::ListValue* unsupported_entries);
[email protected]1a47d7e2010-10-15 00:37:2465
Yann Dagobaa08aa2019-07-29 20:52:3766// Gets the list of feature entries for enterprises. Entries that are available
67// for the current platform are appended to |supported_entries|; all other
68// entries are appended to |unsupported_entries|.
69void GetFlagFeatureEntriesForEnterprises(flags_ui::FlagsStorage* flags_storage,
70 flags_ui::FlagAccess access,
71 base::ListValue* supported_entries,
72 base::ListValue* unsupported_entries);
73
asvitkinee9ed35e2015-10-14 22:33:5974// Returns true if one of the feature entry flags has been flipped since
75// startup.
[email protected]1a47d7e2010-10-15 00:37:2476bool IsRestartNeededToCommitChanges();
77
asvitkinee9ed35e2015-10-14 22:33:5978// Enables or disables the current with id |internal_name|.
79void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
80 const std::string& internal_name,
81 bool enable);
[email protected]1a47d7e2010-10-15 00:37:2482
Mustafa Emre Acerb3aa36a82018-05-22 21:44:0583// Sets a flag value with a list of origins given by |value|. Origins in |value|
84// can be separated by a comma or whitespace. Invalid URLs will be dropped when
85// setting the command line flag.
86// E.g. SetOriginListFlag("test-flag",
87// "http://example.test1 http://example.test2",
88// flags_storage);
89// will add --test-flag=http://example.test to the command line.
90void SetOriginListFlag(const std::string& internal_name,
91 const std::string& value,
92 flags_ui::FlagsStorage* flags_storage);
93
[email protected]e2ddbc92010-10-15 20:02:0794// Removes all switches that were added to a command line by a previous call to
95// |ConvertFlagsToSwitches()|.
Jeremy Roman863386d2017-10-31 19:25:3896void RemoveFlagsSwitches(base::CommandLine::SwitchMap* switch_list);
[email protected]e2ddbc92010-10-15 20:02:0797
[email protected]cb93bf52013-02-20 01:20:0098// Reset all flags to the default state by clearing all flags.
droger888be0b2015-10-01 14:28:5299void ResetAllFlags(flags_ui::FlagsStorage* flags_storage);
[email protected]cb93bf52013-02-20 01:20:00100
[email protected]4bc5050c2010-11-18 17:55:54101// Sends UMA stats about experimental flag usage. This should be called once per
102// startup.
droger888be0b2015-10-01 14:28:52103void RecordUMAStatistics(flags_ui::FlagsStorage* flags_storage);
[email protected]4bc5050c2010-11-18 17:55:54104
[email protected]4b66a7d2014-08-15 17:13:31105// Returns the UMA id for the specified switch name.
alemate0107c3272014-09-03 04:30:04106base::HistogramBase::Sample GetSwitchUMAId(const std::string& switch_name);
[email protected]4b66a7d2014-08-15 17:13:31107
asvitkineab33c922016-08-30 20:34:19108// Sends stats (as UMA histogram) about a set of command line |flags| in
lawrencewu95059d1e2016-09-19 18:07:02109// a histogram, with an enum value for each flag in |switches| and |features|,
110// based on the hash of the flag name.
asvitkineab33c922016-08-30 20:34:19111void ReportAboutFlagsHistogram(const std::string& uma_histogram_name,
lawrencewu95059d1e2016-09-19 18:07:02112 const std::set<std::string>& switches,
113 const std::set<std::string>& features);
[email protected]4b66a7d2014-08-15 17:13:31114
[email protected]e2ddbc92010-10-15 20:02:07115namespace testing {
[email protected]83e9fa702013-02-25 19:30:44116
sdefresne0e566342015-11-24 08:55:46117// Returns the global set of feature entries.
sdefresne246c5642015-11-16 21:47:29118const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count);
[email protected]8a6ff28d2010-12-02 16:35:19119
asvitkinebff63b22014-11-25 01:03:52120// This value is reported as switch histogram ID if switch name has unknown
121// format.
122extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId;
123
[email protected]e2ddbc92010-10-15 20:02:07124} // namespace testing
125
[email protected]1a47d7e2010-10-15 00:37:24126} // namespace about_flags
127
128#endif // CHROME_BROWSER_ABOUT_FLAGS_H_