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