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

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

Issue 1411453004: Componentize internal class FlagsState in flags_ui component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@feature_entry
Patch Set: Rebase Created 5 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
« no previous file with comments | « chrome/BUILD.gn ('k') | chrome/browser/about_flags.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_ABOUT_FLAGS_H_ 5 #ifndef CHROME_BROWSER_ABOUT_FLAGS_H_
6 #define CHROME_BROWSER_ABOUT_FLAGS_H_ 6 #define CHROME_BROWSER_ABOUT_FLAGS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/metrics/histogram_base.h" 15 #include "base/metrics/histogram_base.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "components/flags_ui/feature_entry.h" 17 #include "components/flags_ui/feature_entry.h"
18 18 #include "components/flags_ui/flags_state.h"
19 class PrefService;
20 19
21 namespace base { 20 namespace base {
22 class ListValue; 21 class ListValue;
23 } 22 }
24 23
25 namespace flags_ui { 24 namespace flags_ui {
26 class FlagsStorage; 25 class FlagsStorage;
27 } 26 }
28 27
29 namespace about_flags { 28 namespace about_flags {
30 29
31 // A flag controlling the behavior of the |ConvertFlagsToSwitches| function -
32 // whether it should add the sentinel switches around flags.
33 enum SentinelsMode { kNoSentinels, kAddSentinels };
34
35 // Reads the state from |flags_storage| and adds the command line flags 30 // Reads the state from |flags_storage| and adds the command line flags
36 // belonging to the active feature entries to |command_line|. 31 // belonging to the active feature entries to |command_line|.
37 void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage, 32 void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
38 base::CommandLine* command_line, 33 base::CommandLine* command_line,
39 SentinelsMode sentinels); 34 flags_ui::SentinelsMode sentinels);
40 35
41 // Compares a set of switches of the two provided command line objects and 36 // Compares a set of switches of the two provided command line objects and
42 // returns true if they are the same and false otherwise. 37 // returns true if they are the same and false otherwise.
43 // If |out_difference| is not NULL, it's filled with set_symmetric_difference 38 // If |out_difference| is not NULL, it's filled with set_symmetric_difference
44 // between sets. 39 // between sets.
45 bool AreSwitchesIdenticalToCurrentCommandLine( 40 bool AreSwitchesIdenticalToCurrentCommandLine(
46 const base::CommandLine& new_cmdline, 41 const base::CommandLine& new_cmdline,
47 const base::CommandLine& active_cmdline, 42 const base::CommandLine& active_cmdline,
48 std::set<base::CommandLine::StringType>* out_difference); 43 std::set<base::CommandLine::StringType>* out_difference);
49 44
50 // Differentiate between generic flags available on a per session base and flags
51 // that influence the whole machine and can be said by the admin only. This flag
52 // is relevant for ChromeOS for now only and dictates whether entries marked
53 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not.
54 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags };
55
56 // Gets the list of feature entries. Entries that are available for the current 45 // Gets the list of feature entries. Entries that are available for the current
57 // platform are appended to |supported_entries|; all other entries are appended 46 // platform are appended to |supported_entries|; all other entries are appended
58 // to |unsupported_entries|. 47 // to |unsupported_entries|.
59 void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage, 48 void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
60 FlagAccess access, 49 flags_ui::FlagAccess access,
61 base::ListValue* supported_entries, 50 base::ListValue* supported_entries,
62 base::ListValue* unsupported_entries); 51 base::ListValue* unsupported_entries);
63 52
64 // Returns true if one of the feature entry flags has been flipped since 53 // Returns true if one of the feature entry flags has been flipped since
65 // startup. 54 // startup.
66 bool IsRestartNeededToCommitChanges(); 55 bool IsRestartNeededToCommitChanges();
67 56
68 // Enables or disables the current with id |internal_name|. 57 // Enables or disables the current with id |internal_name|.
69 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage, 58 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
70 const std::string& internal_name, 59 const std::string& internal_name,
71 bool enable); 60 bool enable);
72 61
73 // Removes all switches that were added to a command line by a previous call to 62 // Removes all switches that were added to a command line by a previous call to
74 // |ConvertFlagsToSwitches()|. 63 // |ConvertFlagsToSwitches()|.
75 void RemoveFlagsSwitches( 64 void RemoveFlagsSwitches(
76 std::map<std::string, base::CommandLine::StringType>* switch_list); 65 std::map<std::string, base::CommandLine::StringType>* switch_list);
77 66
78 // Reset all flags to the default state by clearing all flags. 67 // Reset all flags to the default state by clearing all flags.
79 void ResetAllFlags(flags_ui::FlagsStorage* flags_storage); 68 void ResetAllFlags(flags_ui::FlagsStorage* flags_storage);
80 69
81 // Returns the value for the current platform. This is one of the values defined
82 // by the OS enum above.
83 // This is exposed only for testing.
84 int GetCurrentPlatform();
85
86 // Sends UMA stats about experimental flag usage. This should be called once per 70 // Sends UMA stats about experimental flag usage. This should be called once per
87 // startup. 71 // startup.
88 void RecordUMAStatistics(flags_ui::FlagsStorage* flags_storage); 72 void RecordUMAStatistics(flags_ui::FlagsStorage* flags_storage);
89 73
90 // Returns the UMA id for the specified switch name. 74 // Returns the UMA id for the specified switch name.
91 base::HistogramBase::Sample GetSwitchUMAId(const std::string& switch_name); 75 base::HistogramBase::Sample GetSwitchUMAId(const std::string& switch_name);
92 76
93 // Sends stats (as UMA histogram) about command_line_difference. 77 // Sends stats (as UMA histogram) about command_line_difference.
94 // This is used on ChromeOS to report flags that lead to browser restart. 78 // This is used on ChromeOS to report flags that lead to browser restart.
95 // |command_line_difference| is the result of 79 // |command_line_difference| is the result of
96 // AreSwitchesIdenticalToCurrentCommandLine(). 80 // AreSwitchesIdenticalToCurrentCommandLine().
97 void ReportCustomFlags(const std::string& uma_histogram_hame, 81 void ReportCustomFlags(const std::string& uma_histogram_hame,
98 const std::set<std::string>& command_line_difference); 82 const std::set<std::string>& command_line_difference);
99 83
100 namespace testing { 84 namespace testing {
101 85
102 // Clears internal global state, for unit tests. 86 // Returns the global set of feature entries.
103 void ClearState();
104
105 // Sets the list of feature entries. Pass in null to use the default set. This
106 // does NOT take ownership of the supplied |entries|.
107 void SetFeatureEntries(const flags_ui::FeatureEntry* entries, size_t count);
108
109 // Returns the current set of feature entries.
110 const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count); 87 const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count);
111 88
112 // This value is reported as switch histogram ID if switch name has unknown 89 // This value is reported as switch histogram ID if switch name has unknown
113 // format. 90 // format.
114 extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId; 91 extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId;
115 92
116 } // namespace testing 93 } // namespace testing
117 94
118 } // namespace about_flags 95 } // namespace about_flags
119 96
120 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ 97 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_
OLDNEW
« no previous file with comments | « chrome/BUILD.gn ('k') | chrome/browser/about_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698