| 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 "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 : chrome_details_(this) { | 34 : chrome_details_(this) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 UsersPrivateGetWhitelistedUsersFunction:: | 37 UsersPrivateGetWhitelistedUsersFunction:: |
| 38 ~UsersPrivateGetWhitelistedUsersFunction() { | 38 ~UsersPrivateGetWhitelistedUsersFunction() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 ExtensionFunction::ResponseAction | 41 ExtensionFunction::ResponseAction |
| 42 UsersPrivateGetWhitelistedUsersFunction::Run() { | 42 UsersPrivateGetWhitelistedUsersFunction::Run() { |
| 43 Profile* profile = chrome_details_.GetProfile(); | 43 Profile* profile = chrome_details_.GetProfile(); |
| 44 scoped_ptr<base::ListValue> user_list(new base::ListValue); | 44 std::unique_ptr<base::ListValue> user_list(new base::ListValue); |
| 45 | 45 |
| 46 // Non-owners should not be able to see the list of users. | 46 // Non-owners should not be able to see the list of users. |
| 47 if (!chromeos::ProfileHelper::IsOwnerProfile(profile)) | 47 if (!chromeos::ProfileHelper::IsOwnerProfile(profile)) |
| 48 return RespondNow(OneArgument(user_list.release())); | 48 return RespondNow(OneArgument(user_list.release())); |
| 49 | 49 |
| 50 // Create one list to set. This is needed because user white list update is | 50 // Create one list to set. This is needed because user white list update is |
| 51 // asynchronous and sequential. Before previous write comes back, cached list | 51 // asynchronous and sequential. Before previous write comes back, cached list |
| 52 // is stale and should not be used for appending. See http://crbug.com/127215 | 52 // is stale and should not be used for appending. See http://crbug.com/127215 |
| 53 scoped_ptr<base::ListValue> email_list; | 53 std::unique_ptr<base::ListValue> email_list; |
| 54 | 54 |
| 55 UsersPrivateDelegate* delegate = | 55 UsersPrivateDelegate* delegate = |
| 56 UsersPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 56 UsersPrivateDelegateFactory::GetForBrowserContext(browser_context()); |
| 57 PrefsUtil* prefs_util = delegate->GetPrefsUtil(); | 57 PrefsUtil* prefs_util = delegate->GetPrefsUtil(); |
| 58 | 58 |
| 59 scoped_ptr<api::settings_private::PrefObject> users_pref_object = | 59 std::unique_ptr<api::settings_private::PrefObject> users_pref_object = |
| 60 prefs_util->GetPref(chromeos::kAccountsPrefUsers); | 60 prefs_util->GetPref(chromeos::kAccountsPrefUsers); |
| 61 if (users_pref_object->value) { | 61 if (users_pref_object->value) { |
| 62 const base::ListValue* existing = nullptr; | 62 const base::ListValue* existing = nullptr; |
| 63 users_pref_object->value->GetAsList(&existing); | 63 users_pref_object->value->GetAsList(&existing); |
| 64 email_list.reset(existing->DeepCopy()); | 64 email_list.reset(existing->DeepCopy()); |
| 65 } else { | 65 } else { |
| 66 email_list.reset(new base::ListValue()); | 66 email_list.reset(new base::ListValue()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Remove all supervised users. On the next step only supervised users present | 69 // Remove all supervised users. On the next step only supervised users present |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 UsersPrivateAddWhitelistedUserFunction::UsersPrivateAddWhitelistedUserFunction() | 110 UsersPrivateAddWhitelistedUserFunction::UsersPrivateAddWhitelistedUserFunction() |
| 111 : chrome_details_(this) { | 111 : chrome_details_(this) { |
| 112 } | 112 } |
| 113 | 113 |
| 114 UsersPrivateAddWhitelistedUserFunction:: | 114 UsersPrivateAddWhitelistedUserFunction:: |
| 115 ~UsersPrivateAddWhitelistedUserFunction() { | 115 ~UsersPrivateAddWhitelistedUserFunction() { |
| 116 } | 116 } |
| 117 | 117 |
| 118 ExtensionFunction::ResponseAction | 118 ExtensionFunction::ResponseAction |
| 119 UsersPrivateAddWhitelistedUserFunction::Run() { | 119 UsersPrivateAddWhitelistedUserFunction::Run() { |
| 120 scoped_ptr<api::users_private::AddWhitelistedUser::Params> parameters = | 120 std::unique_ptr<api::users_private::AddWhitelistedUser::Params> parameters = |
| 121 api::users_private::AddWhitelistedUser::Params::Create(*args_); | 121 api::users_private::AddWhitelistedUser::Params::Create(*args_); |
| 122 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 122 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 123 | 123 |
| 124 // Non-owners should not be able to add users. | 124 // Non-owners should not be able to add users. |
| 125 if (!chromeos::ProfileHelper::IsOwnerProfile(chrome_details_.GetProfile())) { | 125 if (!chromeos::ProfileHelper::IsOwnerProfile(chrome_details_.GetProfile())) { |
| 126 return RespondNow(OneArgument(new base::FundamentalValue(false))); | 126 return RespondNow(OneArgument(new base::FundamentalValue(false))); |
| 127 } | 127 } |
| 128 | 128 |
| 129 std::string username = gaia::CanonicalizeEmail(parameters->email); | 129 std::string username = gaia::CanonicalizeEmail(parameters->email); |
| 130 if (chromeos::CrosSettings::Get()->FindEmailInList( | 130 if (chromeos::CrosSettings::Get()->FindEmailInList( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 UsersPrivateRemoveWhitelistedUserFunction() | 149 UsersPrivateRemoveWhitelistedUserFunction() |
| 150 : chrome_details_(this) { | 150 : chrome_details_(this) { |
| 151 } | 151 } |
| 152 | 152 |
| 153 UsersPrivateRemoveWhitelistedUserFunction:: | 153 UsersPrivateRemoveWhitelistedUserFunction:: |
| 154 ~UsersPrivateRemoveWhitelistedUserFunction() { | 154 ~UsersPrivateRemoveWhitelistedUserFunction() { |
| 155 } | 155 } |
| 156 | 156 |
| 157 ExtensionFunction::ResponseAction | 157 ExtensionFunction::ResponseAction |
| 158 UsersPrivateRemoveWhitelistedUserFunction::Run() { | 158 UsersPrivateRemoveWhitelistedUserFunction::Run() { |
| 159 scoped_ptr<api::users_private::RemoveWhitelistedUser::Params> parameters = | 159 std::unique_ptr<api::users_private::RemoveWhitelistedUser::Params> |
| 160 api::users_private::RemoveWhitelistedUser::Params::Create(*args_); | 160 parameters = |
| 161 api::users_private::RemoveWhitelistedUser::Params::Create(*args_); |
| 161 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 162 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 162 | 163 |
| 163 // Non-owners should not be able to remove users. | 164 // Non-owners should not be able to remove users. |
| 164 if (!chromeos::ProfileHelper::IsOwnerProfile(chrome_details_.GetProfile())) { | 165 if (!chromeos::ProfileHelper::IsOwnerProfile(chrome_details_.GetProfile())) { |
| 165 return RespondNow(OneArgument(new base::FundamentalValue(false))); | 166 return RespondNow(OneArgument(new base::FundamentalValue(false))); |
| 166 } | 167 } |
| 167 | 168 |
| 168 base::StringValue canonical_email(gaia::CanonicalizeEmail(parameters->email)); | 169 base::StringValue canonical_email(gaia::CanonicalizeEmail(parameters->email)); |
| 169 | 170 |
| 170 UsersPrivateDelegate* delegate = | 171 UsersPrivateDelegate* delegate = |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 209 |
| 209 ExtensionFunction::ResponseAction | 210 ExtensionFunction::ResponseAction |
| 210 UsersPrivateIsWhitelistManagedFunction::Run() { | 211 UsersPrivateIsWhitelistManagedFunction::Run() { |
| 211 bool is_managed = g_browser_process->platform_part() | 212 bool is_managed = g_browser_process->platform_part() |
| 212 ->browser_policy_connector_chromeos() | 213 ->browser_policy_connector_chromeos() |
| 213 ->IsEnterpriseManaged(); | 214 ->IsEnterpriseManaged(); |
| 214 return RespondNow(OneArgument(new base::FundamentalValue(is_managed))); | 215 return RespondNow(OneArgument(new base::FundamentalValue(is_managed))); |
| 215 } | 216 } |
| 216 | 217 |
| 217 } // namespace extensions | 218 } // namespace extensions |
| OLD | NEW |