| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 data->result.loaded_locale = | 48 data->result.loaded_locale = |
| 49 ResourceBundle::GetSharedInstance().ReloadLocaleResources( | 49 ResourceBundle::GetSharedInstance().ReloadLocaleResources( |
| 50 data->result.requested_locale); | 50 data->result.requested_locale); |
| 51 | 51 |
| 52 data->result.success = !data->result.loaded_locale.empty(); | 52 data->result.success = !data->result.loaded_locale.empty(); |
| 53 | 53 |
| 54 ResourceBundle::GetSharedInstance().ReloadFonts(); | 54 ResourceBundle::GetSharedInstance().ReloadFonts(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. | 57 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. |
| 58 void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) { | 58 void FinishSwitchLanguage(std::unique_ptr<SwitchLanguageData> data) { |
| 59 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 60 if (data->result.success) { | 60 if (data->result.success) { |
| 61 g_browser_process->SetApplicationLocale(data->result.loaded_locale); | 61 g_browser_process->SetApplicationLocale(data->result.loaded_locale); |
| 62 | 62 |
| 63 if (data->enable_locale_keyboard_layouts) { | 63 if (data->enable_locale_keyboard_layouts) { |
| 64 input_method::InputMethodManager* manager = | 64 input_method::InputMethodManager* manager = |
| 65 input_method::InputMethodManager::Get(); | 65 input_method::InputMethodManager::Get(); |
| 66 scoped_refptr<input_method::InputMethodManager::State> ime_state = | 66 scoped_refptr<input_method::InputMethodManager::State> ime_state = |
| 67 UserSessionManager::GetInstance()->GetDefaultIMEState(data->profile); | 67 UserSessionManager::GetInstance()->GetDefaultIMEState(data->profile); |
| 68 if (data->login_layouts_only) { | 68 if (data->login_layouts_only) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 loaded_locale(loaded_locale), | 108 loaded_locale(loaded_locale), |
| 109 success(success) { | 109 success(success) { |
| 110 } | 110 } |
| 111 | 111 |
| 112 void SwitchLanguage(const std::string& locale, | 112 void SwitchLanguage(const std::string& locale, |
| 113 const bool enable_locale_keyboard_layouts, | 113 const bool enable_locale_keyboard_layouts, |
| 114 const bool login_layouts_only, | 114 const bool login_layouts_only, |
| 115 const SwitchLanguageCallback& callback, | 115 const SwitchLanguageCallback& callback, |
| 116 Profile* profile) { | 116 Profile* profile) { |
| 117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 118 scoped_ptr<SwitchLanguageData> data( | 118 std::unique_ptr<SwitchLanguageData> data( |
| 119 new SwitchLanguageData(locale, enable_locale_keyboard_layouts, | 119 new SwitchLanguageData(locale, enable_locale_keyboard_layouts, |
| 120 login_layouts_only, callback, profile)); | 120 login_layouts_only, callback, profile)); |
| 121 base::Closure reloader( | 121 base::Closure reloader( |
| 122 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); | 122 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); |
| 123 content::BrowserThread::PostBlockingPoolTaskAndReply( | 123 content::BrowserThread::PostBlockingPoolTaskAndReply( |
| 124 FROM_HERE, reloader, | 124 FROM_HERE, reloader, |
| 125 base::Bind(&FinishSwitchLanguage, base::Passed(std::move(data)))); | 125 base::Bind(&FinishSwitchLanguage, base::Passed(std::move(data)))); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace locale_util | 128 } // namespace locale_util |
| 129 } // namespace chromeos | 129 } // namespace chromeos |
| OLD | NEW |