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
3 // found in the LICENSE file.
5 // This file contains utility functions for locale change.
7 #ifndef CHROME_BROWSER_CHROMEOS_BASE_LOCALE_UTIL_H_
8 #define CHROME_BROWSER_CHROMEOS_BASE_LOCALE_UTIL_H_
12 #include "base/memory/scoped_ptr.h"
24 namespace locale_util
{
26 struct LanguageSwitchResult
{
27 LanguageSwitchResult(const std::string
& requested_locale
,
28 const std::string
& loaded_locale
,
31 std::string requested_locale
;
32 std::string loaded_locale
;
36 // This callback is called on UI thread, when ReloadLocaleResources() is
37 // completed on BlockingPool.
39 // locale - (copy of) locale argument to SwitchLanguage(). Expected locale.
40 // loaded_locale - actual locale name loaded.
41 // success - if locale load succeeded.
42 // (const std::string* locale, const std::string* loaded_locale, bool success)
43 typedef base::Callback
<void(const LanguageSwitchResult
& result
)>
44 SwitchLanguageCallback
;
46 // This function updates input methods only if requested. In general, you want
47 // |enable_locale_keyboard_layouts = true|. |profile| is needed because IME
48 // extensions are per-user.
49 // Note: in case of |enable_locale_keyboard_layouts = false|, the input method
50 // currently in use may not be supported by the new locale. Using the new locale
51 // with an unsupported input method may lead to undefined behavior. Use
52 // |enable_locale_keyboard_layouts = false| with caution.
53 // Note 2: |login_layouts_only = true| enables only login-capable layouts.
54 void SwitchLanguage(const std::string
& locale
,
55 const bool enable_locale_keyboard_layouts
,
56 const bool login_layouts_only
,
57 const SwitchLanguageCallback
& callback
,
60 } // namespace locale_util
61 } // namespace chromeos
63 #endif // CHROME_BROWSER_CHROMEOS_BASE_LOCALE_UTIL_H_