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

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

Powered by Google App Engine
This is Rietveld 408576698