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

Side by Side Diff: components/flags_ui/flags_state.h

Issue 2036193002: Allow overriding variation parameter via chrome://flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review Created 4 years, 6 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ 5 #ifndef COMPONENTS_FLAGS_UI_FLAGS_STATE_H_
6 #define COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ 6 #define COMPONENTS_FLAGS_UI_FLAGS_STATE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.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/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 17
18 namespace base { 18 namespace base {
19 class ListValue; 19 class ListValue;
20 } 20 }
21 21
22 namespace {
Alexei Svitkine (slow) 2016/06/16 09:40:57 This is not quite what I meant. There shouldn't b
jkrcal 2016/06/16 14:49:17 Done. (Thanks for explaining!)
23 // The trial group selected when feature variation parameters are registered via
24 // FlagsState::RegisterFeatureVariationParameters().
25 const char kTrialGroupAboutFlags[] = "AboutFlags";
26 }
27
22 namespace flags_ui { 28 namespace flags_ui {
23 29
24 struct FeatureEntry; 30 struct FeatureEntry;
25 class FlagsStorage; 31 class FlagsStorage;
26 struct SwitchEntry; 32 struct SwitchEntry;
27 33
28 // Enumeration of OSs. 34 // Enumeration of OSs.
29 enum { 35 enum {
30 kOsMac = 1 << 0, 36 kOsMac = 1 << 0,
31 kOsWin = 1 << 1, 37 kOsWin = 1 << 1,
(...skipping 17 matching lines...) Expand all
49 // be the ones marked for Apple review (which otherwise will not be shown). 55 // be the ones marked for Apple review (which otherwise will not be shown).
50 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags, 56 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags,
51 kAppleReviewAccessToFlags }; 57 kAppleReviewAccessToFlags };
52 58
53 // Stores and encapsulates the little state that about:flags has. 59 // Stores and encapsulates the little state that about:flags has.
54 class FlagsState { 60 class FlagsState {
55 public: 61 public:
56 FlagsState(const FeatureEntry* feature_entries, size_t num_feature_entries); 62 FlagsState(const FeatureEntry* feature_entries, size_t num_feature_entries);
57 ~FlagsState(); 63 ~FlagsState();
58 64
65 // Reads the state from |flags_storage| and adds the command line flags
66 // belonging to the active feature entries to |command_line|. Features are
67 // appended via |enable_features_flag_name| and |disable_features_flag_name|.
59 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, 68 void ConvertFlagsToSwitches(FlagsStorage* flags_storage,
60 base::CommandLine* command_line, 69 base::CommandLine* command_line,
61 SentinelsMode sentinels, 70 SentinelsMode sentinels,
62 const char* enable_features_flag_name, 71 const char* enable_features_flag_name,
63 const char* disable_features_flag_name); 72 const char* disable_features_flag_name);
64 bool IsRestartNeededToCommitChanges(); 73 bool IsRestartNeededToCommitChanges();
65 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, 74 void SetFeatureEntryEnabled(FlagsStorage* flags_storage,
66 const std::string& internal_name, 75 const std::string& internal_name,
67 bool enable); 76 bool enable);
68 void RemoveFlagsSwitches( 77 void RemoveFlagsSwitches(
69 std::map<std::string, base::CommandLine::StringType>* switch_list); 78 std::map<std::string, base::CommandLine::StringType>* switch_list);
70 void ResetAllFlags(FlagsStorage* flags_storage); 79 void ResetAllFlags(FlagsStorage* flags_storage);
71 void Reset(); 80 void Reset();
72 81
82 // Registers variations parameter values stored in |flags_storage| (previously
83 // selected in about:flags).
84 void RegisterAllFeatureVariationParameters(FlagsStorage* flags_storage);
85
73 // Gets the list of feature entries. Entries that are available for the 86 // Gets the list of feature entries. Entries that are available for the
74 // current platform are appended to |supported_entries|; all other entries are 87 // current platform are appended to |supported_entries|; all other entries are
75 // appended to |unsupported_entries|. 88 // appended to |unsupported_entries|.
76 void GetFlagFeatureEntries( 89 void GetFlagFeatureEntries(
77 FlagsStorage* flags_storage, 90 FlagsStorage* flags_storage,
78 FlagAccess access, 91 FlagAccess access,
79 base::ListValue* supported_entries, 92 base::ListValue* supported_entries,
80 base::ListValue* unsupported_entries, 93 base::ListValue* unsupported_entries,
81 base::Callback<bool(const FeatureEntry&)> skip_feature_entry); 94 base::Callback<bool(const FeatureEntry&)> skip_feature_entry);
82 95
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Map from switch name to a set of string, that keeps track which strings 171 // Map from switch name to a set of string, that keeps track which strings
159 // were appended to existing (list value) switches. 172 // were appended to existing (list value) switches.
160 std::map<std::string, std::set<std::string>> appended_switches_; 173 std::map<std::string, std::set<std::string>> appended_switches_;
161 174
162 DISALLOW_COPY_AND_ASSIGN(FlagsState); 175 DISALLOW_COPY_AND_ASSIGN(FlagsState);
163 }; 176 };
164 177
165 } // namespace flags_ui 178 } // namespace flags_ui
166 179
167 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ 180 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698