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 UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
6 #define UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/base/ime/composition_text.h"
10 #include "ui/base/ime/input_method_base.h"
11 #include "ui/base/ime/linux/linux_input_method_context.h"
15 // A ui::InputMethod implementation for Aura on Linux platforms. The
16 // implementation details are separated to ui::LinuxInputMethodContext
18 class UI_BASE_IME_EXPORT InputMethodAuraLinux
19 : public InputMethodBase
,
20 public LinuxInputMethodContextDelegate
{
22 explicit InputMethodAuraLinux(internal::InputMethodDelegate
* delegate
);
23 ~InputMethodAuraLinux() override
;
25 LinuxInputMethodContext
* GetContextForTesting(bool is_simple
);
27 // Overriden from InputMethod.
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 IsActive() override
;
37 bool IsCandidatePopupOpen() const override
;
38 void OnFocus() override
;
39 void OnBlur() override
;
41 // Overriden from ui::LinuxInputMethodContextDelegate
42 void OnCommit(const base::string16
& text
) override
;
43 void OnPreeditChanged(const CompositionText
& composition_text
) override
;
44 void OnPreeditEnd() override
;
45 void OnPreeditStart() override
{};
48 // Overridden from InputMethodBase.
49 void OnWillChangeFocusedClient(TextInputClient
* focused_before
,
50 TextInputClient
* focused
) override
;
51 void OnDidChangeFocusedClient(TextInputClient
* focused_before
,
52 TextInputClient
* focused
) override
;
55 bool HasInputMethodResult();
56 bool NeedInsertChar() const;
57 void SendFakeProcessKeyEvent(int flags
) const;
58 void ConfirmCompositionText();
59 void UpdateContextFocusState();
62 scoped_ptr
<LinuxInputMethodContext
> context_
;
63 scoped_ptr
<LinuxInputMethodContext
> context_simple_
;
65 base::string16 result_text_
;
67 ui::CompositionText composition_
;
69 // The current text input type used to indicates if |context_| and
70 // |context_simple_| are focused or not.
71 TextInputType text_input_type_
;
73 // Indicates if currently in sync mode when handling a key event.
74 // This is used in OnXXX callbacks from GTK IM module.
77 // Indicates if the composition text is changed or deleted.
78 bool composition_changed_
;
80 // If it's true then all input method result received before the next key
81 // event will be discarded.
82 bool suppress_next_result_
;
84 DISALLOW_COPY_AND_ASSIGN(InputMethodAuraLinux
);
89 #endif // UI_BASE_IME_INPUT_METHOD_AURALINUX_H_