Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / input_method_engine.h
blob328653dfc05d9111f325f498c411d1e297278f84
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
11 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
12 #include "chromeos/ime/input_method_descriptor.h"
13 #include "url/gurl.h"
15 namespace ui {
16 class CandidateWindow;
17 class KeyEvent;
18 } // namespace ui
20 namespace ash {
21 namespace ime {
22 struct InputMethodMenuItem;
23 } // namespace ime
24 } // namespace ash
26 namespace chromeos {
28 class CompositionText;
30 namespace input_method {
31 struct KeyEventHandle;
32 } // namespace input_method
34 class InputMethodEngine : public InputMethodEngineInterface {
35 public:
36 InputMethodEngine();
38 virtual ~InputMethodEngine();
40 void Initialize(scoped_ptr<InputMethodEngineInterface::Observer> observer,
41 const char* engine_name,
42 const char* extension_id,
43 const char* engine_id,
44 const std::vector<std::string>& languages,
45 const std::vector<std::string>& layouts,
46 const GURL& options_page,
47 const GURL& input_view);
49 // InputMethodEngineInterface overrides.
50 virtual const input_method::InputMethodDescriptor& GetDescriptor()
51 const OVERRIDE;
52 virtual void NotifyImeReady() OVERRIDE;
53 virtual bool SetComposition(int context_id,
54 const char* text,
55 int selection_start,
56 int selection_end,
57 int cursor,
58 const std::vector<SegmentInfo>& segments,
59 std::string* error) OVERRIDE;
60 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE;
61 virtual bool CommitText(int context_id, const char* text,
62 std::string* error) OVERRIDE;
63 virtual bool SendKeyEvents(int context_id,
64 const std::vector<KeyboardEvent>& events) OVERRIDE;
65 virtual const CandidateWindowProperty&
66 GetCandidateWindowProperty() const OVERRIDE;
67 virtual void SetCandidateWindowProperty(
68 const CandidateWindowProperty& property) OVERRIDE;
69 virtual bool SetCandidateWindowVisible(bool visible,
70 std::string* error) OVERRIDE;
71 virtual bool SetCandidates(int context_id,
72 const std::vector<Candidate>& candidates,
73 std::string* error) OVERRIDE;
74 virtual bool SetCursorPosition(int context_id, int candidate_id,
75 std::string* error) OVERRIDE;
76 virtual bool SetMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
77 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
78 virtual bool IsActive() const OVERRIDE;
79 virtual void KeyEventDone(input_method::KeyEventHandle* key_data,
80 bool handled) OVERRIDE;
81 virtual bool DeleteSurroundingText(int context_id,
82 int offset,
83 size_t number_of_chars,
84 std::string* error) OVERRIDE;
86 // IMEEngineHandlerInterface overrides.
87 virtual void FocusIn(
88 const IMEEngineHandlerInterface::InputContext& input_context) OVERRIDE;
89 virtual void FocusOut() OVERRIDE;
90 virtual void Enable() OVERRIDE;
91 virtual void Disable() OVERRIDE;
92 virtual void PropertyActivate(const std::string& property_name) OVERRIDE;
93 virtual void Reset() OVERRIDE;
94 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event,
95 const KeyEventDoneCallback& callback) OVERRIDE;
96 virtual void CandidateClicked(uint32 index) OVERRIDE;
97 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos,
98 uint32 anchor_pos) OVERRIDE;
99 virtual void HideInputView() OVERRIDE;
101 private:
102 // Converts MenuItem to InputMethodMenuItem.
103 void MenuItemToProperty(const MenuItem& item,
104 ash::ime::InputMethodMenuItem* property);
106 // Enables or disables overriding input view page to Virtual Keyboard window.
107 void EnableInputView(bool enabled);
109 // Descriptor of this input method.
110 input_method::InputMethodDescriptor descriptor_;
112 ui::TextInputType current_input_type_;
114 // True if this engine is active.
115 bool active_;
117 // ID that is used for the current input context. False if there is no focus.
118 int context_id_;
120 // Next id that will be assigned to a context.
121 int next_context_id_;
123 // This IME ID in Chrome Extension.
124 std::string engine_id_;
126 // This IME's Chrome Extension ID.
127 std::string extension_id_;
129 // This IME ID in InputMethodManager.
130 std::string imm_id_;
132 // The observer object recieving events for this IME.
133 scoped_ptr<InputMethodEngineInterface::Observer> observer_;
135 // The current preedit text, and it's cursor position.
136 scoped_ptr<CompositionText> composition_text_;
137 int composition_cursor_;
139 // The current candidate window.
140 scoped_ptr<ui::CandidateWindow> candidate_window_;
142 // The current candidate window property.
143 CandidateWindowProperty candidate_window_property_;
145 // Indicates whether the candidate window is visible.
146 bool window_visible_;
148 // Mapping of candidate index to candidate id.
149 std::vector<int> candidate_ids_;
151 // Mapping of candidate id to index.
152 std::map<int, int> candidate_indexes_;
154 // Used for input view window.
155 GURL input_view_url_;
157 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event
158 // sent to ProcessKeyEvent is sent by SendKeyEvents.
159 const ui::KeyEvent* sent_key_event_;
162 } // namespace chromeos
164 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_