OLD | NEW |
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/chromeos/base/locale_util.h" | 5 #include "chrome/browser/chromeos/base/locale_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. | 53 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. |
54 void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) { | 54 void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) { |
55 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 55 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
56 if (data->success) { | 56 if (data->success) { |
57 g_browser_process->SetApplicationLocale(data->loaded_locale); | 57 g_browser_process->SetApplicationLocale(data->loaded_locale); |
58 | 58 |
59 if (data->enable_locale_keyboard_layouts) { | 59 if (data->enable_locale_keyboard_layouts) { |
60 input_method::InputMethodManager* manager = | 60 input_method::InputMethodManager* manager = |
61 input_method::InputMethodManager::Get(); | 61 input_method::InputMethodManager::Get(); |
| 62 scoped_refptr<input_method::InputMethodManager::State> ime_state = |
| 63 manager->GetActiveIMEState(); |
62 if (data->login_layouts_only) { | 64 if (data->login_layouts_only) { |
63 // Enable the hardware keyboard layouts and locale-specific layouts | 65 // Enable the hardware keyboard layouts and locale-specific layouts |
64 // suitable for use on the login screen. This will also switch to the | 66 // suitable for use on the login screen. This will also switch to the |
65 // first hardware keyboard layout since the input method currently in | 67 // first hardware keyboard layout since the input method currently in |
66 // use may not be supported by the new locale. | 68 // use may not be supported by the new locale. |
67 manager->EnableLoginLayouts( | 69 ime_state->EnableLoginLayouts( |
68 data->loaded_locale, | 70 data->loaded_locale, |
69 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 71 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
70 } else { | 72 } else { |
71 // Enable all hardware keyboard layouts. This will also switch to the | 73 // Enable all hardware keyboard layouts. This will also switch to the |
72 // first hardware keyboard layout. | 74 // first hardware keyboard layout. |
73 manager->ReplaceEnabledInputMethods( | 75 ime_state->ReplaceEnabledInputMethods( |
74 manager->GetInputMethodUtil()->GetHardwareInputMethodIds()); | 76 manager->GetInputMethodUtil()->GetHardwareInputMethodIds()); |
75 | 77 |
76 // Enable all locale-specific layouts. | 78 // Enable all locale-specific layouts. |
77 std::vector<std::string> input_methods; | 79 std::vector<std::string> input_methods; |
78 manager->GetInputMethodUtil()->GetInputMethodIdsFromLanguageCode( | 80 manager->GetInputMethodUtil()->GetInputMethodIdsFromLanguageCode( |
79 data->loaded_locale, | 81 data->loaded_locale, |
80 input_method::kKeyboardLayoutsOnly, | 82 input_method::kKeyboardLayoutsOnly, |
81 &input_methods); | 83 &input_methods); |
82 for (std::vector<std::string>::const_iterator it = | 84 for (std::vector<std::string>::const_iterator it = |
83 input_methods.begin(); it != input_methods.end(); ++it) { | 85 input_methods.begin(); it != input_methods.end(); ++it) { |
84 manager->EnableInputMethod(*it); | 86 ime_state->EnableInputMethod(*it); |
85 } | 87 } |
86 } | 88 } |
87 } | 89 } |
88 } | 90 } |
89 gfx::PlatformFontPango::ReloadDefaultFont(); | 91 gfx::PlatformFontPango::ReloadDefaultFont(); |
90 if (data->callback) | 92 if (data->callback) |
91 data->callback->Run(data->locale, data->loaded_locale, data->success); | 93 data->callback->Run(data->locale, data->loaded_locale, data->success); |
92 } | 94 } |
93 | 95 |
94 } // namespace | 96 } // namespace |
(...skipping 13 matching lines...) Expand all Loading... |
108 base::Closure reloader( | 110 base::Closure reloader( |
109 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); | 111 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); |
110 content::BrowserThread::PostBlockingPoolTaskAndReply( | 112 content::BrowserThread::PostBlockingPoolTaskAndReply( |
111 FROM_HERE, | 113 FROM_HERE, |
112 reloader, | 114 reloader, |
113 base::Bind(&FinishSwitchLanguage, base::Passed(data.Pass()))); | 115 base::Bind(&FinishSwitchLanguage, base::Passed(data.Pass()))); |
114 } | 116 } |
115 | 117 |
116 } // namespace locale_util | 118 } // namespace locale_util |
117 } // namespace chromeos | 119 } // namespace chromeos |
OLD | NEW |