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

Side by Side Diff: chrome/browser/ui/webui/flags_ui.cc

Issue 13467023: Add differentiation between owner only and common flags on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed one forgotten place to replace. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/about_flags_unittest.cc ('k') | no next file » | 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 #include "chrome/browser/ui/webui/flags_ui.h" 5 #include "chrome/browser/ui/webui/flags_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 //////////////////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////////////////
83 // 83 //
84 // FlagsDOMHandler 84 // FlagsDOMHandler
85 // 85 //
86 //////////////////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////////////////
87 87
88 // The handler for Javascript messages for the about:flags page. 88 // The handler for Javascript messages for the about:flags page.
89 class FlagsDOMHandler : public WebUIMessageHandler { 89 class FlagsDOMHandler : public WebUIMessageHandler {
90 public: 90 public:
91 explicit FlagsDOMHandler(PrefService* prefs) : prefs_(prefs) {} 91 explicit FlagsDOMHandler(PrefService* prefs, about_flags::FlagAccess access)
92 : prefs_(prefs), access_(access) {}
92 virtual ~FlagsDOMHandler() {} 93 virtual ~FlagsDOMHandler() {}
93 94
94 // WebUIMessageHandler implementation. 95 // WebUIMessageHandler implementation.
95 virtual void RegisterMessages() OVERRIDE; 96 virtual void RegisterMessages() OVERRIDE;
96 97
97 // Callback for the "requestFlagsExperiments" message. 98 // Callback for the "requestFlagsExperiments" message.
98 void HandleRequestFlagsExperiments(const ListValue* args); 99 void HandleRequestFlagsExperiments(const ListValue* args);
99 100
100 // Callback for the "enableFlagsExperiment" message. 101 // Callback for the "enableFlagsExperiment" message.
101 void HandleEnableFlagsExperimentMessage(const ListValue* args); 102 void HandleEnableFlagsExperimentMessage(const ListValue* args);
102 103
103 // Callback for the "restartBrowser" message. Restores all tabs on restart. 104 // Callback for the "restartBrowser" message. Restores all tabs on restart.
104 void HandleRestartBrowser(const ListValue* args); 105 void HandleRestartBrowser(const ListValue* args);
105 106
106 // Callback for the "resetAllFlags" message. 107 // Callback for the "resetAllFlags" message.
107 void HandleResetAllFlags(const ListValue* args); 108 void HandleResetAllFlags(const ListValue* args);
108 109
109 private: 110 private:
110 PrefService* prefs_; 111 PrefService* prefs_;
112 about_flags::FlagAccess access_;
111 113
112 DISALLOW_COPY_AND_ASSIGN(FlagsDOMHandler); 114 DISALLOW_COPY_AND_ASSIGN(FlagsDOMHandler);
113 }; 115 };
114 116
115 void FlagsDOMHandler::RegisterMessages() { 117 void FlagsDOMHandler::RegisterMessages() {
116 web_ui()->RegisterMessageCallback("requestFlagsExperiments", 118 web_ui()->RegisterMessageCallback("requestFlagsExperiments",
117 base::Bind(&FlagsDOMHandler::HandleRequestFlagsExperiments, 119 base::Bind(&FlagsDOMHandler::HandleRequestFlagsExperiments,
118 base::Unretained(this))); 120 base::Unretained(this)));
119 web_ui()->RegisterMessageCallback("enableFlagsExperiment", 121 web_ui()->RegisterMessageCallback("enableFlagsExperiment",
120 base::Bind(&FlagsDOMHandler::HandleEnableFlagsExperimentMessage, 122 base::Bind(&FlagsDOMHandler::HandleEnableFlagsExperimentMessage,
121 base::Unretained(this))); 123 base::Unretained(this)));
122 web_ui()->RegisterMessageCallback("restartBrowser", 124 web_ui()->RegisterMessageCallback("restartBrowser",
123 base::Bind(&FlagsDOMHandler::HandleRestartBrowser, 125 base::Bind(&FlagsDOMHandler::HandleRestartBrowser,
124 base::Unretained(this))); 126 base::Unretained(this)));
125 web_ui()->RegisterMessageCallback("resetAllFlags", 127 web_ui()->RegisterMessageCallback("resetAllFlags",
126 base::Bind(&FlagsDOMHandler::HandleResetAllFlags, 128 base::Bind(&FlagsDOMHandler::HandleResetAllFlags,
127 base::Unretained(this))); 129 base::Unretained(this)));
128 } 130 }
129 131
130 void FlagsDOMHandler::HandleRequestFlagsExperiments(const ListValue* args) { 132 void FlagsDOMHandler::HandleRequestFlagsExperiments(const ListValue* args) {
131 DictionaryValue results; 133 DictionaryValue results;
132 results.Set("flagsExperiments", 134 results.Set("flagsExperiments",
133 about_flags::GetFlagsExperimentsData(prefs_)); 135 about_flags::GetFlagsExperimentsData(prefs_, access_));
134 results.SetBoolean("needsRestart", 136 results.SetBoolean("needsRestart",
135 about_flags::IsRestartNeededToCommitChanges()); 137 about_flags::IsRestartNeededToCommitChanges());
136 web_ui()->CallJavascriptFunction("returnFlagsExperiments", results); 138 web_ui()->CallJavascriptFunction("returnFlagsExperiments", results);
137 } 139 }
138 140
139 void FlagsDOMHandler::HandleEnableFlagsExperimentMessage( 141 void FlagsDOMHandler::HandleEnableFlagsExperimentMessage(
140 const ListValue* args) { 142 const ListValue* args) {
141 DCHECK_EQ(2u, args->GetSize()); 143 DCHECK_EQ(2u, args->GetSize());
142 if (args->GetSize() != 2) 144 if (args->GetSize() != 2)
143 return; 145 return;
(...skipping 30 matching lines...) Expand all
174 : WebUIController(web_ui), 176 : WebUIController(web_ui),
175 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 177 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
176 Profile* profile = Profile::FromWebUI(web_ui); 178 Profile* profile = Profile::FromWebUI(web_ui);
177 179
178 #if defined(OS_CHROMEOS) 180 #if defined(OS_CHROMEOS)
179 chromeos::DeviceSettingsService::Get()->GetOwnershipStatusAsync( 181 chromeos::DeviceSettingsService::Get()->GetOwnershipStatusAsync(
180 base::Bind(&FlagsUI::FinishInitialization, 182 base::Bind(&FlagsUI::FinishInitialization,
181 weak_factory_.GetWeakPtr(), profile)); 183 weak_factory_.GetWeakPtr(), profile));
182 #else 184 #else
183 web_ui->AddMessageHandler( 185 web_ui->AddMessageHandler(
184 new FlagsDOMHandler(g_browser_process->local_state())); 186 new FlagsDOMHandler(g_browser_process->local_state(),
187 about_flags::kOwnerAccessToFlags));
185 188
186 // Set up the about:flags source. 189 // Set up the about:flags source.
187 content::WebUIDataSource::Add(profile, CreateFlagsUIHTMLSource()); 190 content::WebUIDataSource::Add(profile, CreateFlagsUIHTMLSource());
188 #endif 191 #endif
189 } 192 }
190 193
191 FlagsUI::~FlagsUI() { 194 FlagsUI::~FlagsUI() {
192 } 195 }
193 196
194 // static 197 // static
(...skipping 15 matching lines...) Expand all
210 PrefRegistrySyncable::UNSYNCABLE_PREF); 213 PrefRegistrySyncable::UNSYNCABLE_PREF);
211 } 214 }
212 215
213 void FlagsUI::FinishInitialization( 216 void FlagsUI::FinishInitialization(
214 Profile* profile, 217 Profile* profile,
215 chromeos::DeviceSettingsService::OwnershipStatus status, 218 chromeos::DeviceSettingsService::OwnershipStatus status,
216 bool current_user_is_owner) { 219 bool current_user_is_owner) {
217 // On Chrome OS the owner can set system wide flags and other users can only 220 // On Chrome OS the owner can set system wide flags and other users can only
218 // set flags for their own session. 221 // set flags for their own session.
219 if (!current_user_is_owner) { 222 if (!current_user_is_owner) {
220 web_ui()->AddMessageHandler(new FlagsDOMHandler(profile->GetPrefs())); 223 web_ui()->AddMessageHandler(
224 new FlagsDOMHandler(profile->GetPrefs(),
225 about_flags::kGeneralAccessFlagsOnly));
221 } else { 226 } else {
222 web_ui()->AddMessageHandler( 227 web_ui()->AddMessageHandler(
223 new FlagsDOMHandler(g_browser_process->local_state())); 228 new FlagsDOMHandler(g_browser_process->local_state(),
229 about_flags::kOwnerAccessToFlags));
224 // If the owner managed to set the flags pref on his own profile clear it 230 // If the owner managed to set the flags pref on his own profile clear it
225 // because it will never be accessible anymore. 231 // because it will never be accessible anymore.
226 if (profile->GetPrefs()->HasPrefPath(prefs::kEnabledLabsExperiments)) 232 if (profile->GetPrefs()->HasPrefPath(prefs::kEnabledLabsExperiments))
227 profile->GetPrefs()->ClearPref(prefs::kEnabledLabsExperiments); 233 profile->GetPrefs()->ClearPref(prefs::kEnabledLabsExperiments);
228 } 234 }
229 235
230 // Set up the about:flags source. 236 // Set up the about:flags source.
231 content::WebUIDataSource::Add(profile, CreateFlagsUIHTMLSource()); 237 content::WebUIDataSource::Add(profile, CreateFlagsUIHTMLSource());
232 } 238 }
233 #endif 239 #endif
OLDNEW
« no previous file with comments | « chrome/browser/about_flags_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698