File: about_flags.h

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (140 lines) | stat: -rw-r--r-- 5,453 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_ABOUT_FLAGS_H_
#define CHROME_BROWSER_ABOUT_FLAGS_H_

#include <stddef.h>
#include <stdint.h>

#include <map>
#include <set>
#include <string>
#include <vector>

#include "base/command_line.h"
#include "base/containers/span.h"
#include "base/metrics/histogram_base.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/webui/flags/feature_entry.h"
#include "components/webui/flags/flags_state.h"

class Profile;

namespace base {
class FeatureList;
}

namespace flags_ui {
class FlagsStorage;
}

namespace about_flags {

// This method returns the FlagsStorage instance to use for this platform. In
// addition, this returns the access level for the flags. The callback may be
// synchronously invoked.
// Note that |profile| is only used in ash-chrome.
using GetStorageCallback =
    base::OnceCallback<void(std::unique_ptr<flags_ui::FlagsStorage> storage,
                            flags_ui::FlagAccess access)>;
void GetStorage(Profile* profile, GetStorageCallback callback);

// Returns true if the FeatureEntry should not be shown.
bool ShouldSkipConditionalFeatureEntry(const flags_ui::FlagsStorage* storage,
                                       const flags_ui::FeatureEntry& entry);

// Reads the state from |flags_storage| and adds the command line flags
// belonging to the active feature entries to |command_line|.
void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
                            base::CommandLine* command_line,
                            flags_ui::SentinelsMode sentinels);

// Registers variations parameter values selected for features in about:flags.
// The selected flags are retrieved from |flags_storage|, the registered
// variation parameters are connected to their corresponding features in
// |feature_list|. Returns the (possibly empty) list of additional variation ids
// to register in the MetricsService that come from variations selected using
// chrome://flags.
std::vector<std::string> RegisterAllFeatureVariationParameters(
    flags_ui::FlagsStorage* flags_storage,
    base::FeatureList* feature_list);

// Gets the list of feature entries. Entries that are available for the current
// platform are appended to |supported_entries|; all other entries are appended
// to |unsupported_entries|.
void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
                           flags_ui::FlagAccess access,
                           base::Value::List& supported_entries,
                           base::Value::List& unsupported_entries);

// Gets the list of feature entries for the deprecated flags page. Entries that
// are available for the current platform are appended to |supported_entries|;
// all other entries are appended to |unsupported_entries|.
void GetFlagFeatureEntriesForDeprecatedPage(
    flags_ui::FlagsStorage* flags_storage,
    flags_ui::FlagAccess access,
    base::Value::List& supported_entries,
    base::Value::List& unsupported_entries);

// Gets the FlagsState used in about_flags.
flags_ui::FlagsState* GetCurrentFlagsState();

// Returns true if one of the feature entry flags has been flipped since
// startup.
bool IsRestartNeededToCommitChanges();

// Enables or disables the current with id |internal_name|.
void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
                            const std::string& internal_name,
                            bool enable);

// Sets a flag value with a list of origins given by |value|. Origins in |value|
// can be separated by a comma or whitespace. Invalid URLs will be dropped when
// setting the command line flag.
// E.g. SetOriginListFlag("test-flag",
//                        "http://example.test1 http://example.test2",
//                        flags_storage);
// will add --test-flag=http://example.test to the command line.
void SetOriginListFlag(const std::string& internal_name,
                       const std::string& value,
                       flags_ui::FlagsStorage* flags_storage);

// Sets a flag value with a string given by |value|.
void SetStringFlag(const std::string& internal_name,
                   const std::string& value,
                   flags_ui::FlagsStorage* flags_storage);

// Removes all switches that were added to a command line by a previous call to
// |ConvertFlagsToSwitches()|.
void RemoveFlagsSwitches(base::CommandLine::SwitchMap* switch_list);

// Reset all flags to the default state by clearing all flags.
void ResetAllFlags(flags_ui::FlagsStorage* flags_storage);

// Sends UMA stats about experimental flag usage. This should be called once per
// startup.
void RecordUMAStatistics(flags_ui::FlagsStorage* flags_storage,
                         const std::string& histogram_name);

namespace testing {

// This class sets the testing feature entries to the feature entries passed in
// to Init. It clears the testing feature entries on destruction, so
// the feature entries return to their non test values.
class ScopedFeatureEntries final {
 public:
  explicit ScopedFeatureEntries(
      const std::vector<flags_ui::FeatureEntry>& entries);
  ~ScopedFeatureEntries();
};

base::span<const flags_ui::FeatureEntry> GetFeatureEntries();

}  // namespace testing

}  // namespace about_flags

#endif  // CHROME_BROWSER_ABOUT_FLAGS_H_