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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/chromeos/boot_times_loader.h" | 28 #include "chrome/browser/chromeos/boot_times_loader.h" |
29 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 29 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
30 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 30 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
31 #include "chrome/browser/chromeos/login/hwid_checker.h" | 31 #include "chrome/browser/chromeos/login/hwid_checker.h" |
32 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 32 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
33 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 33 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
34 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 34 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
35 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 35 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
36 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 36 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
37 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 37 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
38 #include "chrome/browser/chromeos/login/users/user.h" | |
39 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 38 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
40 #include "chrome/browser/chromeos/login/wizard_controller.h" | 39 #include "chrome/browser/chromeos/login/wizard_controller.h" |
41 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
42 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 41 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
43 #include "chrome/browser/chromeos/settings/cros_settings.h" | 42 #include "chrome/browser/chromeos/settings/cros_settings.h" |
44 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" | 43 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" |
45 #include "chrome/browser/io_thread.h" | 44 #include "chrome/browser/io_thread.h" |
46 #include "chrome/browser/profiles/profile.h" | 45 #include "chrome/browser/profiles/profile.h" |
47 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie
ver.h" | 46 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie
ver.h" |
48 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" | 47 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" |
49 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" | 48 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" |
50 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 49 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
51 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 50 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
52 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
54 #include "chromeos/dbus/dbus_thread_manager.h" | 53 #include "chromeos/dbus/dbus_thread_manager.h" |
55 #include "chromeos/dbus/power_manager_client.h" | 54 #include "chromeos/dbus/power_manager_client.h" |
56 #include "chromeos/ime/ime_keyboard.h" | 55 #include "chromeos/ime/ime_keyboard.h" |
57 #include "chromeos/ime/input_method_manager.h" | 56 #include "chromeos/ime/input_method_manager.h" |
58 #include "chromeos/login/auth/key.h" | 57 #include "chromeos/login/auth/key.h" |
59 #include "chromeos/login/auth/user_context.h" | 58 #include "chromeos/login/auth/user_context.h" |
60 #include "chromeos/network/network_state.h" | 59 #include "chromeos/network/network_state.h" |
61 #include "chromeos/network/network_state_handler.h" | 60 #include "chromeos/network/network_state_handler.h" |
62 #include "chromeos/network/portal_detector/network_portal_detector.h" | 61 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 62 #include "components/user_manager/user.h" |
63 #include "components/user_manager/user_type.h" | 63 #include "components/user_manager/user_type.h" |
64 #include "content/public/browser/render_frame_host.h" | 64 #include "content/public/browser/render_frame_host.h" |
65 #include "content/public/browser/web_contents.h" | 65 #include "content/public/browser/web_contents.h" |
66 #include "google_apis/gaia/gaia_auth_util.h" | 66 #include "google_apis/gaia/gaia_auth_util.h" |
67 #include "grit/chromium_strings.h" | 67 #include "grit/chromium_strings.h" |
68 #include "grit/generated_resources.h" | 68 #include "grit/generated_resources.h" |
69 #include "net/url_request/url_request_context_getter.h" | 69 #include "net/url_request/url_request_context_getter.h" |
70 #include "third_party/cros_system_api/dbus/service_constants.h" | 70 #include "third_party/cros_system_api/dbus/service_constants.h" |
71 #include "ui/base/webui/web_ui_util.h" | 71 #include "ui/base/webui/web_ui_util.h" |
72 #include "ui/gfx/image/image.h" | 72 #include "ui/gfx/image/image.h" |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 void SigninScreenHandler::RefocusCurrentPod() { | 741 void SigninScreenHandler::RefocusCurrentPod() { |
742 core_oobe_actor_->RefocusCurrentPod(); | 742 core_oobe_actor_->RefocusCurrentPod(); |
743 } | 743 } |
744 | 744 |
745 void SigninScreenHandler::OnUserRemoved(const std::string& username) { | 745 void SigninScreenHandler::OnUserRemoved(const std::string& username) { |
746 CallJS("login.AccountPickerScreen.removeUser", username); | 746 CallJS("login.AccountPickerScreen.removeUser", username); |
747 if (delegate_->GetUsers().empty()) | 747 if (delegate_->GetUsers().empty()) |
748 OnShowAddUser(); | 748 OnShowAddUser(); |
749 } | 749 } |
750 | 750 |
751 void SigninScreenHandler::OnUserImageChanged(const User& user) { | 751 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { |
752 if (page_is_ready()) | 752 if (page_is_ready()) |
753 CallJS("login.AccountPickerScreen.updateUserImage", user.email()); | 753 CallJS("login.AccountPickerScreen.updateUserImage", user.email()); |
754 } | 754 } |
755 | 755 |
756 void SigninScreenHandler::OnPreferencesChanged() { | 756 void SigninScreenHandler::OnPreferencesChanged() { |
757 // Make sure that one of the login UI is fully functional now, otherwise | 757 // Make sure that one of the login UI is fully functional now, otherwise |
758 // preferences update would be picked up next time it will be shown. | 758 // preferences update would be picked up next time it will be shown. |
759 if (!webui_visible_) { | 759 if (!webui_visible_) { |
760 LOG(WARNING) << "Login UI is not active - postponed prefs change."; | 760 LOG(WARNING) << "Login UI is not active - postponed prefs change."; |
761 preferences_changed_delayed_ = true; | 761 preferences_changed_delayed_ = true; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 webui::GetBitmapDataUrl(icon_skia.GetRepresentation(1.0f).sk_bitmap())); | 860 webui::GetBitmapDataUrl(icon_skia.GetRepresentation(1.0f).sk_bitmap())); |
861 icon_representations.SetString( | 861 icon_representations.SetString( |
862 "scale2x", | 862 "scale2x", |
863 webui::GetBitmapDataUrl(icon_skia.GetRepresentation(2.0f).sk_bitmap())); | 863 webui::GetBitmapDataUrl(icon_skia.GetRepresentation(2.0f).sk_bitmap())); |
864 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", | 864 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", |
865 username, icon_representations); | 865 username, icon_representations); |
866 | 866 |
867 // TODO(tengs): Move this code once we move unlocking to native code. | 867 // TODO(tengs): Move this code once we move unlocking to native code. |
868 if (ScreenLocker::default_screen_locker()) { | 868 if (ScreenLocker::default_screen_locker()) { |
869 UserManager* user_manager = UserManager::Get(); | 869 UserManager* user_manager = UserManager::Get(); |
870 const User* user = user_manager->FindUser(username); | 870 const user_manager::User* user = user_manager->FindUser(username); |
871 if (!user) | 871 if (!user) |
872 return; | 872 return; |
873 PrefService* profile_prefs = | 873 PrefService* profile_prefs = |
874 ProfileHelper::Get()->GetProfileByUser(user)->GetPrefs(); | 874 ProfileHelper::Get()->GetProfileByUser(user)->GetPrefs(); |
875 if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { | 875 if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { |
876 CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); | 876 CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); |
877 profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); | 877 profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
878 } | 878 } |
879 } | 879 } |
880 } | 880 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 if (!delegate_) | 965 if (!delegate_) |
966 return; | 966 return; |
967 UserContext user_context(username); | 967 UserContext user_context(username); |
968 user_context.SetKey(Key(password)); | 968 user_context.SetKey(Key(password)); |
969 delegate_->Login(user_context, SigninSpecifics()); | 969 delegate_->Login(user_context, SigninSpecifics()); |
970 } | 970 } |
971 | 971 |
972 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { | 972 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { |
973 DCHECK(ScreenLocker::default_screen_locker()); | 973 DCHECK(ScreenLocker::default_screen_locker()); |
974 | 974 |
975 const User* unlock_user = NULL; | 975 const user_manager::User* unlock_user = NULL; |
976 const UserList& users = delegate_->GetUsers(); | 976 const user_manager::UserList& users = delegate_->GetUsers(); |
977 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 977 for (user_manager::UserList::const_iterator it = users.begin(); |
| 978 it != users.end(); |
| 979 ++it) { |
978 if ((*it)->email() == username) { | 980 if ((*it)->email() == username) { |
979 unlock_user = *it; | 981 unlock_user = *it; |
980 break; | 982 break; |
981 } | 983 } |
982 } | 984 } |
983 if (!unlock_user) | 985 if (!unlock_user) |
984 return; | 986 return; |
985 | 987 |
986 Profile* profile = ProfileHelper::Get()->GetProfileByUser(unlock_user); | 988 Profile* profile = ProfileHelper::Get()->GetProfileByUser(unlock_user); |
987 extensions::ScreenlockPrivateEventRouter* router = | 989 extensions::ScreenlockPrivateEventRouter* router = |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 delegate_->Login(context, specifics); | 1262 delegate_->Login(context, specifics); |
1261 } | 1263 } |
1262 | 1264 |
1263 bool SigninScreenHandler::AllWhitelistedUsersPresent() { | 1265 bool SigninScreenHandler::AllWhitelistedUsersPresent() { |
1264 CrosSettings* cros_settings = CrosSettings::Get(); | 1266 CrosSettings* cros_settings = CrosSettings::Get(); |
1265 bool allow_new_user = false; | 1267 bool allow_new_user = false; |
1266 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1268 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1267 if (allow_new_user) | 1269 if (allow_new_user) |
1268 return false; | 1270 return false; |
1269 UserManager* user_manager = UserManager::Get(); | 1271 UserManager* user_manager = UserManager::Get(); |
1270 const UserList& users = user_manager->GetUsers(); | 1272 const user_manager::UserList& users = user_manager->GetUsers(); |
1271 if (!delegate_ || users.size() > kMaxUsers) { | 1273 if (!delegate_ || users.size() > kMaxUsers) { |
1272 return false; | 1274 return false; |
1273 } | 1275 } |
1274 const base::ListValue* whitelist = NULL; | 1276 const base::ListValue* whitelist = NULL; |
1275 if (!cros_settings->GetList(kAccountsPrefUsers, &whitelist) || !whitelist) | 1277 if (!cros_settings->GetList(kAccountsPrefUsers, &whitelist) || !whitelist) |
1276 return false; | 1278 return false; |
1277 for (size_t i = 0; i < whitelist->GetSize(); ++i) { | 1279 for (size_t i = 0; i < whitelist->GetSize(); ++i) { |
1278 std::string whitelisted_user; | 1280 std::string whitelisted_user; |
1279 // NB: Wildcards in the whitelist are also detected as not present here. | 1281 // NB: Wildcards in the whitelist are also detected as not present here. |
1280 if (!whitelist->GetString(i, &whitelisted_user) || | 1282 if (!whitelist->GetString(i, &whitelisted_user) || |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 return gaia_screen_handler_->frame_error(); | 1380 return gaia_screen_handler_->frame_error(); |
1379 } | 1381 } |
1380 | 1382 |
1381 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1383 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
1382 caps_lock_enabled_ = enabled; | 1384 caps_lock_enabled_ = enabled; |
1383 if (page_is_ready()) | 1385 if (page_is_ready()) |
1384 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1386 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
1385 } | 1387 } |
1386 | 1388 |
1387 } // namespace chromeos | 1389 } // namespace chromeos |
OLD | NEW |