Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: ui/base/ime/input_method_base.h

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/ime/input_method_auralinux.cc ('k') | ui/base/ime/input_method_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #ifndef UI_BASE_IME_INPUT_METHOD_BASE_H_
6 #define UI_BASE_IME_INPUT_METHOD_BASE_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h"
12 #include "ui/base/ime/input_method.h"
13 #include "ui/base/ui_base_export.h"
14
15 namespace gfx {
16 class Rect;
17 } // namespace gfx
18
19 namespace ui {
20
21 class InputMethodObserver;
22 class KeyEvent;
23 class TextInputClient;
24
25 // A helper class providing functionalities shared among ui::InputMethod
26 // implementations.
27 class UI_BASE_EXPORT InputMethodBase
28 : NON_EXPORTED_BASE(public InputMethod),
29 public base::SupportsWeakPtr<InputMethodBase> {
30 public:
31 InputMethodBase();
32 ~InputMethodBase() override;
33
34 // Overriden from InputMethod.
35 void SetDelegate(internal::InputMethodDelegate* delegate) override;
36 void Init(bool focused) override;
37 // If a derived class overrides OnFocus()/OnBlur(), it should call parent's
38 // implementation first, to make sure |system_toplevel_window_focused_| flag
39 // can be updated correctly.
40 void OnFocus() override;
41 void OnBlur() override;
42 void SetFocusedTextInputClient(TextInputClient* client) override;
43 void DetachTextInputClient(TextInputClient* client) override;
44 TextInputClient* GetTextInputClient() const override;
45
46 // If a derived class overrides this method, it should call parent's
47 // implementation.
48 void OnTextInputTypeChanged(const TextInputClient* client) override;
49
50 TextInputType GetTextInputType() const override;
51 TextInputMode GetTextInputMode() const override;
52 bool CanComposeInline() const override;
53 void ShowImeIfNeeded() override;
54
55 void AddObserver(InputMethodObserver* observer) override;
56 void RemoveObserver(InputMethodObserver* observer) override;
57
58 protected:
59 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before,
60 TextInputClient* focused) {}
61 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before,
62 TextInputClient* focused) {}
63
64 // Returns true if |client| is currently focused.
65 bool IsTextInputClientFocused(const TextInputClient* client);
66
67 // Checks if the focused text input client's text input type is
68 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text
69 // input client.
70 bool IsTextInputTypeNone() const;
71
72 // Convenience method to call the focused text input client's
73 // OnInputMethodChanged() method. It'll only take effect if the current text
74 // input type is not TEXT_INPUT_TYPE_NONE.
75 void OnInputMethodChanged() const;
76
77 // Convenience method to call delegate_->DispatchKeyEventPostIME().
78 // Returns true if the event was processed
79 bool DispatchKeyEventPostIME(const ui::KeyEvent& event) const;
80
81 // Convenience method to notify all observers of TextInputClient changes.
82 void NotifyTextInputStateChanged(const TextInputClient* client);
83
84 // Interface for for signalling candidate window events.
85 // See also *Callback functions below. To avoid reentrancy issue that
86 // TextInputClient manipulates IME state during even handling, these methods
87 // defer sending actual signals to renderer.
88 void OnCandidateWindowShown();
89 void OnCandidateWindowUpdated();
90 void OnCandidateWindowHidden();
91
92 bool system_toplevel_window_focused() const {
93 return system_toplevel_window_focused_;
94 }
95
96 private:
97 void SetFocusedTextInputClientInternal(TextInputClient* client);
98
99 // Deferred callbacks for signalling TextInputClient about candidate window
100 // appearance changes.
101 void CandidateWindowShownCallback();
102 void CandidateWindowUpdatedCallback();
103 void CandidateWindowHiddenCallback();
104
105 internal::InputMethodDelegate* delegate_;
106 TextInputClient* text_input_client_;
107
108 ObserverList<InputMethodObserver> observer_list_;
109
110 bool system_toplevel_window_focused_;
111
112 DISALLOW_COPY_AND_ASSIGN(InputMethodBase);
113 };
114
115 } // namespace ui
116
117 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_auralinux.cc ('k') | ui/base/ime/input_method_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698