Adding wrapper class WKBackForwardListItemHolder
[chromium-blink-merge.git] / ui / base / ime / input_method_win.h
blobe1ebb244a2820331c9507e32760a3d2fdd91de98
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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_IME_INPUT_METHOD_WIN_H_
6 #define UI_BASE_IME_INPUT_METHOD_WIN_H_
8 #include <windows.h>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "ui/base/ime/input_method_base.h"
15 #include "ui/base/ime/win/imm32_manager.h"
17 namespace ui {
19 // A common InputMethod implementation based on IMM32.
20 class UI_BASE_IME_EXPORT InputMethodWin : public InputMethodBase {
21 public:
22 InputMethodWin(internal::InputMethodDelegate* delegate,
23 HWND toplevel_window_handle);
25 // Overridden from InputMethod:
26 void OnFocus() override;
27 void OnBlur() override;
28 bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
29 NativeEventResult* result) override;
30 bool DispatchKeyEvent(const ui::KeyEvent& event) override;
31 void OnTextInputTypeChanged(const TextInputClient* client) override;
32 void OnCaretBoundsChanged(const TextInputClient* client) override;
33 void CancelComposition(const TextInputClient* client) override;
34 void OnInputLocaleChanged() override;
35 std::string GetInputLocale() override;
36 bool IsCandidatePopupOpen() const override;
38 protected:
39 // Overridden from InputMethodBase:
40 // If a derived class overrides this method, it should call parent's
41 // implementation.
42 void OnWillChangeFocusedClient(TextInputClient* focused_before,
43 TextInputClient* focused) override;
44 void OnDidChangeFocusedClient(TextInputClient* focused_before,
45 TextInputClient* focused) override;
47 private:
48 // For both WM_CHAR and WM_SYSCHAR
49 LRESULT OnChar(HWND window_handle,
50 UINT message,
51 WPARAM wparam,
52 LPARAM lparam,
53 BOOL* handled);
55 LRESULT OnImeSetContext(HWND window_handle,
56 UINT message,
57 WPARAM wparam,
58 LPARAM lparam,
59 BOOL* handled);
60 LRESULT OnImeStartComposition(HWND window_handle,
61 UINT message,
62 WPARAM wparam,
63 LPARAM lparam,
64 BOOL* handled);
65 LRESULT OnImeComposition(HWND window_handle,
66 UINT message,
67 WPARAM wparam,
68 LPARAM lparam,
69 BOOL* handled);
70 LRESULT OnImeEndComposition(HWND window_handle,
71 UINT message,
72 WPARAM wparam,
73 LPARAM lparam,
74 BOOL* handled);
75 LRESULT OnImeNotify(UINT message,
76 WPARAM wparam,
77 LPARAM lparam,
78 BOOL* handled);
80 // Some IMEs rely on WM_IME_REQUEST message even when TSF is enabled. So
81 // OnImeRequest (and its actual implementations as OnDocumentFeed,
82 // OnReconvertString, and OnQueryCharPosition) are placed in this base class.
83 LRESULT OnImeRequest(UINT message,
84 WPARAM wparam,
85 LPARAM lparam,
86 BOOL* handled);
87 LRESULT OnDocumentFeed(RECONVERTSTRING* reconv);
88 LRESULT OnReconvertString(RECONVERTSTRING* reconv);
89 LRESULT OnQueryCharPosition(IMECHARPOSITION* char_positon);
91 // Returns true if the Win32 native window bound to |client| is considered
92 // to be ready for receiving keyboard input.
93 bool IsWindowFocused(const TextInputClient* client) const;
95 bool DispatchFabricatedKeyEvent(const ui::KeyEvent& event);
97 // Asks the client to confirm current composition text.
98 void ConfirmCompositionText();
100 // Enables or disables the IME according to the current text input type.
101 void UpdateIMEState();
103 // Windows IMM32 wrapper.
104 // (See "ui/base/ime/win/ime_input.h" for its details.)
105 ui::IMM32Manager imm32_manager_;
107 // The toplevel window handle.
108 // On non-Aura environment, this value is not used and always NULL.
109 const HWND toplevel_window_handle_;
111 // Name of the current input locale.
112 std::string locale_;
114 // The new text direction and layout alignment requested by the user by
115 // pressing ctrl-shift. It'll be sent to the text input client when the key
116 // is released.
117 base::i18n::TextDirection pending_requested_direction_;
119 // Represents if WM_CHAR[wparam=='\r'] should be dispatched to the focused
120 // text input client or ignored silently. This flag is introduced as a quick
121 // workaround against crbug.com/319100
122 // TODO(yukawa, IME): Figure out long-term solution.
123 bool accept_carriage_return_;
125 // True when an IME should be allowed to process key events.
126 bool enabled_;
128 // True if we know for sure that a candidate window is open.
129 bool is_candidate_popup_open_;
131 // Window handle where composition is on-going. NULL when there is no
132 // composition.
133 HWND composing_window_handle_;
135 // Set to true to suppress the next WM_CHAR, when the WM_KEYDOWN gets stopped
136 // propagation (e.g. triggered an accelerator).
137 bool suppress_next_char_;
139 DISALLOW_COPY_AND_ASSIGN(InputMethodWin);
142 } // namespace ui
144 #endif // UI_BASE_IME_INPUT_METHOD_WIN_H_