OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_DESCRIPTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_DESCRIPTOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_DESCRIPTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_DESCRIPTOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 namespace input_method { | 15 namespace input_method { |
16 | 16 |
17 class InputMethodWhitelist; | 17 class InputMethodWhitelist; |
18 | 18 |
19 // A structure which represents an input method. | 19 // A structure which represents an input method. |
20 class InputMethodDescriptor { | 20 class InputMethodDescriptor { |
21 public: | 21 public: |
22 InputMethodDescriptor(); | 22 InputMethodDescriptor(); |
23 InputMethodDescriptor(const InputMethodWhitelist& whitelist, | 23 InputMethodDescriptor(const std::string& id, |
24 const std::string& in_id, | 24 const std::string& name, |
25 const std::string& in_name, | 25 const std::string& keyboard_layout, |
26 const std::string& in_raw_layout, | 26 const std::string& language_code); |
27 const std::string& in_language_code); | |
28 ~InputMethodDescriptor(); | 27 ~InputMethodDescriptor(); |
29 | 28 |
30 bool operator==(const InputMethodDescriptor& other) const; | 29 bool operator==(const InputMethodDescriptor& other) const; |
31 bool operator!=(const InputMethodDescriptor& other) const; | 30 bool operator!=(const InputMethodDescriptor& other) const; |
32 | 31 |
33 // Debug print function. | 32 // Debug print function. |
34 std::string ToString() const; | 33 std::string ToString() const; |
35 | 34 |
36 const std::string& id() const { return id_; } | 35 const std::string& id() const { return id_; } |
37 const std::string& name() const { return name_; } | 36 const std::string& name() const { return name_; } |
38 const std::string& keyboard_layout() const { return keyboard_layout_; } | 37 const std::string& keyboard_layout() const { return keyboard_layout_; } |
39 const std::vector<std::string>& virtual_keyboard_layouts() const { | |
40 return virtual_keyboard_layouts_; | |
41 } | |
42 const std::string& language_code() const { return language_code_; } | 38 const std::string& language_code() const { return language_code_; } |
43 | 39 |
44 // Returns the fallback input method descriptor (the very basic US | 40 // Returns the fallback input method descriptor (the very basic US |
45 // keyboard). This function is mostly used for testing, but may be used | 41 // keyboard). This function is mostly used for testing, but may be used |
46 // as the fallback, when there is no other choice. | 42 // as the fallback, when there is no other choice. |
47 static InputMethodDescriptor GetFallbackInputMethodDescriptor(); | 43 static InputMethodDescriptor GetFallbackInputMethodDescriptor(); |
48 | 44 |
49 private: | 45 private: |
50 // For GetFallbackInputMethodDescriptor(). Use the public constructor instead. | |
51 InputMethodDescriptor(const std::string& in_id, | |
52 const std::string& in_name, | |
53 const std::string& in_keyboard_layout, | |
54 const std::string& in_virtual_keyboard_layouts, | |
55 const std::string& in_language_code); | |
56 | |
57 // An ID that identifies an input method engine (e.g., "t:latn-post", | 46 // An ID that identifies an input method engine (e.g., "t:latn-post", |
58 // "pinyin", "hangul"). | 47 // "pinyin", "hangul"). |
59 std::string id_; | 48 std::string id_; |
60 // A name used to specify the user-visible name of this input method. It is | 49 // A name used to specify the user-visible name of this input method. It is |
61 // only used by extension IMEs, and should be blank for internal IMEs. | 50 // only used by extension IMEs, and should be blank for internal IMEs. |
62 std::string name_; | 51 std::string name_; |
63 // A preferred physical keyboard layout for the input method (e.g., "us", | 52 // A preferred physical keyboard layout for the input method (e.g., "us", |
64 // "us(dvorak)", "jp"). Comma separated layout names do NOT appear. | 53 // "us(dvorak)", "jp"). Comma separated layout names do NOT appear. |
65 std::string keyboard_layout_; | 54 std::string keyboard_layout_; |
66 // Preferred virtual keyboard layouts for the input method. Comma separated | |
67 // layout names in order of priority, such as "handwriting,us", could appear. | |
68 std::vector<std::string> virtual_keyboard_layouts_; | |
69 // Language code like "ko", "ja", "en-US", and "zh-CN". | 55 // Language code like "ko", "ja", "en-US", and "zh-CN". |
70 std::string language_code_; | 56 std::string language_code_; |
71 }; | 57 }; |
72 | 58 |
73 typedef std::vector<InputMethodDescriptor> InputMethodDescriptors; | 59 typedef std::vector<InputMethodDescriptor> InputMethodDescriptors; |
74 | 60 |
75 } // namespace input_method | 61 } // namespace input_method |
76 } // namespace chromeos | 62 } // namespace chromeos |
77 | 63 |
78 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_DESCRIPTOR_H_ | 64 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_DESCRIPTOR_H_ |
OLD | NEW |