Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc

Issue 597723003: Revert of ChromeOS: "Add New User" screen should enable all hardware keyboards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 std::string GetNetworkName(const std::string& service_path) { 168 std::string GetNetworkName(const std::string& service_path) {
169 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 169 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
170 GetNetworkState(service_path); 170 GetNetworkState(service_path);
171 if (!network) 171 if (!network)
172 return std::string(); 172 return std::string();
173 return network->name(); 173 return network->name();
174 } 174 }
175 175
176 static bool SetUserInputMethodImpl( 176 static bool SetUserInputMethodImpl(
177 const std::string& username, 177 const std::string& username,
178 const std::string& user_input_method, 178 chromeos::input_method::InputMethodManager* manager) {
179 input_method::InputMethodManager::State* ime_state) { 179 PrefService* const local_state = g_browser_process->local_state();
180 if (!chromeos::input_method::InputMethodManager::Get()->IsLoginKeyboard( 180
181 user_input_method)) { 181 const base::DictionaryValue* users_lru_input_methods =
182 local_state->GetDictionary(prefs::kUsersLRUInputMethod);
183
184 if (users_lru_input_methods == NULL) {
185 DLOG(WARNING) << "SetUserInputMethod('" << username
186 << "'): no kUsersLRUInputMethod";
187 return false;
188 }
189
190 std::string input_method;
191
192 if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
193 &input_method)) {
194 DVLOG(0) << "SetUserInputMethod('" << username
195 << "'): no input method for this user";
196 return false;
197 }
198
199 if (input_method.empty())
200 return false;
201
202 if (!manager->IsLoginKeyboard(input_method)) {
182 LOG(WARNING) << "SetUserInputMethod('" << username 203 LOG(WARNING) << "SetUserInputMethod('" << username
183 << "'): stored user LRU input method '" << user_input_method 204 << "'): stored user LRU input method '" << input_method
184 << "' is no longer Full Latin Keyboard Language" 205 << "' is no longer Full Latin Keyboard Language"
185 << " (entry dropped). Use hardware default instead."; 206 << " (entry dropped). Use hardware default instead.";
186 207
187 PrefService* const local_state = g_browser_process->local_state();
188 DictionaryPrefUpdate updater(local_state, prefs::kUsersLRUInputMethod); 208 DictionaryPrefUpdate updater(local_state, prefs::kUsersLRUInputMethod);
189 209
190 base::DictionaryValue* const users_lru_input_methods = updater.Get(); 210 base::DictionaryValue* const users_lru_input_methods = updater.Get();
191 if (users_lru_input_methods != NULL) { 211 if (users_lru_input_methods != NULL) {
192 users_lru_input_methods->SetStringWithoutPathExpansion(username, ""); 212 users_lru_input_methods->SetStringWithoutPathExpansion(username, "");
193 } 213 }
194 return false; 214 return false;
195 } 215 }
196 216
197 if (!Contains(ime_state->GetActiveInputMethodIds(), user_input_method)) { 217 if (!Contains(manager->GetActiveIMEState()->GetActiveInputMethodIds(),
198 if (!ime_state->EnableInputMethod(user_input_method)) { 218 input_method)) {
219 if (!manager->GetActiveIMEState()->EnableInputMethod(input_method)) {
199 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username 220 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username
200 << "'): user input method '" << user_input_method 221 << "'): user input method '" << input_method
201 << "' is not enabled and enabling failed (ignored!)."; 222 << "' is not enabled and enabling failed (ignored!).";
202 } 223 }
203 } 224 }
204 ime_state->ChangeInputMethod(user_input_method, false /* show_message */); 225 manager->GetActiveIMEState()->ChangeInputMethod(input_method,
226 false /* show_message */);
205 227
206 return true; 228 return true;
207 } 229 }
208 230
209 } // namespace 231 } // namespace
210 232
211 // LoginScreenContext implementation ------------------------------------------ 233 // LoginScreenContext implementation ------------------------------------------
212 234
213 LoginScreenContext::LoginScreenContext() { 235 LoginScreenContext::LoginScreenContext() {
214 Init(); 236 Init();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 policy::ConsumerManagementService* consumer_management = 307 policy::ConsumerManagementService* consumer_management =
286 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 308 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
287 GetConsumerManagementService(); 309 GetConsumerManagementService();
288 is_enrolling_consumer_management_ = 310 is_enrolling_consumer_management_ =
289 consumer_management && 311 consumer_management &&
290 consumer_management->GetEnrollmentStage() == 312 consumer_management->GetEnrollmentStage() ==
291 policy::ConsumerManagementService::ENROLLMENT_STAGE_REQUESTED; 313 policy::ConsumerManagementService::ENROLLMENT_STAGE_REQUESTED;
292 } 314 }
293 315
294 SigninScreenHandler::~SigninScreenHandler() { 316 SigninScreenHandler::~SigninScreenHandler() {
295 OobeUI* oobe_ui = GetOobeUI();
296 if (oobe_ui)
297 oobe_ui->RemoveObserver(this);
298 chromeos::input_method::ImeKeyboard* keyboard = 317 chromeos::input_method::ImeKeyboard* keyboard =
299 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); 318 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard();
300 if (keyboard) 319 if (keyboard)
301 keyboard->RemoveObserver(this); 320 keyboard->RemoveObserver(this);
302 weak_factory_.InvalidateWeakPtrs(); 321 weak_factory_.InvalidateWeakPtrs();
303 if (delegate_) 322 if (delegate_)
304 delegate_->SetWebUIHandler(NULL); 323 delegate_->SetWebUIHandler(NULL);
305 network_state_informer_->RemoveObserver(this); 324 network_state_informer_->RemoveObserver(this);
306 if (max_mode_delegate_) { 325 if (max_mode_delegate_) {
307 max_mode_delegate_->RemoveObserver(this); 326 max_mode_delegate_->RemoveObserver(this);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 void SigninScreenHandler::OnNetworkReady() { 471 void SigninScreenHandler::OnNetworkReady() {
453 VLOG(1) << "OnNetworkReady() call."; 472 VLOG(1) << "OnNetworkReady() call.";
454 DCHECK(gaia_screen_handler_); 473 DCHECK(gaia_screen_handler_);
455 gaia_screen_handler_->MaybePreloadAuthExtension(); 474 gaia_screen_handler_->MaybePreloadAuthExtension();
456 } 475 }
457 476
458 void SigninScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { 477 void SigninScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) {
459 UpdateStateInternal(reason, false); 478 UpdateStateInternal(reason, false);
460 } 479 }
461 480
462 void SigninScreenHandler::SetFocusPODCallbackForTesting(
463 base::Closure callback) {
464 test_focus_pod_callback_ = callback;
465 }
466
467 // SigninScreenHandler, private: ----------------------------------------------- 481 // SigninScreenHandler, private: -----------------------------------------------
468 482
469 void SigninScreenHandler::ShowImpl() { 483 void SigninScreenHandler::ShowImpl() {
470 if (!page_is_ready()) { 484 if (!page_is_ready()) {
471 show_on_init_ = true; 485 show_on_init_ = true;
472 return; 486 return;
473 } 487 }
474 488
475 if (!ime_state_.get())
476 ime_state_ = input_method::InputMethodManager::Get()->GetActiveIMEState();
477
478 GetOobeUI()->AddObserver(this);
479
480 if (oobe_ui_ || is_enrolling_consumer_management_) { 489 if (oobe_ui_ || is_enrolling_consumer_management_) {
481 // Shows new user sign-in for OOBE. 490 // Shows new user sign-in for OOBE.
482 OnShowAddUser(); 491 OnShowAddUser();
483 } else { 492 } else {
484 // Populates account picker. Animation is turned off for now until we 493 // Populates account picker. Animation is turned off for now until we
485 // figure out how to make it fast enough. 494 // figure out how to make it fast enough.
486 delegate_->HandleGetUsers(); 495 delegate_->HandleGetUsers();
487 496
488 // Reset Caps Lock state when login screen is shown. 497 // Reset Caps Lock state when login screen is shown.
489 input_method::InputMethodManager::Get() 498 input_method::InputMethodManager::Get()
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 787
779 // This message is sent by the kiosk app menu, but is handled here 788 // This message is sent by the kiosk app menu, but is handled here
780 // so we can tell the delegate to launch the app. 789 // so we can tell the delegate to launch the app.
781 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); 790 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp);
782 } 791 }
783 792
784 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { 793 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
785 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); 794 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod);
786 } 795 }
787 796
788 void SigninScreenHandler::OnCurrentScreenChanged(OobeUI::Screen current_screen,
789 OobeUI::Screen new_screen) {
790 if (new_screen == OobeUI::SCREEN_ACCOUNT_PICKER) {
791 // Restore active IME state if returning to user pod row screen.
792 input_method::InputMethodManager::Get()->SetState(ime_state_);
793 }
794 }
795
796 std::string SigninScreenHandler::GetUserLRUInputMethod(
797 const std::string& username) const {
798 PrefService* const local_state = g_browser_process->local_state();
799 const base::DictionaryValue* users_lru_input_methods =
800 local_state->GetDictionary(prefs::kUsersLRUInputMethod);
801
802 if (users_lru_input_methods == NULL) {
803 DLOG(WARNING) << "GetUserLRUInputMethod('" << username
804 << "'): no kUsersLRUInputMethod";
805 return std::string();
806 }
807
808 std::string input_method;
809
810 if (!users_lru_input_methods->GetStringWithoutPathExpansion(username,
811 &input_method)) {
812 DVLOG(0) << "GetUserLRUInputMethod('" << username
813 << "'): no input method for this user";
814 return std::string();
815 }
816
817 return input_method;
818 }
819
820 void SigninScreenHandler::HandleGetUsers() { 797 void SigninScreenHandler::HandleGetUsers() {
821 if (delegate_) 798 if (delegate_)
822 delegate_->HandleGetUsers(); 799 delegate_->HandleGetUsers();
823 } 800 }
824 801
825 void SigninScreenHandler::ClearAndEnablePassword() { 802 void SigninScreenHandler::ClearAndEnablePassword() {
826 core_oobe_actor_->ResetSignInUI(false); 803 core_oobe_actor_->ResetSignInUI(false);
827 } 804 }
828 805
829 void SigninScreenHandler::ClearUserPodPassword() { 806 void SigninScreenHandler::ClearUserPodPassword() {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 993
1017 bool SigninScreenHandler::ShouldLoadGaia() const { 994 bool SigninScreenHandler::ShouldLoadGaia() const {
1018 // Fetching of the extension is not started before account picker page is 995 // Fetching of the extension is not started before account picker page is
1019 // loaded because it can affect the loading speed. 996 // loaded because it can affect the loading speed.
1020 // Do not load the extension for the screen locker, see crosbug.com/25018. 997 // Do not load the extension for the screen locker, see crosbug.com/25018.
1021 return !ScreenLocker::default_screen_locker() && 998 return !ScreenLocker::default_screen_locker() &&
1022 is_account_picker_showing_first_time_; 999 is_account_picker_showing_first_time_;
1023 } 1000 }
1024 1001
1025 // Update keyboard layout to least recently used by the user. 1002 // Update keyboard layout to least recently used by the user.
1026 void SigninScreenHandler::SetUserInputMethod( 1003 void SigninScreenHandler::SetUserInputMethod(const std::string& username) {
1027 const std::string& username,
1028 input_method::InputMethodManager::State* ime_state) {
1029 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1004 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1030 if (user_manager->IsUserLoggedIn()) { 1005 if (user_manager->IsUserLoggedIn()) {
1031 // We are on sign-in screen inside user session (adding new user to 1006 // We are on sign-in screen inside user session (adding new user to
1032 // the session or on lock screen), don't switch input methods in this case. 1007 // the session or on lock screen), don't switch input methods in this case.
1033 // TODO(dpolukhin): adding user and sign-in should be consistent 1008 // TODO(dpolukhin): adding user and sign-in should be consistent
1034 // crbug.com/292774 1009 // crbug.com/292774
1035 return; 1010 return;
1036 } 1011 }
1037 1012
1038 bool succeed = false; 1013 chromeos::input_method::InputMethodManager* const manager =
1014 chromeos::input_method::InputMethodManager::Get();
1039 1015
1040 const std::string input_method = GetUserLRUInputMethod(username); 1016 const bool succeed = SetUserInputMethodImpl(username, manager);
1041
1042 if (!input_method.empty())
1043 succeed = SetUserInputMethodImpl(username, input_method, ime_state);
1044 1017
1045 // This is also a case when LRU layout is set only for a few local users, 1018 // This is also a case when LRU layout is set only for a few local users,
1046 // thus others need to be switched to default locale. 1019 // thus others need to be switched to default locale.
1047 // Otherwise they will end up using another user's locale to log in. 1020 // Otherwise they will end up using another user's locale to log in.
1048 if (!succeed) { 1021 if (!succeed) {
1049 DVLOG(0) << "SetUserInputMethod('" << username 1022 DVLOG(0) << "SetUserInputMethod('" << username
1050 << "'): failed to set user layout. Switching to default."; 1023 << "'): failed to set user layout. Switching to default.";
1051 1024
1052 ime_state->SetInputMethodLoginDefault(); 1025 manager->GetActiveIMEState()->SetInputMethodLoginDefault();
1053 } 1026 }
1054 } 1027 }
1055 1028
1056 1029
1057 void SigninScreenHandler::UserSettingsChanged() { 1030 void SigninScreenHandler::UserSettingsChanged() {
1058 DCHECK(gaia_screen_handler_); 1031 DCHECK(gaia_screen_handler_);
1059 GaiaContext context; 1032 GaiaContext context;
1060 if (delegate_) 1033 if (delegate_)
1061 context.has_users = !delegate_->GetUsers().empty(); 1034 context.has_users = !delegate_->GetUsers().empty();
1062 gaia_screen_handler_->UpdateGaia(context); 1035 gaia_screen_handler_->UpdateGaia(context);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 1318
1346 void SigninScreenHandler::HandleShowLoadingTimeoutError() { 1319 void SigninScreenHandler::HandleShowLoadingTimeoutError() {
1347 UpdateState(ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT); 1320 UpdateState(ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT);
1348 } 1321 }
1349 1322
1350 void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) { 1323 void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) {
1351 offline_login_active_ = offline_login_active; 1324 offline_login_active_ = offline_login_active;
1352 } 1325 }
1353 1326
1354 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { 1327 void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
1355 SetUserInputMethod(user_id, ime_state_.get()); 1328 SetUserInputMethod(user_id);
1356 #if !defined(USE_ATHENA) 1329 #if !defined(USE_ATHENA)
1357 // TODO(dpolukhin): crbug.com/408734. 1330 // TODO(dpolukhin): crbug.com/408734.
1358 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); 1331 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
1359 #endif 1332 #endif
1360 ScreenlockBridge::Get()->SetFocusedUser(user_id); 1333 ScreenlockBridge::Get()->SetFocusedUser(user_id);
1361 if (!test_focus_pod_callback_.is_null())
1362 test_focus_pod_callback_.Run();
1363 } 1334 }
1364 1335
1365 void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) { 1336 void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) {
1366 SetAuthType(user_id, 1337 SetAuthType(user_id,
1367 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, 1338 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
1368 base::string16()); 1339 base::string16());
1369 HideUserPodCustomIcon(user_id); 1340 HideUserPodCustomIcon(user_id);
1370 } 1341 }
1371 1342
1372 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( 1343 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 return true; 1424 return true;
1454 } 1425 }
1455 1426
1456 void SigninScreenHandler::CancelPasswordChangedFlowInternal() { 1427 void SigninScreenHandler::CancelPasswordChangedFlowInternal() {
1457 if (delegate_) { 1428 if (delegate_) {
1458 ShowImpl(); 1429 ShowImpl();
1459 delegate_->CancelPasswordChangedFlow(); 1430 delegate_->CancelPasswordChangedFlow();
1460 } 1431 }
1461 } 1432 }
1462 1433
1463 OobeUI* SigninScreenHandler::GetOobeUI() const {
1464 return static_cast<OobeUI*>(web_ui()->GetController());
1465 }
1466
1467 OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const { 1434 OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const {
1468 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; 1435 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN;
1469 OobeUI* oobe_ui = GetOobeUI(); 1436 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
1470 if (oobe_ui) 1437 if (oobe_ui)
1471 screen = oobe_ui->current_screen(); 1438 screen = oobe_ui->current_screen();
1472 return screen; 1439 return screen;
1473 } 1440 }
1474 1441
1475 bool SigninScreenHandler::IsGaiaVisible() const { 1442 bool SigninScreenHandler::IsGaiaVisible() const {
1476 return IsSigninScreen(GetCurrentScreen()) && 1443 return IsSigninScreen(GetCurrentScreen()) &&
1477 ui_state_ == UI_STATE_GAIA_SIGNIN; 1444 ui_state_ == UI_STATE_GAIA_SIGNIN;
1478 } 1445 }
1479 1446
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 return gaia_screen_handler_->frame_error(); 1517 return gaia_screen_handler_->frame_error();
1551 } 1518 }
1552 1519
1553 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { 1520 void SigninScreenHandler::OnCapsLockChanged(bool enabled) {
1554 caps_lock_enabled_ = enabled; 1521 caps_lock_enabled_ = enabled;
1555 if (page_is_ready()) 1522 if (page_is_ready())
1556 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); 1523 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_);
1557 } 1524 }
1558 1525
1559 } // namespace chromeos 1526 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698