OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/value_conversions.h" | 10 #include "base/value_conversions.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // UserManagerScreenHandler --------------------------------------------------- | 217 // UserManagerScreenHandler --------------------------------------------------- |
218 | 218 |
219 UserManagerScreenHandler::UserManagerScreenHandler() | 219 UserManagerScreenHandler::UserManagerScreenHandler() |
220 : desktop_type_(chrome::GetActiveDesktop()) { | 220 : desktop_type_(chrome::GetActiveDesktop()) { |
221 profileInfoCacheObserver_.reset( | 221 profileInfoCacheObserver_.reset( |
222 new UserManagerScreenHandler::ProfileUpdateObserver( | 222 new UserManagerScreenHandler::ProfileUpdateObserver( |
223 g_browser_process->profile_manager(), this)); | 223 g_browser_process->profile_manager(), this)); |
224 } | 224 } |
225 | 225 |
226 UserManagerScreenHandler::~UserManagerScreenHandler() { | 226 UserManagerScreenHandler::~UserManagerScreenHandler() { |
227 ScreenlockBridge::Get()->SetLockHandler(NULL); | 227 SigninScreenBridge::Get()->SetLockHandler(NULL); |
228 } | 228 } |
229 | 229 |
230 void UserManagerScreenHandler::ShowBannerMessage( | 230 void UserManagerScreenHandler::ShowBannerMessage( |
231 const base::string16& message) { | 231 const base::string16& message) { |
232 web_ui()->CallJavascriptFunction( | 232 web_ui()->CallJavascriptFunction( |
233 "login.AccountPickerScreen.showBannerMessage", | 233 "login.AccountPickerScreen.showBannerMessage", |
234 base::StringValue(message)); | 234 base::StringValue(message)); |
235 } | 235 } |
236 | 236 |
237 void UserManagerScreenHandler::ShowUserPodCustomIcon( | 237 void UserManagerScreenHandler::ShowUserPodCustomIcon( |
238 const std::string& user_email, | 238 const std::string& user_email, |
239 const ScreenlockBridge::UserPodCustomIconOptions& icon_options) { | 239 const SigninScreenBridge::UserPodCustomIconOptions& icon_options) { |
240 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); | 240 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); |
241 if (!icon || icon->empty()) | 241 if (!icon || icon->empty()) |
242 return; | 242 return; |
243 web_ui()->CallJavascriptFunction( | 243 web_ui()->CallJavascriptFunction( |
244 "login.AccountPickerScreen.showUserPodCustomIcon", | 244 "login.AccountPickerScreen.showUserPodCustomIcon", |
245 base::StringValue(user_email), | 245 base::StringValue(user_email), |
246 *icon); | 246 *icon); |
247 } | 247 } |
248 | 248 |
249 void UserManagerScreenHandler::HideUserPodCustomIcon( | 249 void UserManagerScreenHandler::HideUserPodCustomIcon( |
250 const std::string& user_email) { | 250 const std::string& user_email) { |
251 web_ui()->CallJavascriptFunction( | 251 web_ui()->CallJavascriptFunction( |
252 "login.AccountPickerScreen.hideUserPodCustomIcon", | 252 "login.AccountPickerScreen.hideUserPodCustomIcon", |
253 base::StringValue(user_email)); | 253 base::StringValue(user_email)); |
254 } | 254 } |
255 | 255 |
256 void UserManagerScreenHandler::EnableInput() { | 256 void UserManagerScreenHandler::EnableInput() { |
257 // Nothing here because UI is not disabled when starting to authenticate. | 257 // Nothing here because UI is not disabled when starting to authenticate. |
258 } | 258 } |
259 | 259 |
260 void UserManagerScreenHandler::SetAuthType( | 260 void UserManagerScreenHandler::SetAuthType( |
261 const std::string& user_email, | 261 const std::string& user_email, |
262 ScreenlockBridge::LockHandler::AuthType auth_type, | 262 SigninScreenBridge::LockHandler::AuthType auth_type, |
263 const base::string16& auth_value) { | 263 const base::string16& auth_value) { |
264 if (GetAuthType(user_email) == | 264 if (GetAuthType(user_email) == |
265 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) | 265 SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD) |
266 return; | 266 return; |
267 | 267 |
268 user_auth_type_map_[user_email] = auth_type; | 268 user_auth_type_map_[user_email] = auth_type; |
269 web_ui()->CallJavascriptFunction( | 269 web_ui()->CallJavascriptFunction( |
270 "login.AccountPickerScreen.setAuthType", | 270 "login.AccountPickerScreen.setAuthType", |
271 base::StringValue(user_email), | 271 base::StringValue(user_email), |
272 base::FundamentalValue(auth_type), | 272 base::FundamentalValue(auth_type), |
273 base::StringValue(auth_value)); | 273 base::StringValue(auth_value)); |
274 } | 274 } |
275 | 275 |
276 ScreenlockBridge::LockHandler::AuthType UserManagerScreenHandler::GetAuthType( | 276 SigninScreenBridge::LockHandler::AuthType UserManagerScreenHandler::GetAuthType( |
277 const std::string& user_email) const { | 277 const std::string& user_email) const { |
278 UserAuthTypeMap::const_iterator it = user_auth_type_map_.find(user_email); | 278 UserAuthTypeMap::const_iterator it = user_auth_type_map_.find(user_email); |
279 if (it == user_auth_type_map_.end()) | 279 if (it == user_auth_type_map_.end()) |
280 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 280 return SigninScreenBridge::LockHandler::OFFLINE_PASSWORD; |
281 return it->second; | 281 return it->second; |
282 } | 282 } |
283 | 283 |
284 void UserManagerScreenHandler::Unlock(const std::string& user_email) { | 284 void UserManagerScreenHandler::Unlock(const std::string& user_email) { |
285 ProfileInfoCache& info_cache = | 285 ProfileInfoCache& info_cache = |
286 g_browser_process->profile_manager()->GetProfileInfoCache(); | 286 g_browser_process->profile_manager()->GetProfileInfoCache(); |
287 const size_t profile_index = GetIndexOfProfileWithEmailAndName( | 287 const size_t profile_index = GetIndexOfProfileWithEmailAndName( |
288 info_cache, base::UTF8ToUTF16(user_email), base::string16()); | 288 info_cache, base::UTF8ToUTF16(user_email), base::string16()); |
289 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); | 289 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); |
290 | 290 |
291 authenticating_profile_index_ = profile_index; | 291 authenticating_profile_index_ = profile_index; |
292 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); | 292 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); |
293 } | 293 } |
294 | 294 |
295 void UserManagerScreenHandler::AttemptUserClickLogin( | 295 void UserManagerScreenHandler::AttemptUserClickLogin( |
296 const std::string& user_email, | 296 const std::string& user_email, |
297 const std::string& secret, | 297 const std::string& secret, |
298 const std::string& key_label) { | 298 const std::string& key_label) { |
299 NOTREACHED(); | 299 NOTREACHED(); |
300 } | 300 } |
301 | 301 |
302 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { | 302 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
303 SendUserList(); | 303 SendUserList(); |
304 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", | 304 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", |
305 base::FundamentalValue(IsGuestModeEnabled()), | 305 base::FundamentalValue(IsGuestModeEnabled()), |
306 base::FundamentalValue(IsAddPersonEnabled())); | 306 base::FundamentalValue(IsAddPersonEnabled())); |
307 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( | 307 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( |
308 web_ui()->GetWebContents()->GetNativeView()); | 308 web_ui()->GetWebContents()->GetNativeView()); |
309 | 309 |
310 ScreenlockBridge::Get()->SetLockHandler(this); | 310 SigninScreenBridge::Get()->SetLockHandler(this); |
311 } | 311 } |
312 | 312 |
313 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { | 313 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { |
314 if (!IsAddPersonEnabled()) { | 314 if (!IsAddPersonEnabled()) { |
315 // The 'Add User' UI should not be showing. | 315 // The 'Add User' UI should not be showing. |
316 NOTREACHED(); | 316 NOTREACHED(); |
317 return; | 317 return; |
318 } | 318 } |
319 profiles::CreateAndSwitchToNewProfile( | 319 profiles::CreateAndSwitchToNewProfile( |
320 desktop_type_, | 320 desktop_type_, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 std::string email; | 450 std::string email; |
451 CHECK(args->GetString(0, &email)); | 451 CHECK(args->GetString(0, &email)); |
452 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); | 452 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); |
453 } | 453 } |
454 | 454 |
455 void UserManagerScreenHandler::HandleHardlockUserPod( | 455 void UserManagerScreenHandler::HandleHardlockUserPod( |
456 const base::ListValue* args) { | 456 const base::ListValue* args) { |
457 std::string email; | 457 std::string email; |
458 CHECK(args->GetString(0, &email)); | 458 CHECK(args->GetString(0, &email)); |
459 SetAuthType(email, | 459 SetAuthType(email, |
460 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 460 SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
461 base::string16()); | 461 base::string16()); |
462 HideUserPodCustomIcon(email); | 462 HideUserPodCustomIcon(email); |
463 } | 463 } |
464 | 464 |
465 void UserManagerScreenHandler::OnClientLoginSuccess( | 465 void UserManagerScreenHandler::OnClientLoginSuccess( |
466 const ClientLoginResult& result) { | 466 const ClientLoginResult& result) { |
467 chrome::SetLocalAuthCredentials(authenticating_profile_index_, | 467 chrome::SetLocalAuthCredentials(authenticating_profile_index_, |
468 password_attempt_); | 468 password_attempt_); |
469 ReportAuthenticationResult(true, ProfileMetrics::AUTH_ONLINE); | 469 ReportAuthenticationResult(true, ProfileMetrics::AUTH_ONLINE); |
470 } | 470 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 "cr.ui.Oobe.showSignInError", | 699 "cr.ui.Oobe.showSignInError", |
700 base::FundamentalValue(0), | 700 base::FundamentalValue(0), |
701 base::StringValue(l10n_util::GetStringUTF8( | 701 base::StringValue(l10n_util::GetStringUTF8( |
702 auth == ProfileMetrics::AUTH_FAILED_OFFLINE ? | 702 auth == ProfileMetrics::AUTH_FAILED_OFFLINE ? |
703 IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE : | 703 IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE : |
704 IDS_LOGIN_ERROR_AUTHENTICATING)), | 704 IDS_LOGIN_ERROR_AUTHENTICATING)), |
705 base::StringValue(""), | 705 base::StringValue(""), |
706 base::FundamentalValue(0)); | 706 base::FundamentalValue(0)); |
707 } | 707 } |
708 } | 708 } |
OLD | NEW |