OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CROS_INPUT_METHOD_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_INPUT_METHOD_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_INPUT_METHOD_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_INPUT_METHOD_LIBRARY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 #include "base/timer.h" | 15 #include "base/timer.h" |
15 #include "third_party/cros/chromeos_input_method.h" | 16 #include "third_party/cros/chromeos_input_method.h" |
16 | 17 |
| 18 class GURL; |
| 19 |
17 namespace chromeos { | 20 namespace chromeos { |
18 | 21 |
| 22 namespace input_method { |
| 23 class VirtualKeyboard; |
| 24 } // namespace input_method |
| 25 |
19 // This class handles the interaction with the ChromeOS language library APIs. | 26 // This class handles the interaction with the ChromeOS language library APIs. |
20 // Classes can add themselves as observers. Users can get an instance of this | 27 // Classes can add themselves as observers. Users can get an instance of this |
21 // library class like this: | 28 // library class like this: |
22 // chromeos::CrosLibrary::Get()->GetInputMethodLibrary() | 29 // chromeos::CrosLibrary::Get()->GetInputMethodLibrary() |
23 class InputMethodLibrary { | 30 class InputMethodLibrary { |
24 public: | 31 public: |
25 class Observer { | 32 class Observer { |
26 public: | 33 public: |
27 virtual ~Observer() = 0; | 34 virtual ~Observer() = 0; |
28 // Called when the current input method is changed. | 35 // Called when the current input method is changed. |
(...skipping 15 matching lines...) Expand all Loading... |
44 const InputMethodDescriptor& current_input_method) = 0; | 51 const InputMethodDescriptor& current_input_method) = 0; |
45 | 52 |
46 // Called when the list of properties is changed. | 53 // Called when the list of properties is changed. |
47 virtual void PropertyListChanged( | 54 virtual void PropertyListChanged( |
48 InputMethodLibrary* obj, | 55 InputMethodLibrary* obj, |
49 const ImePropertyList& current_ime_properties) = 0; | 56 const ImePropertyList& current_ime_properties) = 0; |
50 | 57 |
51 // Called by AddObserver() when the first observer is added. | 58 // Called by AddObserver() when the first observer is added. |
52 virtual void FirstObserverIsAdded(InputMethodLibrary* obj) = 0; | 59 virtual void FirstObserverIsAdded(InputMethodLibrary* obj) = 0; |
53 }; | 60 }; |
| 61 |
| 62 class VirtualKeyboardObserver { |
| 63 public: |
| 64 virtual ~VirtualKeyboardObserver() = 0; |
| 65 // Called when the current virtual keyboard is changed. |
| 66 virtual void VirtualKeyboardChanged( |
| 67 InputMethodLibrary* obj, |
| 68 const input_method::VirtualKeyboard& virtual_keyboard, |
| 69 const std::string& virtual_keyboard_layout) = 0; |
| 70 }; |
| 71 |
54 virtual ~InputMethodLibrary() {} | 72 virtual ~InputMethodLibrary() {} |
55 | 73 |
56 // Adds an observer to receive notifications of input method related | 74 // Adds an observer to receive notifications of input method related |
57 // changes as desribed in the Observer class above. | 75 // changes as desribed in the Observer class above. |
58 virtual void AddObserver(Observer* observer) = 0; | 76 virtual void AddObserver(Observer* observer) = 0; |
| 77 virtual void AddVirtualKeyboardObserver( |
| 78 VirtualKeyboardObserver* observer) = 0; |
59 virtual void RemoveObserver(Observer* observer) = 0; | 79 virtual void RemoveObserver(Observer* observer) = 0; |
| 80 virtual void RemoveVirtualKeyboardObserver( |
| 81 VirtualKeyboardObserver* observer) = 0; |
60 | 82 |
61 // Returns the list of input methods we can select (i.e. active). If the cros | 83 // Returns the list of input methods we can select (i.e. active). If the cros |
62 // library is not found or IBus/DBus daemon is not alive, this function | 84 // library is not found or IBus/DBus daemon is not alive, this function |
63 // returns a fallback input method list (and never returns NULL). | 85 // returns a fallback input method list (and never returns NULL). |
64 virtual InputMethodDescriptors* GetActiveInputMethods() = 0; | 86 virtual InputMethodDescriptors* GetActiveInputMethods() = 0; |
65 | 87 |
66 // Returns the number of active input methods. | 88 // Returns the number of active input methods. |
67 virtual size_t GetNumActiveInputMethods() = 0; | 89 virtual size_t GetNumActiveInputMethods() = 0; |
68 | 90 |
69 // Returns the list of input methods we support, including ones not active. | 91 // Returns the list of input methods we support, including ones not active. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 virtual void SetEnableAutoImeShutdown(bool enable) = 0; | 144 virtual void SetEnableAutoImeShutdown(bool enable) = 0; |
123 | 145 |
124 // Sends a handwriting stroke to libcros. See chromeos::SendHandwritingStroke | 146 // Sends a handwriting stroke to libcros. See chromeos::SendHandwritingStroke |
125 // for details. | 147 // for details. |
126 virtual void SendHandwritingStroke(const HandwritingStroke& stroke) = 0; | 148 virtual void SendHandwritingStroke(const HandwritingStroke& stroke) = 0; |
127 | 149 |
128 // Clears last N handwriting strokes in libcros. See | 150 // Clears last N handwriting strokes in libcros. See |
129 // chromeos::CancelHandwriting for details. | 151 // chromeos::CancelHandwriting for details. |
130 virtual void CancelHandwritingStrokes(int stroke_count) = 0; | 152 virtual void CancelHandwritingStrokes(int stroke_count) = 0; |
131 | 153 |
| 154 // Registers a new virtual keyboard for |layouts|. Set |is_system| true when |
| 155 // the keyboard is provided as a content extension. System virtual keyboards |
| 156 // have lower priority than non-system ones. See virtual_keyboard_selector.h |
| 157 // for details. |
| 158 // TODO(yusukes): Add UnregisterVirtualKeyboard function as well. |
| 159 virtual void RegisterVirtualKeyboard(const GURL& launch_url, |
| 160 const std::set<std::string>& layouts, |
| 161 bool is_system) = 0; |
| 162 |
132 virtual InputMethodDescriptor previous_input_method() const = 0; | 163 virtual InputMethodDescriptor previous_input_method() const = 0; |
133 virtual InputMethodDescriptor current_input_method() const = 0; | 164 virtual InputMethodDescriptor current_input_method() const = 0; |
134 | 165 |
135 virtual const ImePropertyList& current_ime_properties() const = 0; | 166 virtual const ImePropertyList& current_ime_properties() const = 0; |
136 | 167 |
137 // Factory function, creates a new instance and returns ownership. | 168 // Factory function, creates a new instance and returns ownership. |
138 // For normal usage, access the singleton via CrosLibrary::Get(). | 169 // For normal usage, access the singleton via CrosLibrary::Get(). |
139 static InputMethodLibrary* GetImpl(bool stub); | 170 static InputMethodLibrary* GetImpl(bool stub); |
140 }; | 171 }; |
141 | 172 |
142 } // namespace chromeos | 173 } // namespace chromeos |
143 | 174 |
144 #endif // CHROME_BROWSER_CHROMEOS_CROS_INPUT_METHOD_LIBRARY_H_ | 175 #endif // CHROME_BROWSER_CHROMEOS_CROS_INPUT_METHOD_LIBRARY_H_ |
OLD | NEW |