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 #ifndef CHROMEOS_IME_EXTENSION_IME_UTIL_H_ | 5 #ifndef CHROMEOS_IME_EXTENSION_IME_UTIL_H_ |
6 #define CHROMEOS_IME_EXTENSION_IME_UTIL_H_ | 6 #define CHROMEOS_IME_EXTENSION_IME_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | |
10 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 | 14 |
14 // Extension IME related utilities. | 15 // Extension IME related utilities. |
15 namespace extension_ime_util { | 16 namespace extension_ime_util { |
16 | 17 |
17 // Returns InputMethodID for |engine_id| in |extension_id| of extension IME. | 18 // Returns InputMethodID for |engine_id| in |extension_id| of extension IME. |
18 // This function does not check |extension_id| is installed extension IME nor | 19 // This function does not check |extension_id| is installed extension IME nor |
19 // |engine_id| is really a member of |extension_id|. | 20 // |engine_id| is really a member of |extension_id|. |
20 std::string CHROMEOS_EXPORT GetInputMethodID(const std::string& extension_id, | 21 std::string CHROMEOS_EXPORT GetInputMethodID(const std::string& extension_id, |
21 const std::string& engine_id); | 22 const std::string& engine_id); |
22 | 23 |
23 // Returns InputMethodID for |engine_id| in |extension_id| of component | 24 // Returns InputMethodID for |engine_id| in |extension_id| of component |
24 // extension IME, This function does not check |extension_id| is component one | 25 // extension IME, This function does not check |extension_id| is component one |
25 // nor |engine_id| is really a member of |extension_id|. | 26 // nor |engine_id| is really a member of |extension_id|. |
26 std::string CHROMEOS_EXPORT GetComponentInputMethodID( | 27 std::string CHROMEOS_EXPORT GetComponentInputMethodID( |
27 const std::string& extension_id, | 28 const std::string& extension_id, |
28 const std::string& engine_id); | 29 const std::string& engine_id); |
29 | 30 |
30 // Returns extension ID if |input_method_id| is extension IME ID or component | 31 // Returns extension ID if |input_method_id| is extension IME ID or component |
31 // extension IME ID. Otherwise returns an empty string (""). | 32 // extension IME ID. Otherwise returns an empty string (""). |
32 std::string CHROMEOS_EXPORT GetExtensionIDFromInputMethodID( | 33 std::string CHROMEOS_EXPORT GetExtensionIDFromInputMethodID( |
33 const std::string& input_method_id); | 34 const std::string& input_method_id); |
34 | 35 |
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); | |
39 | |
35 // Returns true if |input_method_id| is extension IME ID. This function does not | 40 // Returns true if |input_method_id| is extension IME ID. This function does not |
36 // check |input_method_id| is installed extension IME. | 41 // check |input_method_id| is installed extension IME. |
37 bool CHROMEOS_EXPORT IsExtensionIME(const std::string& input_method_id); | 42 bool CHROMEOS_EXPORT IsExtensionIME(const std::string& input_method_id); |
38 | 43 |
39 // Returns true if |input_method_id| is component extension IME ID. This | 44 // Returns true if |input_method_id| is component extension IME ID. This |
40 // function does not check |input_method_id| is really whitelisted one or not. | 45 // function does not check |input_method_id| is really whitelisted one or not. |
41 // If you want to check |input_method_id| is whitelisted component extension | 46 // If you want to check |input_method_id| is whitelisted component extension |
42 // IME, please use ComponentExtensionIMEManager::IsWhitelisted instead. | 47 // IME, please use ComponentExtensionIMEManager::IsWhitelisted instead. |
43 bool CHROMEOS_EXPORT IsComponentExtensionIME( | 48 bool CHROMEOS_EXPORT IsComponentExtensionIME( |
44 const std::string& input_method_id); | 49 const std::string& input_method_id); |
45 | 50 |
46 // Returns true if the |input_method| is a member of |extension_id| of extension | 51 // Returns true if the |input_method| is a member of |extension_id| of extension |
47 // IME, otherwise returns false. | 52 // IME, otherwise returns false. |
48 bool CHROMEOS_EXPORT IsMemberOfExtension(const std::string& input_method_id, | 53 bool CHROMEOS_EXPORT IsMemberOfExtension(const std::string& input_method_id, |
49 const std::string& extension_id); | 54 const std::string& extension_id); |
50 | 55 |
51 // Returns true if the |input_method_id| is the extension based xkb keyboard, | 56 // Returns true if the |input_method_id| is the extension based xkb keyboard, |
52 // otherwise returns false. | 57 // otherwise returns false. |
53 bool CHROMEOS_EXPORT IsKeyboardLayoutExtension( | 58 bool CHROMEOS_EXPORT IsKeyboardLayoutExtension( |
54 const std::string& input_method_id); | 59 const std::string& input_method_id); |
55 | 60 |
61 // Returns true to use the wrapped extension keyboards instead of the legacy | |
62 // xkb keyboards, returns false otherwise. | |
63 bool CHROMEOS_EXPORT UseWrappedExtensionKeyboardLayouts(); | |
64 | |
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); | |
70 | |
71 // The scoped class to temporarily set the flag to use extension based xkb | |
72 // keyboards for testing. | |
73 class CHROMEOS_EXPORT ScopedUseExtensionKeyboardFlagForTesting { | |
74 public: | |
75 explicit ScopedUseExtensionKeyboardFlagForTesting(bool newFlag); | |
Yuki
2014/03/04 05:57:28
nit: s/newFlag/new_flag/
Shu Chen
2014/03/04 06:43:38
Done.
| |
76 private: | |
Yuki
2014/03/04 05:57:28
nit: better to put an empty line just before priva
Shu Chen
2014/03/04 06:43:38
Done.
| |
77 base::AutoReset<bool> auto_reset_; | |
78 }; | |
79 | |
56 } // namespace extension_ime_util | 80 } // namespace extension_ime_util |
57 | 81 |
58 } // namespace chromeos | 82 } // namespace chromeos |
59 | 83 |
60 #endif // CHROMEOS_IME_EXTENSION_IME_UTIL_H_ | 84 #endif // CHROMEOS_IME_EXTENSION_IME_UTIL_H_ |
OLD | NEW |