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 "base/task_scheduler/post_task.h" | 10 #include "base/task_scheduler/post_task.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // Runs on SequencedWorkerPool thread under PostTaskAndReply(). | 44 // Runs on SequencedWorkerPool thread under PostTaskAndReply(). |
45 // So data is owned by "Reply" part of PostTaskAndReply() process. | 45 // So data is owned by "Reply" part of PostTaskAndReply() process. |
46 void SwitchLanguageDoReloadLocale(SwitchLanguageData* data) { | 46 void SwitchLanguageDoReloadLocale(SwitchLanguageData* data) { |
47 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 47 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
48 | 48 |
49 data->result.loaded_locale = | 49 data->result.loaded_locale = |
50 ResourceBundle::GetSharedInstance().ReloadLocaleResources( | 50 ResourceBundle::GetSharedInstance().ReloadLocaleResources( |
51 data->result.requested_locale); | 51 data->result.requested_locale); |
52 | 52 |
53 data->result.success = !data->result.loaded_locale.empty(); | 53 data->result.success = !data->result.loaded_locale.empty(); |
54 | |
55 ResourceBundle::GetSharedInstance().ReloadFonts(); | |
56 } | 54 } |
57 | 55 |
58 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. | 56 // Callback after SwitchLanguageDoReloadLocale() back in UI thread. |
59 void FinishSwitchLanguage(std::unique_ptr<SwitchLanguageData> data) { | 57 void FinishSwitchLanguage(std::unique_ptr<SwitchLanguageData> data) { |
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 58 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
61 if (data->result.success) { | 59 if (data->result.success) { |
62 g_browser_process->SetApplicationLocale(data->result.loaded_locale); | 60 g_browser_process->SetApplicationLocale(data->result.loaded_locale); |
63 | 61 |
64 if (data->enable_locale_keyboard_layouts) { | 62 if (data->enable_locale_keyboard_layouts) { |
65 input_method::InputMethodManager* manager = | 63 input_method::InputMethodManager* manager = |
(...skipping 20 matching lines...) Expand all Loading... | |
86 data->result.loaded_locale, | 84 data->result.loaded_locale, |
87 input_method::kKeyboardLayoutsOnly, | 85 input_method::kKeyboardLayoutsOnly, |
88 &input_methods); | 86 &input_methods); |
89 for (std::vector<std::string>::const_iterator it = | 87 for (std::vector<std::string>::const_iterator it = |
90 input_methods.begin(); it != input_methods.end(); ++it) { | 88 input_methods.begin(); it != input_methods.end(); ++it) { |
91 ime_state->EnableInputMethod(*it); | 89 ime_state->EnableInputMethod(*it); |
92 } | 90 } |
93 } | 91 } |
94 } | 92 } |
95 } | 93 } |
94 | |
oshima
2017/02/21 00:24:05
Please add comment that this should be in UI threa
tzik
2017/02/21 04:25:48
Done.
| |
95 ResourceBundle::GetSharedInstance().ReloadFonts(); | |
96 gfx::PlatformFontLinux::ReloadDefaultFont(); | 96 gfx::PlatformFontLinux::ReloadDefaultFont(); |
97 if (!data->callback.is_null()) | 97 if (!data->callback.is_null()) |
98 data->callback.Run(data->result); | 98 data->callback.Run(data->result); |
99 } | 99 } |
100 | 100 |
101 } // namespace | 101 } // namespace |
102 | 102 |
103 namespace locale_util { | 103 namespace locale_util { |
104 | 104 |
105 LanguageSwitchResult::LanguageSwitchResult(const std::string& requested_locale, | 105 LanguageSwitchResult::LanguageSwitchResult(const std::string& requested_locale, |
(...skipping 17 matching lines...) Expand all Loading... | |
123 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); | 123 base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get()))); |
124 base::PostTaskWithTraitsAndReply( | 124 base::PostTaskWithTraitsAndReply( |
125 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 125 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
126 base::TaskPriority::BACKGROUND), | 126 base::TaskPriority::BACKGROUND), |
127 reloader, | 127 reloader, |
128 base::Bind(&FinishSwitchLanguage, base::Passed(std::move(data)))); | 128 base::Bind(&FinishSwitchLanguage, base::Passed(std::move(data)))); |
129 } | 129 } |
130 | 130 |
131 } // namespace locale_util | 131 } // namespace locale_util |
132 } // namespace chromeos | 132 } // namespace chromeos |
OLD | NEW |