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 #ifndef CHROMEOS_IME_EXTENSION_IME_UTIL_H_
6 #define CHROMEOS_IME_EXTENSION_IME_UTIL_H_
10 #include "base/auto_reset.h"
11 #include "chromeos/chromeos_export.h"
15 // Extension IME related utilities.
16 namespace extension_ime_util
{
18 // Returns InputMethodID for |engine_id| in |extension_id| of extension IME.
19 // This function does not check |extension_id| is installed extension IME nor
20 // |engine_id| is really a member of |extension_id|.
21 std::string CHROMEOS_EXPORT
GetInputMethodID(const std::string
& extension_id
,
22 const std::string
& engine_id
);
24 // Returns InputMethodID for |engine_id| in |extension_id| of component
25 // extension IME, This function does not check |extension_id| is component one
26 // nor |engine_id| is really a member of |extension_id|.
27 std::string CHROMEOS_EXPORT
GetComponentInputMethodID(
28 const std::string
& extension_id
,
29 const std::string
& engine_id
);
31 // Returns extension ID if |input_method_id| is extension IME ID or component
32 // extension IME ID. Otherwise returns an empty string ("").
33 std::string CHROMEOS_EXPORT
GetExtensionIDFromInputMethodID(
34 const std::string
& input_method_id
);
36 // Returns InputMethodID from keyboard layout (xkb) id (e.g. xkb:fr:fra).
37 std::string CHROMEOS_EXPORT
GetInputMethodIDByKeyboardLayout(
38 const std::string
& keyboard_layout_id
);
40 // Returns true if |input_method_id| is extension IME ID. This function does not
41 // check |input_method_id| is installed extension IME.
42 bool CHROMEOS_EXPORT
IsExtensionIME(const std::string
& input_method_id
);
44 // Returns true if |input_method_id| is component extension IME ID. This
45 // function does not check |input_method_id| is really whitelisted one or not.
46 // If you want to check |input_method_id| is whitelisted component extension
47 // IME, please use ComponentExtensionIMEManager::IsWhitelisted instead.
48 bool CHROMEOS_EXPORT
IsComponentExtensionIME(
49 const std::string
& input_method_id
);
51 // Returns true if the |input_method| is a member of |extension_id| of extension
52 // IME, otherwise returns false.
53 bool CHROMEOS_EXPORT
IsMemberOfExtension(const std::string
& input_method_id
,
54 const std::string
& extension_id
);
56 // Returns true if the |input_method_id| is the extension based xkb keyboard,
57 // otherwise returns false.
58 bool CHROMEOS_EXPORT
IsKeyboardLayoutExtension(
59 const std::string
& input_method_id
);
61 // Returns true to use the wrapped extension keyboards instead of the legacy
62 // xkb keyboards, returns false otherwise.
63 bool CHROMEOS_EXPORT
UseWrappedExtensionKeyboardLayouts();
65 // Gets legacy xkb id (e.g. xkb:us::eng) from the new extension based xkb id
66 // (e.g. _comp_ime_...xkb:us::eng). If the given id is not prefixed with
67 // 'xkb:', just return the same as the given id.
68 std::string CHROMEOS_EXPORT
MaybeGetLegacyXkbId(
69 const std::string
& input_method_id
);
71 // The scoped class to temporarily set the flag to use extension based xkb
72 // keyboards for testing.
73 class CHROMEOS_EXPORT ScopedUseExtensionKeyboardFlagForTesting
{
75 explicit ScopedUseExtensionKeyboardFlagForTesting(bool new_flag
);
76 ~ScopedUseExtensionKeyboardFlagForTesting();
79 base::AutoReset
<bool> auto_reset_
;
82 } // namespace extension_ime_util
84 } // namespace chromeos
86 #endif // CHROMEOS_IME_EXTENSION_IME_UTIL_H_