| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 base::Bind( | 74 base::Bind( |
| 75 &SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser, | 75 &SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser, |
| 76 base::Unretained(this))); | 76 base::Unretained(this))); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void SigninSupervisedUserImportHandler::AssignWebUICallbackId( | 79 void SigninSupervisedUserImportHandler::AssignWebUICallbackId( |
| 80 const base::ListValue* args) { | 80 const base::ListValue* args) { |
| 81 CHECK_LE(1U, args->GetSize()); | 81 CHECK_LE(1U, args->GetSize()); |
| 82 CHECK(webui_callback_id_.empty()); | 82 CHECK(webui_callback_id_.empty()); |
| 83 CHECK(args->GetString(0, &webui_callback_id_)); | 83 CHECK(args->GetString(0, &webui_callback_id_)); |
| 84 AllowJavascript(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 void SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser( | 87 void SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser( |
| 87 const base::ListValue* args) { | 88 const base::ListValue* args) { |
| 88 CHECK_EQ(1U, args->GetSize()); | 89 CHECK_EQ(1U, args->GetSize()); |
| 89 std::string url; | 90 std::string url; |
| 90 bool success = args->GetString(0, &url); | 91 bool success = args->GetString(0, &url); |
| 91 DCHECK(success); | 92 DCHECK(success); |
| 92 content::OpenURLParams params(GURL(url), | 93 content::OpenURLParams params(GURL(url), |
| 93 content::Referrer(), | 94 content::Referrer(), |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 case Profile::CREATE_STATUS_REMOTE_FAIL: | 184 case Profile::CREATE_STATUS_REMOTE_FAIL: |
| 184 case Profile::MAX_CREATE_STATUS: { | 185 case Profile::MAX_CREATE_STATUS: { |
| 185 NOTREACHED(); | 186 NOTREACHED(); |
| 186 break; | 187 break; |
| 187 } | 188 } |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 191 void SigninSupervisedUserImportHandler::RejectCallback( | 192 void SigninSupervisedUserImportHandler::RejectCallback( |
| 192 const base::string16& error) { | 193 const base::string16& error) { |
| 193 web_ui()->CallJavascriptFunction("cr.webUIResponse", | 194 RejectJavascriptCallback( |
| 194 base::StringValue(webui_callback_id_), | 195 base::StringValue(webui_callback_id_), |
| 195 base::FundamentalValue(false), | |
| 196 base::StringValue(error)); | 196 base::StringValue(error)); |
| 197 webui_callback_id_.clear(); | 197 webui_callback_id_.clear(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 base::string16 SigninSupervisedUserImportHandler::GetLocalErorrMessage() const { | 200 base::string16 SigninSupervisedUserImportHandler::GetLocalErorrMessage() const { |
| 201 return l10n_util::GetStringUTF16( | 201 return l10n_util::GetStringUTF16( |
| 202 IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR); | 202 IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR); |
| 203 } | 203 } |
| 204 | 204 |
| 205 base::string16 SigninSupervisedUserImportHandler::GetAuthErorrMessage() const { | 205 base::string16 SigninSupervisedUserImportHandler::GetAuthErorrMessage() const { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 profiles::GetDefaultAvatarIconUrl(avatar_index); | 260 profiles::GetDefaultAvatarIconUrl(avatar_index); |
| 261 supervised_user->SetString("iconURL", avatar_url); | 261 supervised_user->SetString("iconURL", avatar_url); |
| 262 bool on_current_device = | 262 bool on_current_device = |
| 263 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); | 263 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); |
| 264 supervised_user->SetBoolean("onCurrentDevice", on_current_device); | 264 supervised_user->SetBoolean("onCurrentDevice", on_current_device); |
| 265 | 265 |
| 266 supervised_users.Append(supervised_user); | 266 supervised_users.Append(supervised_user); |
| 267 } | 267 } |
| 268 | 268 |
| 269 // Resolve callback with response. | 269 // Resolve callback with response. |
| 270 web_ui()->CallJavascriptFunction("cr.webUIResponse", | 270 ResolveJavascriptCallback( |
| 271 base::StringValue(webui_callback_id_), | 271 base::StringValue(webui_callback_id_), |
| 272 base::FundamentalValue(true), | |
| 273 supervised_users); | 272 supervised_users); |
| 274 webui_callback_id_.clear(); | 273 webui_callback_id_.clear(); |
| 275 } | 274 } |
| 276 | 275 |
| 277 bool SigninSupervisedUserImportHandler::IsAccountConnected( | 276 bool SigninSupervisedUserImportHandler::IsAccountConnected( |
| 278 Profile* profile) const { | 277 Profile* profile) const { |
| 279 SigninManagerBase* signin_manager = | 278 SigninManagerBase* signin_manager = |
| 280 SigninManagerFactory::GetForProfile(profile); | 279 SigninManagerFactory::GetForProfile(profile); |
| 281 return signin_manager && signin_manager->IsAuthenticated(); | 280 return signin_manager && signin_manager->IsAuthenticated(); |
| 282 } | 281 } |
| 283 | 282 |
| 284 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { | 283 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { |
| 285 SigninErrorController* error_controller = | 284 SigninErrorController* error_controller = |
| 286 SigninErrorControllerFactory::GetForProfile(profile); | 285 SigninErrorControllerFactory::GetForProfile(profile); |
| 287 if (!error_controller) | 286 if (!error_controller) |
| 288 return true; | 287 return true; |
| 289 | 288 |
| 290 GoogleServiceAuthError::State state = error_controller->auth_error().state(); | 289 GoogleServiceAuthError::State state = error_controller->auth_error().state(); |
| 291 return state != GoogleServiceAuthError::NONE; | 290 return state != GoogleServiceAuthError::NONE; |
| 292 } | 291 } |
| OLD | NEW |