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/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/value_conversions.h" | 11 #include "base/value_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" | 15 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
18 #include "chrome/browser/profiles/profile_info_cache.h" | 18 #include "chrome/browser/profiles/profile_info_cache.h" |
19 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 19 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
21 #include "chrome/browser/profiles/profile_metrics.h" | 21 #include "chrome/browser/profiles/profile_metrics.h" |
22 #include "chrome/browser/profiles/profile_window.h" | 22 #include "chrome/browser/profiles/profile_window.h" |
23 #include "chrome/browser/profiles/profiles_state.h" | 23 #include "chrome/browser/profiles/profiles_state.h" |
24 #include "chrome/browser/signin/local_auth.h" | 24 #include "chrome/browser/signin/local_auth.h" |
| 25 #include "chrome/browser/signin/proximity_auth_facade.h" |
25 #include "chrome/browser/ui/app_list/app_list_service.h" | 26 #include "chrome/browser/ui/app_list/app_list_service.h" |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_dialogs.h" | 28 #include "chrome/browser/ui/browser_dialogs.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_list_observer.h" | 31 #include "chrome/browser/ui/browser_list_observer.h" |
31 #include "chrome/browser/ui/chrome_pages.h" | 32 #include "chrome/browser/ui/chrome_pages.h" |
32 #include "chrome/browser/ui/singleton_tabs.h" | 33 #include "chrome/browser/ui/singleton_tabs.h" |
33 #include "chrome/browser/ui/user_manager.h" | 34 #include "chrome/browser/ui/user_manager.h" |
34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 291 |
291 UserManagerScreenHandler::UserManagerScreenHandler() | 292 UserManagerScreenHandler::UserManagerScreenHandler() |
292 : desktop_type_(chrome::GetActiveDesktop()), | 293 : desktop_type_(chrome::GetActiveDesktop()), |
293 weak_ptr_factory_(this) { | 294 weak_ptr_factory_(this) { |
294 profileInfoCacheObserver_.reset( | 295 profileInfoCacheObserver_.reset( |
295 new UserManagerScreenHandler::ProfileUpdateObserver( | 296 new UserManagerScreenHandler::ProfileUpdateObserver( |
296 g_browser_process->profile_manager(), this)); | 297 g_browser_process->profile_manager(), this)); |
297 } | 298 } |
298 | 299 |
299 UserManagerScreenHandler::~UserManagerScreenHandler() { | 300 UserManagerScreenHandler::~UserManagerScreenHandler() { |
300 ScreenlockBridge::Get()->SetLockHandler(NULL); | 301 GetScreenlockBridgeInstance()->SetLockHandler(NULL); |
301 } | 302 } |
302 | 303 |
303 void UserManagerScreenHandler::ShowBannerMessage( | 304 void UserManagerScreenHandler::ShowBannerMessage( |
304 const base::string16& message) { | 305 const base::string16& message) { |
305 web_ui()->CallJavascriptFunction( | 306 web_ui()->CallJavascriptFunction( |
306 "login.AccountPickerScreen.showBannerMessage", | 307 "login.AccountPickerScreen.showBannerMessage", |
307 base::StringValue(message)); | 308 base::StringValue(message)); |
308 } | 309 } |
309 | 310 |
310 void UserManagerScreenHandler::ShowUserPodCustomIcon( | 311 void UserManagerScreenHandler::ShowUserPodCustomIcon( |
311 const std::string& user_email, | 312 const std::string& user_email, |
312 const ScreenlockBridge::UserPodCustomIconOptions& icon_options) { | 313 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& |
| 314 icon_options) { |
313 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); | 315 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); |
314 if (!icon || icon->empty()) | 316 if (!icon || icon->empty()) |
315 return; | 317 return; |
316 web_ui()->CallJavascriptFunction( | 318 web_ui()->CallJavascriptFunction( |
317 "login.AccountPickerScreen.showUserPodCustomIcon", | 319 "login.AccountPickerScreen.showUserPodCustomIcon", |
318 base::StringValue(user_email), | 320 base::StringValue(user_email), |
319 *icon); | 321 *icon); |
320 } | 322 } |
321 | 323 |
322 void UserManagerScreenHandler::HideUserPodCustomIcon( | 324 void UserManagerScreenHandler::HideUserPodCustomIcon( |
323 const std::string& user_email) { | 325 const std::string& user_email) { |
324 web_ui()->CallJavascriptFunction( | 326 web_ui()->CallJavascriptFunction( |
325 "login.AccountPickerScreen.hideUserPodCustomIcon", | 327 "login.AccountPickerScreen.hideUserPodCustomIcon", |
326 base::StringValue(user_email)); | 328 base::StringValue(user_email)); |
327 } | 329 } |
328 | 330 |
329 void UserManagerScreenHandler::EnableInput() { | 331 void UserManagerScreenHandler::EnableInput() { |
330 // Nothing here because UI is not disabled when starting to authenticate. | 332 // Nothing here because UI is not disabled when starting to authenticate. |
331 } | 333 } |
332 | 334 |
333 void UserManagerScreenHandler::SetAuthType( | 335 void UserManagerScreenHandler::SetAuthType( |
334 const std::string& user_email, | 336 const std::string& user_email, |
335 ScreenlockBridge::LockHandler::AuthType auth_type, | 337 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, |
336 const base::string16& auth_value) { | 338 const base::string16& auth_value) { |
337 if (GetAuthType(user_email) == | 339 if (GetAuthType(user_email) == |
338 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) | 340 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) |
339 return; | 341 return; |
340 | 342 |
341 user_auth_type_map_[user_email] = auth_type; | 343 user_auth_type_map_[user_email] = auth_type; |
342 web_ui()->CallJavascriptFunction( | 344 web_ui()->CallJavascriptFunction( |
343 "login.AccountPickerScreen.setAuthType", | 345 "login.AccountPickerScreen.setAuthType", |
344 base::StringValue(user_email), | 346 base::StringValue(user_email), |
345 base::FundamentalValue(auth_type), | 347 base::FundamentalValue(auth_type), |
346 base::StringValue(auth_value)); | 348 base::StringValue(auth_value)); |
347 } | 349 } |
348 | 350 |
349 ScreenlockBridge::LockHandler::AuthType UserManagerScreenHandler::GetAuthType( | 351 proximity_auth::ScreenlockBridge::LockHandler::AuthType |
350 const std::string& user_email) const { | 352 UserManagerScreenHandler::GetAuthType(const std::string& user_email) const { |
351 UserAuthTypeMap::const_iterator it = user_auth_type_map_.find(user_email); | 353 UserAuthTypeMap::const_iterator it = user_auth_type_map_.find(user_email); |
352 if (it == user_auth_type_map_.end()) | 354 if (it == user_auth_type_map_.end()) |
353 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 355 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
354 return it->second; | 356 return it->second; |
355 } | 357 } |
356 | 358 |
357 ScreenlockBridge::LockHandler::ScreenType | 359 proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
358 UserManagerScreenHandler::GetScreenType() const { | 360 UserManagerScreenHandler::GetScreenType() const { |
359 return ScreenlockBridge::LockHandler::LOCK_SCREEN; | 361 return proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN; |
360 } | 362 } |
361 | 363 |
362 void UserManagerScreenHandler::Unlock(const std::string& user_email) { | 364 void UserManagerScreenHandler::Unlock(const std::string& user_email) { |
363 const ProfileInfoCache& info_cache = | 365 const ProfileInfoCache& info_cache = |
364 g_browser_process->profile_manager()->GetProfileInfoCache(); | 366 g_browser_process->profile_manager()->GetProfileInfoCache(); |
365 const size_t profile_index = | 367 const size_t profile_index = |
366 GetIndexOfProfileWithEmail(info_cache, user_email); | 368 GetIndexOfProfileWithEmail(info_cache, user_email); |
367 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); | 369 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); |
368 | 370 |
369 authenticating_profile_index_ = profile_index; | 371 authenticating_profile_index_ = profile_index; |
(...skipping 11 matching lines...) Expand all Loading... |
381 // If the URL has a hash parameter, store it for later. | 383 // If the URL has a hash parameter, store it for later. |
382 args->GetString(0, &url_hash_); | 384 args->GetString(0, &url_hash_); |
383 | 385 |
384 SendUserList(); | 386 SendUserList(); |
385 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", | 387 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen", |
386 base::FundamentalValue(IsGuestModeEnabled()), | 388 base::FundamentalValue(IsGuestModeEnabled()), |
387 base::FundamentalValue(IsAddPersonEnabled())); | 389 base::FundamentalValue(IsAddPersonEnabled())); |
388 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( | 390 desktop_type_ = chrome::GetHostDesktopTypeForNativeView( |
389 web_ui()->GetWebContents()->GetNativeView()); | 391 web_ui()->GetWebContents()->GetNativeView()); |
390 | 392 |
391 ScreenlockBridge::Get()->SetLockHandler(this); | 393 GetScreenlockBridgeInstance()->SetLockHandler(this); |
392 } | 394 } |
393 | 395 |
394 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { | 396 void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { |
395 if (!IsAddPersonEnabled()) { | 397 if (!IsAddPersonEnabled()) { |
396 // The 'Add User' UI should not be showing. | 398 // The 'Add User' UI should not be showing. |
397 NOTREACHED(); | 399 NOTREACHED(); |
398 return; | 400 return; |
399 } | 401 } |
400 profiles::CreateAndSwitchToNewProfile( | 402 profiles::CreateAndSwitchToNewProfile( |
401 desktop_type_, | 403 desktop_type_, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 const base::ListValue* args) { | 541 const base::ListValue* args) { |
540 std::string email; | 542 std::string email; |
541 CHECK(args->GetString(0, &email)); | 543 CHECK(args->GetString(0, &email)); |
542 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); | 544 GetScreenlockRouter(email)->OnAuthAttempted(GetAuthType(email), ""); |
543 } | 545 } |
544 | 546 |
545 void UserManagerScreenHandler::HandleHardlockUserPod( | 547 void UserManagerScreenHandler::HandleHardlockUserPod( |
546 const base::ListValue* args) { | 548 const base::ListValue* args) { |
547 std::string email; | 549 std::string email; |
548 CHECK(args->GetString(0, &email)); | 550 CHECK(args->GetString(0, &email)); |
549 SetAuthType(email, | 551 SetAuthType( |
550 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 552 email, |
551 base::string16()); | 553 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
| 554 base::string16()); |
552 HideUserPodCustomIcon(email); | 555 HideUserPodCustomIcon(email); |
553 } | 556 } |
554 | 557 |
555 void UserManagerScreenHandler::OnClientLoginSuccess( | 558 void UserManagerScreenHandler::OnClientLoginSuccess( |
556 const ClientLoginResult& result) { | 559 const ClientLoginResult& result) { |
557 LocalAuth::SetLocalAuthCredentials(authenticating_profile_index_, | 560 LocalAuth::SetLocalAuthCredentials(authenticating_profile_index_, |
558 password_attempt_); | 561 password_attempt_); |
559 ReportAuthenticationResult(true, ProfileMetrics::AUTH_ONLINE); | 562 ReportAuthenticationResult(true, ProfileMetrics::AUTH_ONLINE); |
560 } | 563 } |
561 | 564 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 Profile* profile, Profile::CreateStatus profile_create_status) { | 869 Profile* profile, Profile::CreateStatus profile_create_status) { |
867 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); | 870 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); |
868 if (browser && browser->window()) { | 871 if (browser && browser->window()) { |
869 OnBrowserWindowReady(browser); | 872 OnBrowserWindowReady(browser); |
870 } else { | 873 } else { |
871 registrar_.Add(this, | 874 registrar_.Add(this, |
872 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 875 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
873 content::NotificationService::AllSources()); | 876 content::NotificationService::AllSources()); |
874 } | 877 } |
875 } | 878 } |
OLD | NEW |