Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / ime / input_method_auralinux.h
blob05a80d7798bc445e0a37eda7286a723e055e5b9f
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"
13 namespace ui {
15 // A ui::InputMethod implementation for Aura on Linux platforms. The
16 // implementation details are separated to ui::LinuxInputMethodContext
17 // interface.
18 class UI_BASE_IME_EXPORT InputMethodAuraLinux
19 : public InputMethodBase,
20 public LinuxInputMethodContextDelegate {
21 public:
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 void DispatchKeyEvent(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;
37 void OnFocus() override;
38 void OnBlur() override;
40 // Overriden from ui::LinuxInputMethodContextDelegate
41 void OnCommit(const base::string16& text) override;
42 void OnPreeditChanged(const CompositionText& composition_text) override;
43 void OnPreeditEnd() override;
44 void OnPreeditStart() override{};
46 protected:
47 // Overridden from InputMethodBase.
48 void OnWillChangeFocusedClient(TextInputClient* focused_before,
49 TextInputClient* focused) override;
50 void OnDidChangeFocusedClient(TextInputClient* focused_before,
51 TextInputClient* focused) override;
53 private:
54 bool HasInputMethodResult();
55 bool NeedInsertChar() const;
56 ui::EventDispatchDetails SendFakeProcessKeyEvent(ui::KeyEvent* event) const;
57 void ConfirmCompositionText();
58 void UpdateContextFocusState();
59 void ResetContext();
61 scoped_ptr<LinuxInputMethodContext> context_;
62 scoped_ptr<LinuxInputMethodContext> context_simple_;
64 base::string16 result_text_;
66 ui::CompositionText composition_;
68 // The current text input type used to indicates if |context_| and
69 // |context_simple_| are focused or not.
70 TextInputType text_input_type_;
72 // Indicates if currently in sync mode when handling a key event.
73 // This is used in OnXXX callbacks from GTK IM module.
74 bool is_sync_mode_;
76 // Indicates if the composition text is changed or deleted.
77 bool composition_changed_;
79 // If it's true then all input method result received before the next key
80 // event will be discarded.
81 bool suppress_next_result_;
83 DISALLOW_COPY_AND_ASSIGN(InputMethodAuraLinux);
86 } // namespace ui
88 #endif // UI_BASE_IME_INPUT_METHOD_AURALINUX_H_