| OLD | NEW |
| 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" |
| 21 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 22 #include "chrome/browser/extensions/chrome_extension_function.h" | 23 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/common/extensions/api/users_private.h" | 25 #include "chrome/common/extensions/api/users_private.h" |
| 25 #include "chromeos/settings/cros_settings_names.h" | 26 #include "chromeos/settings/cros_settings_names.h" |
| 27 #include "components/ownership/owner_settings_service.h" |
| 26 #include "components/user_manager/user_manager.h" | 28 #include "components/user_manager/user_manager.h" |
| 27 #include "components/user_manager/user_names.h" | 29 #include "components/user_manager/user_names.h" |
| 28 #include "extensions/browser/extension_function_registry.h" | 30 #include "extensions/browser/extension_function_registry.h" |
| 29 #include "google_apis/gaia/gaia_auth_util.h" | 31 #include "google_apis/gaia/gaia_auth_util.h" |
| 30 | 32 |
| 31 namespace extensions { | 33 namespace extensions { |
| 32 | 34 |
| 33 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
| 34 // UsersPrivateGetWhitelistedUsersFunction | 36 // UsersPrivateGetWhitelistedUsersFunction |
| 35 | 37 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 UsersPrivateIsCurrentUserOwnerFunction::UsersPrivateIsCurrentUserOwnerFunction() | 206 UsersPrivateIsCurrentUserOwnerFunction::UsersPrivateIsCurrentUserOwnerFunction() |
| 205 : chrome_details_(this) { | 207 : chrome_details_(this) { |
| 206 } | 208 } |
| 207 | 209 |
| 208 UsersPrivateIsCurrentUserOwnerFunction:: | 210 UsersPrivateIsCurrentUserOwnerFunction:: |
| 209 ~UsersPrivateIsCurrentUserOwnerFunction() { | 211 ~UsersPrivateIsCurrentUserOwnerFunction() { |
| 210 } | 212 } |
| 211 | 213 |
| 212 ExtensionFunction::ResponseAction | 214 ExtensionFunction::ResponseAction |
| 213 UsersPrivateIsCurrentUserOwnerFunction::Run() { | 215 UsersPrivateIsCurrentUserOwnerFunction::Run() { |
| 214 bool is_owner = | 216 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( |
| 215 chromeos::ProfileHelper::IsOwnerProfile(chrome_details_.GetProfile()); | 217 browser_context()) |
| 216 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_owner))); | 218 ->IsOwnerAsync(base::Bind( |
| 219 &UsersPrivateIsCurrentUserOwnerFunction::IsOwnerCallback, this)); |
| 220 return RespondLater(); |
| 221 } |
| 222 |
| 223 void UsersPrivateIsCurrentUserOwnerFunction::IsOwnerCallback(bool is_owner) { |
| 224 Respond(OneArgument(base::MakeUnique<base::Value>(is_owner))); |
| 217 } | 225 } |
| 218 | 226 |
| 219 //////////////////////////////////////////////////////////////////////////////// | 227 //////////////////////////////////////////////////////////////////////////////// |
| 220 // UsersPrivateIsWhitelistManagedFunction | 228 // UsersPrivateIsWhitelistManagedFunction |
| 221 | 229 |
| 222 UsersPrivateIsWhitelistManagedFunction:: | 230 UsersPrivateIsWhitelistManagedFunction:: |
| 223 UsersPrivateIsWhitelistManagedFunction() { | 231 UsersPrivateIsWhitelistManagedFunction() { |
| 224 } | 232 } |
| 225 | 233 |
| 226 UsersPrivateIsWhitelistManagedFunction:: | 234 UsersPrivateIsWhitelistManagedFunction:: |
| 227 ~UsersPrivateIsWhitelistManagedFunction() { | 235 ~UsersPrivateIsWhitelistManagedFunction() { |
| 228 } | 236 } |
| 229 | 237 |
| 230 ExtensionFunction::ResponseAction | 238 ExtensionFunction::ResponseAction |
| 231 UsersPrivateIsWhitelistManagedFunction::Run() { | 239 UsersPrivateIsWhitelistManagedFunction::Run() { |
| 232 bool is_managed = g_browser_process->platform_part() | 240 bool is_managed = g_browser_process->platform_part() |
| 233 ->browser_policy_connector_chromeos() | 241 ->browser_policy_connector_chromeos() |
| 234 ->IsEnterpriseManaged(); | 242 ->IsEnterpriseManaged(); |
| 235 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); | 243 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); |
| 236 } | 244 } |
| 237 | 245 |
| 238 } // namespace extensions | 246 } // namespace extensions |
| OLD | NEW |