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 UI_BASE_IME_CHROMEOS_EXTENSION_IME_UTIL_H_ |
6 #define CHROMEOS_IME_EXTENSION_IME_UTIL_H_ | 6 #define UI_BASE_IME_CHROMEOS_EXTENSION_IME_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "chromeos/chromeos_export.h" | 11 #include "ui/base/ui_base_export.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 | 14 |
15 // Extension IME related utilities. | 15 // Extension IME related utilities. |
16 namespace extension_ime_util { | 16 namespace extension_ime_util { |
17 | 17 |
18 #if defined(GOOGLE_CHROME_BUILD) | 18 #if defined(GOOGLE_CHROME_BUILD) |
19 const char kXkbExtensionId[] = "jkghodnilhceideoidjikpgommlajknk"; | 19 const char kXkbExtensionId[] = "jkghodnilhceideoidjikpgommlajknk"; |
20 const char kM17nExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 20 const char kM17nExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
21 const char kHangulExtensionId[] = "bdgdidmhaijohebebipajioienkglgfo"; | 21 const char kHangulExtensionId[] = "bdgdidmhaijohebebipajioienkglgfo"; |
22 const char kMozcExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 22 const char kMozcExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
23 const char kT13nExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 23 const char kT13nExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
24 const char kChinesePinyinExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 24 const char kChinesePinyinExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
25 const char kChineseZhuyinExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 25 const char kChineseZhuyinExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
26 const char kChineseCangjieExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 26 const char kChineseCangjieExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
27 #else | 27 #else |
28 const char kXkbExtensionId[] = "fgoepimhcoialccpbmpnnblemnepkkao"; | 28 const char kXkbExtensionId[] = "fgoepimhcoialccpbmpnnblemnepkkao"; |
29 const char kM17nExtensionId[] = "jhffeifommiaekmbkkjlpmilogcfdohp"; | 29 const char kM17nExtensionId[] = "jhffeifommiaekmbkkjlpmilogcfdohp"; |
30 const char kHangulExtensionId[] = "bdgdidmhaijohebebipajioienkglgfo"; | 30 const char kHangulExtensionId[] = "bdgdidmhaijohebebipajioienkglgfo"; |
31 const char kMozcExtensionId[] = "bbaiamgfapehflhememkfglaehiobjnk"; | 31 const char kMozcExtensionId[] = "bbaiamgfapehflhememkfglaehiobjnk"; |
32 const char kT13nExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; | 32 const char kT13nExtensionId[] = "gjaehgfemfahhmlgpdfknkhdnemmolop"; |
33 const char kChinesePinyinExtensionId[] = "cpgalbafkoofkjmaeonnfijgpfennjjn"; | 33 const char kChinesePinyinExtensionId[] = "cpgalbafkoofkjmaeonnfijgpfennjjn"; |
34 const char kChineseZhuyinExtensionId[] = "ekbifjdfhkmdeeajnolmgdlmkllopefi"; | 34 const char kChineseZhuyinExtensionId[] = "ekbifjdfhkmdeeajnolmgdlmkllopefi"; |
35 const char kChineseCangjieExtensionId[] = "aeebooiibjahgpgmhkeocbeekccfknbj"; | 35 const char kChineseCangjieExtensionId[] = "aeebooiibjahgpgmhkeocbeekccfknbj"; |
36 #endif | 36 #endif |
37 | 37 |
38 // Returns InputMethodID for |engine_id| in |extension_id| of extension IME. | 38 // Returns InputMethodID for |engine_id| in |extension_id| of extension IME. |
39 // This function does not check |extension_id| is installed extension IME nor | 39 // This function does not check |extension_id| is installed extension IME nor |
40 // |engine_id| is really a member of |extension_id|. | 40 // |engine_id| is really a member of |extension_id|. |
41 std::string CHROMEOS_EXPORT GetInputMethodID(const std::string& extension_id, | 41 std::string UI_BASE_EXPORT GetInputMethodID(const std::string& extension_id, |
42 const std::string& engine_id); | 42 const std::string& engine_id); |
43 | 43 |
44 // Returns InputMethodID for |engine_id| in |extension_id| of component | 44 // Returns InputMethodID for |engine_id| in |extension_id| of component |
45 // extension IME, This function does not check |extension_id| is component one | 45 // extension IME, This function does not check |extension_id| is component one |
46 // nor |engine_id| is really a member of |extension_id|. | 46 // nor |engine_id| is really a member of |extension_id|. |
47 std::string CHROMEOS_EXPORT GetComponentInputMethodID( | 47 std::string UI_BASE_EXPORT GetComponentInputMethodID( |
48 const std::string& extension_id, | 48 const std::string& extension_id, |
49 const std::string& engine_id); | 49 const std::string& engine_id); |
50 | 50 |
51 // Returns extension ID if |input_method_id| is extension IME ID or component | 51 // Returns extension ID if |input_method_id| is extension IME ID or component |
52 // extension IME ID. Otherwise returns an empty string (""). | 52 // extension IME ID. Otherwise returns an empty string (""). |
53 std::string CHROMEOS_EXPORT GetExtensionIDFromInputMethodID( | 53 std::string UI_BASE_EXPORT GetExtensionIDFromInputMethodID( |
54 const std::string& input_method_id); | 54 const std::string& input_method_id); |
55 | 55 |
56 // Returns InputMethodID from engine id (e.g. xkb:fr:fra), or returns itself if | 56 // Returns InputMethodID from engine id (e.g. xkb:fr:fra), or returns itself if |
57 // the |engine_id| is not a known engine id. | 57 // the |engine_id| is not a known engine id. |
58 // The caller must make sure the |engine_id| is from system input methods | 58 // The caller must make sure the |engine_id| is from system input methods |
59 // instead of 3rd party input methods. | 59 // instead of 3rd party input methods. |
60 std::string CHROMEOS_EXPORT GetInputMethodIDByEngineID( | 60 std::string UI_BASE_EXPORT GetInputMethodIDByEngineID( |
61 const std::string& engine_id); | 61 const std::string& engine_id); |
62 | 62 |
63 // Returns true if |input_method_id| is extension IME ID. This function does not | 63 // Returns true if |input_method_id| is extension IME ID. This function does not |
64 // check |input_method_id| is installed extension IME. | 64 // check |input_method_id| is installed extension IME. |
65 bool CHROMEOS_EXPORT IsExtensionIME(const std::string& input_method_id); | 65 bool UI_BASE_EXPORT IsExtensionIME(const std::string& input_method_id); |
66 | 66 |
67 // Returns true if |input_method_id| is component extension IME ID. This | 67 // Returns true if |input_method_id| is component extension IME ID. This |
68 // function does not check |input_method_id| is really whitelisted one or not. | 68 // function does not check |input_method_id| is really whitelisted one or not. |
69 // If you want to check |input_method_id| is whitelisted component extension | 69 // If you want to check |input_method_id| is whitelisted component extension |
70 // IME, please use ComponentExtensionIMEManager::IsWhitelisted instead. | 70 // IME, please use ComponentExtensionIMEManager::IsWhitelisted instead. |
71 bool CHROMEOS_EXPORT IsComponentExtensionIME( | 71 bool UI_BASE_EXPORT IsComponentExtensionIME( |
72 const std::string& input_method_id); | 72 const std::string& input_method_id); |
73 | 73 |
74 // Returns true if the |input_method| is a member of |extension_id| of extension | 74 // Returns true if the |input_method| is a member of |extension_id| of extension |
75 // IME, otherwise returns false. | 75 // IME, otherwise returns false. |
76 bool CHROMEOS_EXPORT IsMemberOfExtension(const std::string& input_method_id, | 76 bool UI_BASE_EXPORT IsMemberOfExtension(const std::string& input_method_id, |
77 const std::string& extension_id); | 77 const std::string& extension_id); |
78 | 78 |
79 // Returns true if the |input_method_id| is the extension based xkb keyboard, | 79 // Returns true if the |input_method_id| is the extension based xkb keyboard, |
80 // otherwise returns false. | 80 // otherwise returns false. |
81 bool CHROMEOS_EXPORT IsKeyboardLayoutExtension( | 81 bool UI_BASE_EXPORT IsKeyboardLayoutExtension( |
82 const std::string& input_method_id); | 82 const std::string& input_method_id); |
83 | 83 |
84 // Returns input method component id from the extension-based InputMethodID | 84 // Returns input method component id from the extension-based InputMethodID |
85 // for component IME extensions. This function does not check that | 85 // for component IME extensions. This function does not check that |
86 // |input_method_id| is installed. | 86 // |input_method_id| is installed. |
87 std::string CHROMEOS_EXPORT | 87 std::string UI_BASE_EXPORT |
88 GetComponentIDByInputMethodID(const std::string& input_method_id); | 88 GetComponentIDByInputMethodID(const std::string& input_method_id); |
89 | 89 |
90 // Gets legacy xkb id (e.g. xkb:us::eng) from the new extension based xkb id | 90 // Gets legacy xkb id (e.g. xkb:us::eng) from the new extension based xkb id |
91 // (e.g. _comp_ime_...xkb:us::eng). If the given id is not prefixed with | 91 // (e.g. _comp_ime_...xkb:us::eng). If the given id is not prefixed with |
92 // 'xkb:', just return the same as the given id. | 92 // 'xkb:', just return the same as the given id. |
93 std::string CHROMEOS_EXPORT MaybeGetLegacyXkbId( | 93 std::string UI_BASE_EXPORT MaybeGetLegacyXkbId( |
94 const std::string& input_method_id); | 94 const std::string& input_method_id); |
95 | 95 |
96 } // namespace extension_ime_util | 96 } // namespace extension_ime_util |
97 | 97 |
98 } // namespace chromeos | 98 } // namespace chromeos |
99 | 99 |
100 #endif // CHROMEOS_IME_EXTENSION_IME_UTIL_H_ | 100 #endif // UI_BASE_IME_CHROMEOS_EXTENSION_IME_UTIL_H_ |
OLD | NEW |