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

Side by Side Diff: chrome/browser/chromeos/extensions/users_private/users_private_api.cc

Issue 2902253004: Settings: Users: Make isCurrentUserOwner async (Closed)
Patch Set: Fix test Created 3 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 #include "chrome/browser/chromeos/extensions/users_private/users_private_api.h" 5 #include "chrome/browser/chromeos/extensions/users_private/users_private_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e.h" 16 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e.h"
16 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e_factory.h" 17 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e_factory.h"
17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 19 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 UsersPrivateIsCurrentUserOwnerFunction::UsersPrivateIsCurrentUserOwnerFunction() 205 UsersPrivateIsCurrentUserOwnerFunction::UsersPrivateIsCurrentUserOwnerFunction()
205 : chrome_details_(this) { 206 : chrome_details_(this) {
206 } 207 }
207 208
208 UsersPrivateIsCurrentUserOwnerFunction:: 209 UsersPrivateIsCurrentUserOwnerFunction::
209 ~UsersPrivateIsCurrentUserOwnerFunction() { 210 ~UsersPrivateIsCurrentUserOwnerFunction() {
210 } 211 }
211 212
212 ExtensionFunction::ResponseAction 213 ExtensionFunction::ResponseAction
213 UsersPrivateIsCurrentUserOwnerFunction::Run() { 214 UsersPrivateIsCurrentUserOwnerFunction::Run() {
214 bool is_owner = 215 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(
215 chromeos::ProfileHelper::IsOwnerProfile(chrome_details_.GetProfile()); 216 browser_context())
216 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_owner))); 217 ->IsOwnerAsync(base::Bind(
218 &UsersPrivateIsCurrentUserOwnerFunction::IsOwnerCallback, this));
219 return RespondLater();
220 }
221
222 void UsersPrivateIsCurrentUserOwnerFunction::IsOwnerCallback(bool is_owner) {
223 Respond(OneArgument(base::MakeUnique<base::Value>(is_owner)));
217 } 224 }
218 225
219 //////////////////////////////////////////////////////////////////////////////// 226 ////////////////////////////////////////////////////////////////////////////////
220 // UsersPrivateIsWhitelistManagedFunction 227 // UsersPrivateIsWhitelistManagedFunction
221 228
222 UsersPrivateIsWhitelistManagedFunction:: 229 UsersPrivateIsWhitelistManagedFunction::
223 UsersPrivateIsWhitelistManagedFunction() { 230 UsersPrivateIsWhitelistManagedFunction() {
224 } 231 }
225 232
226 UsersPrivateIsWhitelistManagedFunction:: 233 UsersPrivateIsWhitelistManagedFunction::
227 ~UsersPrivateIsWhitelistManagedFunction() { 234 ~UsersPrivateIsWhitelistManagedFunction() {
228 } 235 }
229 236
230 ExtensionFunction::ResponseAction 237 ExtensionFunction::ResponseAction
231 UsersPrivateIsWhitelistManagedFunction::Run() { 238 UsersPrivateIsWhitelistManagedFunction::Run() {
232 bool is_managed = g_browser_process->platform_part() 239 bool is_managed = g_browser_process->platform_part()
233 ->browser_policy_connector_chromeos() 240 ->browser_policy_connector_chromeos()
234 ->IsEnterpriseManaged(); 241 ->IsEnterpriseManaged();
235 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); 242 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed)));
236 } 243 }
237 244
238 } // namespace extensions 245 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698