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

Side by Side Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. Created 6 years, 4 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/chromeos/chrome_browser_main_chromeos.h" 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 450
451 Profile* profile; 451 Profile* profile;
452 }; 452 };
453 453
454 // static 454 // static
455 void GuestLanguageSetCallbackData::Callback( 455 void GuestLanguageSetCallbackData::Callback(
456 const scoped_ptr<GuestLanguageSetCallbackData>& self, 456 const scoped_ptr<GuestLanguageSetCallbackData>& self,
457 const std::string& locale, 457 const std::string& locale,
458 const std::string& loaded_locale, 458 const std::string& loaded_locale,
459 bool success) { 459 bool success) {
460 input_method::InputMethodManager* const ime_manager = 460 input_method::InputMethodManager* manager =
461 input_method::InputMethodManager::Get(); 461 input_method::InputMethodManager::Get();
462 scoped_refptr<input_method::InputMethodManager::State> ime_state =
463 manager->GetActiveIMEState();
462 // Active layout must be hardware "login layout". 464 // Active layout must be hardware "login layout".
463 // The previous one must be "locale default layout". 465 // The previous one must be "locale default layout".
464 // First, enable all hardware input methods. 466 // First, enable all hardware input methods.
465 const std::vector<std::string>& input_methods = 467 const std::vector<std::string>& input_methods =
466 ime_manager->GetInputMethodUtil()->GetHardwareInputMethodIds(); 468 manager->GetInputMethodUtil()->GetHardwareInputMethodIds();
467 for (size_t i = 0; i < input_methods.size(); ++i) 469 for (size_t i = 0; i < input_methods.size(); ++i)
468 ime_manager->EnableInputMethod(input_methods[i]); 470 ime_state->EnableInputMethod(input_methods[i]);
469 471
470 // Second, enable locale based input methods. 472 // Second, enable locale based input methods.
471 const std::string locale_default_input_method = 473 const std::string locale_default_input_method =
472 ime_manager->GetInputMethodUtil()-> 474 manager->GetInputMethodUtil()->GetLanguageDefaultInputMethodId(
473 GetLanguageDefaultInputMethodId(loaded_locale); 475 loaded_locale);
474 if (!locale_default_input_method.empty()) { 476 if (!locale_default_input_method.empty()) {
475 PrefService* user_prefs = self->profile->GetPrefs(); 477 PrefService* user_prefs = self->profile->GetPrefs();
476 user_prefs->SetString(prefs::kLanguagePreviousInputMethod, 478 user_prefs->SetString(prefs::kLanguagePreviousInputMethod,
477 locale_default_input_method); 479 locale_default_input_method);
478 ime_manager->EnableInputMethod(locale_default_input_method); 480 ime_state->EnableInputMethod(locale_default_input_method);
479 } 481 }
480 482
481 // Finally, activate the first login input method. 483 // Finally, activate the first login input method.
482 const std::vector<std::string>& login_input_methods = 484 const std::vector<std::string>& login_input_methods =
483 ime_manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); 485 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds();
484 ime_manager->ChangeInputMethod(login_input_methods[0]); 486 ime_state->ChangeInputMethod(login_input_methods[0],
487 false /* show_message */);
485 } 488 }
486 489
487 void SetGuestLocale(Profile* const profile) { 490 void SetGuestLocale(Profile* const profile) {
488 scoped_ptr<GuestLanguageSetCallbackData> data( 491 scoped_ptr<GuestLanguageSetCallbackData> data(
489 new GuestLanguageSetCallbackData(profile)); 492 new GuestLanguageSetCallbackData(profile));
490 scoped_ptr<locale_util::SwitchLanguageCallback> callback( 493 scoped_ptr<locale_util::SwitchLanguageCallback> callback(
491 new locale_util::SwitchLanguageCallback(base::Bind( 494 new locale_util::SwitchLanguageCallback(base::Bind(
492 &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); 495 &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass()))));
493 user_manager::User* const user = 496 user_manager::User* const user =
494 ProfileHelper::Get()->GetUserByProfile(profile); 497 ProfileHelper::Get()->GetUserByProfile(profile);
(...skipping 20 matching lines...) Expand all
515 bool is_official_build = true; 518 bool is_official_build = true;
516 #else 519 #else
517 bool is_official_build = false; 520 bool is_official_build = false;
518 #endif 521 #endif
519 // Enable portal detector if EULA was previously accepted or if 522 // Enable portal detector if EULA was previously accepted or if
520 // this is an unofficial build. 523 // this is an unofficial build.
521 if (!is_official_build || StartupUtils::IsEulaAccepted()) 524 if (!is_official_build || StartupUtils::IsEulaAccepted())
522 detector->Enable(true); 525 detector->Enable(true);
523 } 526 }
524 527
528 // Initialize input methods.
529 input_method::InputMethodManager* manager =
530 input_method::InputMethodManager::Get();
531 UserSessionManager* session_manager = UserSessionManager::GetInstance();
532 DCHECK(manager);
533 DCHECK(session_manager);
534
535 manager->SetState(session_manager->GetDefaultIMEState(profile()));
536
525 bool is_running_test = parameters().ui_task != NULL; 537 bool is_running_test = parameters().ui_task != NULL;
526 g_browser_process->platform_part()->InitializeSessionManager( 538 g_browser_process->platform_part()->InitializeSessionManager(
527 parsed_command_line(), profile(), is_running_test); 539 parsed_command_line(), profile(), is_running_test);
528 g_browser_process->platform_part()->SessionManager()->Start(); 540 g_browser_process->platform_part()->SessionManager()->Start();
529 541
530 // Guest user profile is never initialized with locale settings, 542 // Guest user profile is never initialized with locale settings,
531 // so we need special handling for Guest session. 543 // so we need special handling for Guest session.
532 if (UserManager::Get()->IsLoggedInAsGuest()) 544 if (UserManager::Get()->IsLoggedInAsGuest())
533 SetGuestLocale(profile()); 545 SetGuestLocale(profile());
534 546
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // Destroy DBus services immediately after threads are stopped. 741 // Destroy DBus services immediately after threads are stopped.
730 dbus_services_.reset(); 742 dbus_services_.reset();
731 743
732 ChromeBrowserMainPartsLinux::PostDestroyThreads(); 744 ChromeBrowserMainPartsLinux::PostDestroyThreads();
733 745
734 // Destroy DeviceSettingsService after g_browser_process. 746 // Destroy DeviceSettingsService after g_browser_process.
735 DeviceSettingsService::Shutdown(); 747 DeviceSettingsService::Shutdown();
736 } 748 }
737 749
738 } // namespace chromeos 750 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698