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()->CallJavascriptFunctionUnsafe( | 194 RejectJavascriptCallback( |
194 "cr.webUIResponse", base::StringValue(webui_callback_id_), | 195 base::StringValue(webui_callback_id_), |
195 base::FundamentalValue(false), base::StringValue(error)); | 196 base::StringValue(error)); |
196 webui_callback_id_.clear(); | 197 webui_callback_id_.clear(); |
197 } | 198 } |
198 | 199 |
199 base::string16 SigninSupervisedUserImportHandler::GetLocalErorrMessage() const { | 200 base::string16 SigninSupervisedUserImportHandler::GetLocalErorrMessage() const { |
200 return l10n_util::GetStringUTF16( | 201 return l10n_util::GetStringUTF16( |
201 IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR); | 202 IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR); |
202 } | 203 } |
203 | 204 |
204 base::string16 SigninSupervisedUserImportHandler::GetAuthErorrMessage() const { | 205 base::string16 SigninSupervisedUserImportHandler::GetAuthErorrMessage() const { |
205 return l10n_util::GetStringUTF16( | 206 return l10n_util::GetStringUTF16( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 profiles::GetDefaultAvatarIconUrl(avatar_index); | 260 profiles::GetDefaultAvatarIconUrl(avatar_index); |
260 supervised_user->SetString("iconURL", avatar_url); | 261 supervised_user->SetString("iconURL", avatar_url); |
261 bool on_current_device = | 262 bool on_current_device = |
262 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); | 263 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); |
263 supervised_user->SetBoolean("onCurrentDevice", on_current_device); | 264 supervised_user->SetBoolean("onCurrentDevice", on_current_device); |
264 | 265 |
265 supervised_users.Append(supervised_user); | 266 supervised_users.Append(supervised_user); |
266 } | 267 } |
267 | 268 |
268 // Resolve callback with response. | 269 // Resolve callback with response. |
269 web_ui()->CallJavascriptFunctionUnsafe( | 270 ResolveJavascriptCallback( |
270 "cr.webUIResponse", base::StringValue(webui_callback_id_), | 271 base::StringValue(webui_callback_id_), |
271 base::FundamentalValue(true), supervised_users); | 272 supervised_users); |
272 webui_callback_id_.clear(); | 273 webui_callback_id_.clear(); |
273 } | 274 } |
274 | 275 |
275 bool SigninSupervisedUserImportHandler::IsAccountConnected( | 276 bool SigninSupervisedUserImportHandler::IsAccountConnected( |
276 Profile* profile) const { | 277 Profile* profile) const { |
277 SigninManagerBase* signin_manager = | 278 SigninManagerBase* signin_manager = |
278 SigninManagerFactory::GetForProfile(profile); | 279 SigninManagerFactory::GetForProfile(profile); |
279 return signin_manager && signin_manager->IsAuthenticated(); | 280 return signin_manager && signin_manager->IsAuthenticated(); |
280 } | 281 } |
281 | 282 |
282 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { | 283 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { |
283 SigninErrorController* error_controller = | 284 SigninErrorController* error_controller = |
284 SigninErrorControllerFactory::GetForProfile(profile); | 285 SigninErrorControllerFactory::GetForProfile(profile); |
285 if (!error_controller) | 286 if (!error_controller) |
286 return true; | 287 return true; |
287 | 288 |
288 GoogleServiceAuthError::State state = error_controller->auth_error().state(); | 289 GoogleServiceAuthError::State state = error_controller->auth_error().state(); |
289 return state != GoogleServiceAuthError::NONE; | 290 return state != GoogleServiceAuthError::NONE; |
290 } | 291 } |
OLD | NEW |