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

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

Issue 484353005: ChromeOS: "Add New User" screen should enable all hardware keyboards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 3 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 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/chromeos/login/gaia_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_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/browser_shutdown.h" 14 #include "chrome/browser/browser_shutdown.h"
15 #include "chrome/browser/chromeos/input_method/input_method_util.h"
16 #include "chrome/browser/chromeos/language_preferences.h"
15 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 17 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
16 #include "chrome/browser/chromeos/policy/consumer_management_service.h" 18 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 19 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "chrome/browser/io_thread.h" 21 #include "chrome/browser/io_thread.h"
20 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 22 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
21 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" 23 #include "chrome/browser/ui/webui/signin/inline_login_ui.h"
22 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
23 #include "chrome/grit/generated_resources.h" 25 #include "chrome/grit/generated_resources.h"
24 #include "chromeos/chromeos_switches.h" 26 #include "chromeos/chromeos_switches.h"
27 #include "chromeos/ime/input_method_manager.h"
25 #include "chromeos/settings/cros_settings_names.h" 28 #include "chromeos/settings/cros_settings_names.h"
26 #include "components/user_manager/user_manager.h" 29 #include "components/user_manager/user_manager.h"
27 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
29 #include "google_apis/gaia/gaia_auth_util.h" 32 #include "google_apis/gaia/gaia_auth_util.h"
30 #include "google_apis/gaia/gaia_switches.h" 33 #include "google_apis/gaia/gaia_switches.h"
31 #include "google_apis/gaia/gaia_urls.h" 34 #include "google_apis/gaia/gaia_urls.h"
32 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
33 36
34 using content::BrowserThread; 37 using content::BrowserThread;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // The Task posted to PostTaskAndReply in StartClearingDnsCache on the IO 101 // The Task posted to PostTaskAndReply in StartClearingDnsCache on the IO
99 // thread. 102 // thread.
100 void ClearDnsCache(IOThread* io_thread) { 103 void ClearDnsCache(IOThread* io_thread) {
101 DCHECK_CURRENTLY_ON(BrowserThread::IO); 104 DCHECK_CURRENTLY_ON(BrowserThread::IO);
102 if (browser_shutdown::IsTryingToQuit()) 105 if (browser_shutdown::IsTryingToQuit())
103 return; 106 return;
104 107
105 io_thread->ClearHostCache(); 108 io_thread->ClearHostCache();
106 } 109 }
107 110
111 void PushFrontIMIfNotExists(const std::string& input_method,
112 std::vector<std::string>* input_methods) {
113 if (input_method.empty())
114 return;
115
116 if (std::find(input_methods->begin(), input_methods->end(), input_method) ==
117 input_methods->end())
118 input_methods->insert(input_methods->begin(), input_method);
119 }
120
108 } // namespace 121 } // namespace
109 122
110 GaiaContext::GaiaContext() 123 GaiaContext::GaiaContext()
111 : force_reload(false), 124 : force_reload(false),
112 is_local(false), 125 is_local(false),
113 password_changed(false), 126 password_changed(false),
114 show_users(false), 127 show_users(false),
115 use_offline(false), 128 use_offline(false),
116 has_users(false) {} 129 has_users(false) {}
117 130
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // Gaia page will be realoded, so focus isn't stolen anymore. 563 // Gaia page will be realoded, so focus isn't stolen anymore.
551 focus_stolen_ = false; 564 focus_stolen_ = false;
552 } 565 }
553 566
554 // Note that LoadAuthExtension clears |populated_email_|. 567 // Note that LoadAuthExtension clears |populated_email_|.
555 if (populated_email_.empty()) 568 if (populated_email_.empty())
556 Delegate()->LoadSigninWallpaper(); 569 Delegate()->LoadSigninWallpaper();
557 else 570 else
558 Delegate()->LoadWallpaper(populated_email_); 571 Delegate()->LoadWallpaper(populated_email_);
559 572
573 input_method::InputMethodManager* imm =
574 input_method::InputMethodManager::Get();
575
576 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state =
577 imm->GetActiveIMEState()->Clone();
578 imm->SetState(gaia_ime_state);
579
560 // Set Least Recently Used input method for the user. 580 // Set Least Recently Used input method for the user.
561 if (!populated_email_.empty()) 581 if (!populated_email_.empty()) {
562 signin_screen_handler_->SetUserInputMethod(populated_email_); 582 signin_screen_handler_->SetUserInputMethod(populated_email_,
583 gaia_ime_state.get());
584 } else {
585 std::vector<std::string> input_methods =
586 imm->GetInputMethodUtil()->GetHardwareLoginInputMethodIds();
587 const std::string owner_im = signin_screen_handler_->GetUserLRUInputMethod(
588 user_manager::UserManager::Get()->GetOwnerEmail());
589 const std::string system_im = g_browser_process->local_state()->GetString(
590 language_prefs::kPreferredKeyboardLayout);
591
592 PushFrontIMIfNotExists(owner_im, &input_methods);
593 PushFrontIMIfNotExists(system_im, &input_methods);
594
595 gaia_ime_state->EnableLoginLayouts(
596 g_browser_process->GetApplicationLocale(), input_methods);
597
598 if (!system_im.empty()) {
599 gaia_ime_state->ChangeInputMethod(system_im, false /* show_message */);
600 } else if (!owner_im.empty()) {
601 gaia_ime_state->ChangeInputMethod(owner_im, false /* show_message */);
602 }
603 }
563 604
564 LoadAuthExtension(!gaia_silent_load_, false, false); 605 LoadAuthExtension(!gaia_silent_load_, false, false);
565 signin_screen_handler_->UpdateUIState( 606 signin_screen_handler_->UpdateUIState(
566 SigninScreenHandler::UI_STATE_GAIA_SIGNIN, NULL); 607 SigninScreenHandler::UI_STATE_GAIA_SIGNIN, NULL);
567 608
568 if (gaia_silent_load_) { 609 if (gaia_silent_load_) {
569 // The variable is assigned to false because silently loaded Gaia page was 610 // The variable is assigned to false because silently loaded Gaia page was
570 // used. 611 // used.
571 gaia_silent_load_ = false; 612 gaia_silent_load_ = false;
572 if (focus_stolen_) 613 if (focus_stolen_)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 666
626 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { 667 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() {
627 DCHECK(signin_screen_handler_); 668 DCHECK(signin_screen_handler_);
628 return signin_screen_handler_->delegate_; 669 return signin_screen_handler_->delegate_;
629 } 670 }
630 671
631 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { 672 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) {
632 signin_screen_handler_ = handler; 673 signin_screen_handler_ = handler;
633 } 674 }
634 } // namespace chromeos 675 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698