| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 ResourceBundle::GetSharedInstance().ReloadLocaleResources( | 43 ResourceBundle::GetSharedInstance().ReloadLocaleResources( |
| 44 data->result.requested_locale); | 44 data->result.requested_locale); |
| 45 | 45 |
| 46 data->result.success = !data->result.loaded_locale.empty(); | 46 data->result.success = !data->result.loaded_locale.empty(); |
| 47 | 47 |
| 48 ResourceBundle::GetSharedInstance().ReloadFonts(); | 48 ResourceBundle::GetSharedInstance().ReloadFonts(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. | 51 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. |
| 52 void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) { | 52 void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) { |
| 53 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 53 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 54 if (data->result.success) { | 54 if (data->result.success) { |
| 55 g_browser_process->SetApplicationLocale(data->result.loaded_locale); | 55 g_browser_process->SetApplicationLocale(data->result.loaded_locale); |
| 56 | 56 |
| 57 if (data->enable_locale_keyboard_layouts) { | 57 if (data->enable_locale_keyboard_layouts) { |
| 58 input_method::InputMethodManager* manager = | 58 input_method::InputMethodManager* manager = |
| 59 input_method::InputMethodManager::Get(); | 59 input_method::InputMethodManager::Get(); |
| 60 scoped_refptr<input_method::InputMethodManager::State> ime_state = | 60 scoped_refptr<input_method::InputMethodManager::State> ime_state = |
| 61 manager->GetActiveIMEState(); | 61 manager->GetActiveIMEState(); |
| 62 if (data->login_layouts_only) { | 62 if (data->login_layouts_only) { |
| 63 // Enable the hardware keyboard layouts and locale-specific layouts | 63 // Enable the hardware keyboard layouts and locale-specific layouts |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 bool success) | 100 bool success) |
| 101 : requested_locale(requested_locale), | 101 : requested_locale(requested_locale), |
| 102 loaded_locale(loaded_locale), | 102 loaded_locale(loaded_locale), |
| 103 success(success) { | 103 success(success) { |
| 104 } | 104 } |
| 105 | 105 |
| 106 void SwitchLanguage(const std::string& locale, | 106 void SwitchLanguage(const std::string& locale, |
| 107 const bool enable_locale_keyboard_layouts, | 107 const bool enable_locale_keyboard_layouts, |
| 108 const bool login_layouts_only, | 108 const bool login_layouts_only, |
| 109 const SwitchLanguageCallback& callback) { | 109 const SwitchLanguageCallback& callback) { |
| 110 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 111 scoped_ptr<SwitchLanguageData> data(new SwitchLanguageData( | 111 scoped_ptr<SwitchLanguageData> data(new SwitchLanguageData( |
| 112 locale, enable_locale_keyboard_layouts, login_layouts_only, callback)); | 112 locale, enable_locale_keyboard_layouts, login_layouts_only, callback)); |
| 113 base::Closure reloader( | 113 base::Closure reloader( |
| 114 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); | 114 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); |
| 115 content::BrowserThread::PostBlockingPoolTaskAndReply( | 115 content::BrowserThread::PostBlockingPoolTaskAndReply( |
| 116 FROM_HERE, | 116 FROM_HERE, |
| 117 reloader, | 117 reloader, |
| 118 base::Bind(&FinishSwitchLanguage, base::Passed(data.Pass()))); | 118 base::Bind(&FinishSwitchLanguage, base::Passed(data.Pass()))); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace locale_util | 121 } // namespace locale_util |
| 122 } // namespace chromeos | 122 } // namespace chromeos |
| OLD | NEW |