OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
11 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
17 #include "base/prefs/scoped_user_pref_update.h" | 18 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #include "components/user_manager/user.h" | 68 #include "components/user_manager/user.h" |
68 #include "components/user_manager/user_type.h" | 69 #include "components/user_manager/user_type.h" |
69 #include "content/public/browser/render_frame_host.h" | 70 #include "content/public/browser/render_frame_host.h" |
70 #include "content/public/browser/web_contents.h" | 71 #include "content/public/browser/web_contents.h" |
71 #include "google_apis/gaia/gaia_auth_util.h" | 72 #include "google_apis/gaia/gaia_auth_util.h" |
72 #include "grit/chromium_strings.h" | 73 #include "grit/chromium_strings.h" |
73 #include "grit/generated_resources.h" | 74 #include "grit/generated_resources.h" |
74 #include "net/url_request/url_request_context_getter.h" | 75 #include "net/url_request/url_request_context_getter.h" |
75 #include "third_party/cros_system_api/dbus/service_constants.h" | 76 #include "third_party/cros_system_api/dbus/service_constants.h" |
76 #include "ui/base/webui/web_ui_util.h" | 77 #include "ui/base/webui/web_ui_util.h" |
77 #include "ui/gfx/image/image.h" | |
78 #include "ui/gfx/image/image_skia.h" | |
79 | 78 |
80 #if defined(USE_AURA) | 79 #if defined(USE_AURA) |
81 #include "ash/shell.h" | 80 #include "ash/shell.h" |
82 #include "ash/wm/lock_state_controller.h" | 81 #include "ash/wm/lock_state_controller.h" |
83 #endif | 82 #endif |
84 | 83 |
85 namespace { | 84 namespace { |
86 | 85 |
87 // Max number of users to show. | 86 // Max number of users to show. |
88 const size_t kMaxUsers = 18; | 87 const size_t kMaxUsers = 18; |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 403 |
405 builder->Add("samlNotice", IDS_LOGIN_SAML_NOTICE); | 404 builder->Add("samlNotice", IDS_LOGIN_SAML_NOTICE); |
406 | 405 |
407 builder->Add("confirmPasswordTitle", IDS_LOGIN_CONFIRM_PASSWORD_TITLE); | 406 builder->Add("confirmPasswordTitle", IDS_LOGIN_CONFIRM_PASSWORD_TITLE); |
408 builder->Add("confirmPasswordLabel", IDS_LOGIN_CONFIRM_PASSWORD_LABEL); | 407 builder->Add("confirmPasswordLabel", IDS_LOGIN_CONFIRM_PASSWORD_LABEL); |
409 builder->Add("confirmPasswordConfirmButton", | 408 builder->Add("confirmPasswordConfirmButton", |
410 IDS_LOGIN_CONFIRM_PASSWORD_CONFIRM_BUTTON); | 409 IDS_LOGIN_CONFIRM_PASSWORD_CONFIRM_BUTTON); |
411 builder->Add("confirmPasswordText", IDS_LOGIN_CONFIRM_PASSWORD_TEXT); | 410 builder->Add("confirmPasswordText", IDS_LOGIN_CONFIRM_PASSWORD_TEXT); |
412 builder->Add("confirmPasswordErrorText", | 411 builder->Add("confirmPasswordErrorText", |
413 IDS_LOGIN_CONFIRM_PASSWORD_ERROR_TEXT); | 412 IDS_LOGIN_CONFIRM_PASSWORD_ERROR_TEXT); |
414 builder->Add("easyUnlockTooltip", | |
415 IDS_LOGIN_EASY_UNLOCK_TOOLTIP); | |
416 | 413 |
417 builder->Add("fatalEnrollmentError", | 414 builder->Add("fatalEnrollmentError", |
418 IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR); | 415 IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR); |
419 builder->Add("insecureURLEnrollmentError", | 416 builder->Add("insecureURLEnrollmentError", |
420 IDS_ENTERPRISE_ENROLLMENT_AUTH_INSECURE_URL_ERROR); | 417 IDS_ENTERPRISE_ENROLLMENT_AUTH_INSECURE_URL_ERROR); |
421 | 418 |
422 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) | 419 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) |
423 builder->Add("demoLoginMessage", IDS_KIOSK_MODE_LOGIN_MESSAGE); | 420 builder->Add("demoLoginMessage", IDS_KIOSK_MODE_LOGIN_MESSAGE); |
424 } | 421 } |
425 | 422 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 case UI_STATE_ACCOUNT_PICKER: | 503 case UI_STATE_ACCOUNT_PICKER: |
507 ui_state_ = UI_STATE_ACCOUNT_PICKER; | 504 ui_state_ = UI_STATE_ACCOUNT_PICKER; |
508 ShowScreen(OobeUI::kScreenAccountPicker, params); | 505 ShowScreen(OobeUI::kScreenAccountPicker, params); |
509 break; | 506 break; |
510 default: | 507 default: |
511 NOTREACHED(); | 508 NOTREACHED(); |
512 break; | 509 break; |
513 } | 510 } |
514 } | 511 } |
515 | 512 |
516 // TODO (ygorshenin@): split this method into small parts. | 513 // TODO(ygorshenin@): split this method into small parts. |
517 // TODO (ygorshenin@): move this logic to GaiaScreenHandler. | 514 // TODO(ygorshenin@): move this logic to GaiaScreenHandler. |
518 void SigninScreenHandler::UpdateStateInternal( | 515 void SigninScreenHandler::UpdateStateInternal( |
519 ErrorScreenActor::ErrorReason reason, | 516 ErrorScreenActor::ErrorReason reason, |
520 bool force_update) { | 517 bool force_update) { |
521 // Do nothing once user has signed in or sign in is in progress. | 518 // Do nothing once user has signed in or sign in is in progress. |
522 // TODO(ygorshenin): We will end up here when processing network state | 519 // TODO(ygorshenin): We will end up here when processing network state |
523 // notification but no ShowSigninScreen() was called so delegate_ will be | 520 // notification but no ShowSigninScreen() was called so delegate_ will be |
524 // NULL. Network state processing logic does not belong here. | 521 // NULL. Network state processing logic does not belong here. |
525 if (delegate_ && | 522 if (delegate_ && |
526 (delegate_->IsUserSigninCompleted() || delegate_->IsSigninInProgress())) { | 523 (delegate_->IsUserSigninCompleted() || delegate_->IsSigninInProgress())) { |
527 return; | 524 return; |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // Don't reload auth extension if proxy auth dialog was cancelled. | 913 // Don't reload auth extension if proxy auth dialog was cancelled. |
917 has_pending_auth_ui_ = false; | 914 has_pending_auth_ui_ = false; |
918 update_state_closure_.Cancel(); | 915 update_state_closure_.Cancel(); |
919 break; | 916 break; |
920 } | 917 } |
921 default: | 918 default: |
922 NOTREACHED() << "Unexpected notification " << type; | 919 NOTREACHED() << "Unexpected notification " << type; |
923 } | 920 } |
924 } | 921 } |
925 | 922 |
926 void SigninScreenHandler::ShowBannerMessage(const std::string& message) { | 923 void SigninScreenHandler::ShowBannerMessage(const base::string16& message) { |
927 CallJS("login.AccountPickerScreen.showBannerMessage", message); | 924 CallJS("login.AccountPickerScreen.showBannerMessage", message); |
928 } | 925 } |
929 | 926 |
930 void SigninScreenHandler::ShowUserPodCustomIcon( | 927 void SigninScreenHandler::ShowUserPodCustomIcon( |
931 const std::string& username, | 928 const std::string& username, |
932 const gfx::Image& icon) { | 929 const ScreenlockBridge::UserPodCustomIconOptions& icon_options) { |
933 gfx::ImageSkia icon_skia = icon.AsImageSkia(); | 930 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); |
934 base::DictionaryValue icon_representations; | 931 if (!icon || icon->empty()) |
935 icon_representations.SetString( | 932 return; |
936 "scale1x", | 933 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", username, *icon); |
937 webui::GetBitmapDataUrl(icon_skia.GetRepresentation(1.0f).sk_bitmap())); | |
938 icon_representations.SetString( | |
939 "scale2x", | |
940 webui::GetBitmapDataUrl(icon_skia.GetRepresentation(2.0f).sk_bitmap())); | |
941 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", | |
942 username, icon_representations); | |
943 | |
944 // TODO(tengs): Move this code once we move unlocking to native code. | |
945 if (ScreenLocker::default_screen_locker()) { | |
946 UserManager* user_manager = UserManager::Get(); | |
947 const user_manager::User* user = user_manager->FindUser(username); | |
948 if (!user) | |
949 return; | |
950 PrefService* profile_prefs = | |
951 ProfileHelper::Get()->GetProfileByUser(user)->GetPrefs(); | |
952 if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { | |
953 CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); | |
954 profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); | |
955 } | |
956 } | |
957 } | 934 } |
958 | 935 |
959 void SigninScreenHandler::HideUserPodCustomIcon(const std::string& username) { | 936 void SigninScreenHandler::HideUserPodCustomIcon(const std::string& username) { |
960 CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", username); | 937 CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", username); |
961 } | 938 } |
962 | 939 |
963 void SigninScreenHandler::EnableInput() { | 940 void SigninScreenHandler::EnableInput() { |
964 // Only for lock screen at the moment. | 941 // Only for lock screen at the moment. |
965 ScreenLocker::default_screen_locker()->EnableInput(); | 942 ScreenLocker::default_screen_locker()->EnableInput(); |
966 } | 943 } |
967 | 944 |
968 void SigninScreenHandler::SetAuthType( | 945 void SigninScreenHandler::SetAuthType( |
969 const std::string& username, | 946 const std::string& username, |
970 ScreenlockBridge::LockHandler::AuthType auth_type, | 947 ScreenlockBridge::LockHandler::AuthType auth_type, |
971 const std::string& initial_value) { | 948 const base::string16& initial_value) { |
972 delegate_->SetAuthType(username, auth_type); | 949 delegate_->SetAuthType(username, auth_type); |
973 | 950 |
974 CallJS("login.AccountPickerScreen.setAuthType", | 951 CallJS("login.AccountPickerScreen.setAuthType", |
975 username, | 952 username, |
976 static_cast<int>(auth_type), | 953 static_cast<int>(auth_type), |
977 base::StringValue(initial_value)); | 954 base::StringValue(initial_value)); |
978 } | 955 } |
979 | 956 |
980 ScreenlockBridge::LockHandler::AuthType SigninScreenHandler::GetAuthType( | 957 ScreenlockBridge::LockHandler::AuthType SigninScreenHandler::GetAuthType( |
981 const std::string& username) const { | 958 const std::string& username) const { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 return gaia_screen_handler_->frame_error(); | 1472 return gaia_screen_handler_->frame_error(); |
1496 } | 1473 } |
1497 | 1474 |
1498 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1475 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
1499 caps_lock_enabled_ = enabled; | 1476 caps_lock_enabled_ = enabled; |
1500 if (page_is_ready()) | 1477 if (page_is_ready()) |
1501 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1478 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
1502 } | 1479 } |
1503 | 1480 |
1504 } // namespace chromeos | 1481 } // namespace chromeos |
OLD | NEW |