OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/signin/signin_supervised_user_import_handler.h
" | 5 #include "chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h
" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 case Profile::CREATE_STATUS_REMOTE_FAIL: | 211 case Profile::CREATE_STATUS_REMOTE_FAIL: |
212 case Profile::MAX_CREATE_STATUS: { | 212 case Profile::MAX_CREATE_STATUS: { |
213 NOTREACHED(); | 213 NOTREACHED(); |
214 break; | 214 break; |
215 } | 215 } |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 void SigninSupervisedUserImportHandler::RejectCallback( | 219 void SigninSupervisedUserImportHandler::RejectCallback( |
220 const base::string16& error) { | 220 const base::string16& error) { |
221 RejectJavascriptCallback( | 221 RejectJavascriptCallback(base::Value(webui_callback_id_), base::Value(error)); |
222 base::StringValue(webui_callback_id_), | |
223 base::StringValue(error)); | |
224 webui_callback_id_.clear(); | 222 webui_callback_id_.clear(); |
225 } | 223 } |
226 | 224 |
227 base::string16 SigninSupervisedUserImportHandler::GetLocalErrorMessage() const { | 225 base::string16 SigninSupervisedUserImportHandler::GetLocalErrorMessage() const { |
228 return l10n_util::GetStringUTF16( | 226 return l10n_util::GetStringUTF16( |
229 IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR); | 227 IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR); |
230 } | 228 } |
231 | 229 |
232 base::string16 SigninSupervisedUserImportHandler::GetAuthErrorMessage( | 230 base::string16 SigninSupervisedUserImportHandler::GetAuthErrorMessage( |
233 Profile* profile) const { | 231 Profile* profile) const { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 profiles::GetDefaultAvatarIconUrl(avatar_index); | 288 profiles::GetDefaultAvatarIconUrl(avatar_index); |
291 supervised_user->SetString("iconURL", avatar_url); | 289 supervised_user->SetString("iconURL", avatar_url); |
292 bool on_current_device = | 290 bool on_current_device = |
293 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); | 291 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); |
294 supervised_user->SetBoolean("onCurrentDevice", on_current_device); | 292 supervised_user->SetBoolean("onCurrentDevice", on_current_device); |
295 | 293 |
296 supervised_users.Append(std::move(supervised_user)); | 294 supervised_users.Append(std::move(supervised_user)); |
297 } | 295 } |
298 | 296 |
299 // Resolve callback with response. | 297 // Resolve callback with response. |
300 ResolveJavascriptCallback( | 298 ResolveJavascriptCallback(base::Value(webui_callback_id_), supervised_users); |
301 base::StringValue(webui_callback_id_), | |
302 supervised_users); | |
303 webui_callback_id_.clear(); | 299 webui_callback_id_.clear(); |
304 } | 300 } |
305 | 301 |
306 bool SigninSupervisedUserImportHandler::IsAccountConnected( | 302 bool SigninSupervisedUserImportHandler::IsAccountConnected( |
307 Profile* profile) const { | 303 Profile* profile) const { |
308 SigninManagerBase* signin_manager = | 304 SigninManagerBase* signin_manager = |
309 SigninManagerFactory::GetForProfile(profile); | 305 SigninManagerFactory::GetForProfile(profile); |
310 return signin_manager && signin_manager->IsAuthenticated(); | 306 return signin_manager && signin_manager->IsAuthenticated(); |
311 } | 307 } |
312 | 308 |
313 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { | 309 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { |
314 SigninErrorController* error_controller = | 310 SigninErrorController* error_controller = |
315 SigninErrorControllerFactory::GetForProfile(profile); | 311 SigninErrorControllerFactory::GetForProfile(profile); |
316 if (!error_controller) | 312 if (!error_controller) |
317 return true; | 313 return true; |
318 | 314 |
319 GoogleServiceAuthError::State state = error_controller->auth_error().state(); | 315 GoogleServiceAuthError::State state = error_controller->auth_error().state(); |
320 return state != GoogleServiceAuthError::NONE; | 316 return state != GoogleServiceAuthError::NONE; |
321 } | 317 } |
OLD | NEW |