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 CHROMEOS_IME_INPUT_METHOD_MANAGER_H_ | 5 #ifndef CHROMEOS_IME_INPUT_METHOD_MANAGER_H_ |
6 #define CHROMEOS_IME_INPUT_METHOD_MANAGER_H_ | 6 #define CHROMEOS_IME_INPUT_METHOD_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
14 #include "chromeos/ime/input_method_descriptor.h" | 15 #include "chromeos/ime/input_method_descriptor.h" |
15 | 16 |
16 class Profile; | 17 class Profile; |
17 | 18 |
18 namespace ui { | 19 namespace ui { |
19 class Accelerator; | 20 class Accelerator; |
20 } // namespace ui | 21 } // namespace ui |
21 | 22 |
22 namespace chromeos { | 23 namespace chromeos { |
23 class ComponentExtensionIMEManager; | 24 class ComponentExtensionIMEManager; |
24 class InputMethodEngineInterface; | 25 class InputMethodEngineInterface; |
25 namespace input_method { | 26 namespace input_method { |
26 class InputMethodUtil; | 27 class InputMethodUtil; |
27 class ImeKeyboard; | 28 class ImeKeyboard; |
28 | 29 |
29 // This class manages input methodshandles. Classes can add themselves as | 30 // This class manages input methodshandles. Classes can add themselves as |
30 // observers. Clients can get an instance of this library class by: | 31 // observers. Clients can get an instance of this library class by: |
31 // InputMethodManager::Get(). | 32 // InputMethodManager::Get(). |
32 class CHROMEOS_EXPORT InputMethodManager { | 33 class CHROMEOS_EXPORT InputMethodManager { |
33 public: | 34 public: |
34 enum State { | 35 enum UISessionState { |
35 STATE_LOGIN_SCREEN = 0, | 36 STATE_LOGIN_SCREEN = 0, |
36 STATE_BROWSER_SCREEN, | 37 STATE_BROWSER_SCREEN, |
37 STATE_LOCK_SCREEN, | 38 STATE_LOCK_SCREEN, |
38 STATE_TERMINATING, | 39 STATE_TERMINATING, |
39 }; | 40 }; |
40 | 41 |
41 class Observer { | 42 class Observer { |
42 public: | 43 public: |
43 virtual ~Observer() {} | 44 virtual ~Observer() {} |
44 // Called when the current input method is changed. |show_message| | 45 // Called when the current input method is changed. |show_message| |
45 // indicates whether the user should be notified of this change. | 46 // indicates whether the user should be notified of this change. |
46 virtual void InputMethodChanged(InputMethodManager* manager, | 47 virtual void InputMethodChanged(InputMethodManager* manager, |
47 bool show_message) = 0; | 48 bool show_message) = 0; |
48 }; | 49 }; |
49 | 50 |
50 // CandidateWindowObserver is notified of events related to the candidate | 51 // CandidateWindowObserver is notified of events related to the candidate |
51 // window. The "suggestion window" used by IMEs such as ibus-mozc does not | 52 // window. The "suggestion window" used by IMEs such as ibus-mozc does not |
52 // count as the candidate window (this may change if we later want suggestion | 53 // count as the candidate window (this may change if we later want suggestion |
53 // window events as well). These events also won't occur when the virtual | 54 // window events as well). These events also won't occur when the virtual |
54 // keyboard is used, since it controls its own candidate window. | 55 // keyboard is used, since it controls its own candidate window. |
55 class CandidateWindowObserver { | 56 class CandidateWindowObserver { |
56 public: | 57 public: |
57 virtual ~CandidateWindowObserver() {} | 58 virtual ~CandidateWindowObserver() {} |
58 // Called when the candidate window is opened. | 59 // Called when the candidate window is opened. |
59 virtual void CandidateWindowOpened(InputMethodManager* manager) = 0; | 60 virtual void CandidateWindowOpened(InputMethodManager* manager) = 0; |
60 // Called when the candidate window is closed. | 61 // Called when the candidate window is closed. |
61 virtual void CandidateWindowClosed(InputMethodManager* manager) = 0; | 62 virtual void CandidateWindowClosed(InputMethodManager* manager) = 0; |
62 }; | 63 }; |
63 | 64 |
| 65 class State : public base::RefCounted<InputMethodManager::State> { |
| 66 protected: |
| 67 friend base::RefCounted<InputMethodManager::State>; |
| 68 |
| 69 virtual ~State(); |
| 70 }; |
| 71 |
64 virtual ~InputMethodManager() {} | 72 virtual ~InputMethodManager() {} |
65 | 73 |
66 // Gets the global instance of InputMethodManager. Initialize() must be called | 74 // Gets the global instance of InputMethodManager. Initialize() must be called |
67 // first. | 75 // first. |
68 static CHROMEOS_EXPORT InputMethodManager* Get(); | 76 static CHROMEOS_EXPORT InputMethodManager* Get(); |
69 | 77 |
70 // Sets the global instance. |instance| will be owned by the internal pointer | 78 // Sets the global instance. |instance| will be owned by the internal pointer |
71 // and deleted by Shutdown(). | 79 // and deleted by Shutdown(). |
72 // TODO(nona): Instanciate InputMethodManagerImpl inside of this function once | 80 // TODO(nona): Instanciate InputMethodManagerImpl inside of this function once |
73 // crbug.com/164375 is fixed. | 81 // crbug.com/164375 is fixed. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Switches to an input method (or keyboard layout) which is associated with | 200 // Switches to an input method (or keyboard layout) which is associated with |
193 // the |accelerator|. | 201 // the |accelerator|. |
194 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) = 0; | 202 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) = 0; |
195 | 203 |
196 // If keyboard layout can be uset at login screen | 204 // If keyboard layout can be uset at login screen |
197 virtual bool IsLoginKeyboard(const std::string& layout) const = 0; | 205 virtual bool IsLoginKeyboard(const std::string& layout) const = 0; |
198 | 206 |
199 // Migrates the input method id to extension-based input method id. | 207 // Migrates the input method id to extension-based input method id. |
200 virtual bool MigrateInputMethods( | 208 virtual bool MigrateInputMethods( |
201 std::vector<std::string>* input_method_ids) = 0; | 209 std::vector<std::string>* input_method_ids) = 0; |
| 210 |
| 211 virtual scoped_refptr<State> CreateNewState( |
| 212 const std::string& debug_name) const = 0; |
| 213 |
| 214 virtual void SetState(scoped_refptr<State> state) = 0; |
202 }; | 215 }; |
203 | 216 |
204 } // namespace input_method | 217 } // namespace input_method |
205 } // namespace chromeos | 218 } // namespace chromeos |
206 | 219 |
207 #endif // CHROMEOS_IME_INPUT_METHOD_MANAGER_H_ | 220 #endif // CHROMEOS_IME_INPUT_METHOD_MANAGER_H_ |
OLD | NEW |