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 void Init(bool focused
) override
;
29 bool OnUntranslatedIMEMessage(const base::NativeEvent
& event
,
30 NativeEventResult
* result
) override
;
31 bool DispatchKeyEvent(const ui::KeyEvent
& event
) override
;
32 void OnTextInputTypeChanged(const TextInputClient
* client
) override
;
33 void OnCaretBoundsChanged(const TextInputClient
* client
) override
;
34 void CancelComposition(const TextInputClient
* client
) override
;
35 void OnInputLocaleChanged() override
;
36 std::string
GetInputLocale() override
;
37 bool IsActive() override
;
38 bool IsCandidatePopupOpen() const override
;
39 void OnFocus() override
;
40 void OnBlur() override
;
42 // Overriden from ui::LinuxInputMethodContextDelegate
43 void OnCommit(const base::string16
& text
) override
;
44 void OnPreeditChanged(const CompositionText
& composition_text
) override
;
45 void OnPreeditEnd() override
;
46 void OnPreeditStart() override
{};
49 // Overridden from InputMethodBase.
50 void OnWillChangeFocusedClient(TextInputClient
* focused_before
,
51 TextInputClient
* focused
) override
;
52 void OnDidChangeFocusedClient(TextInputClient
* focused_before
,
53 TextInputClient
* focused
) override
;
56 bool HasInputMethodResult();
57 bool NeedInsertChar() const;
58 void SendFakeProcessKeyEvent(int flags
) const;
59 void ConfirmCompositionText();
60 void UpdateContextFocusState();
63 scoped_ptr
<LinuxInputMethodContext
> context_
;
64 scoped_ptr
<LinuxInputMethodContext
> context_simple_
;
66 base::string16 result_text_
;
68 ui::CompositionText composition_
;
70 // The current text input type used to indicates if |context_| and
71 // |context_simple_| are focused or not.
72 TextInputType text_input_type_
;
74 // Indicates if currently in sync mode when handling a key event.
75 // This is used in OnXXX callbacks from GTK IM module.
78 // Indicates if the composition text is changed or deleted.
79 bool composition_changed_
;
81 // If it's true then all input method result received before the next key
82 // event will be discarded.
83 bool suppress_next_result_
;
85 DISALLOW_COPY_AND_ASSIGN(InputMethodAuraLinux
);
90 #endif // UI_BASE_IME_INPUT_METHOD_AURALINUX_H_