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

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

Issue 8659033: IME (input method editor) support for Aura, part 1 of 3: Add ui/base/ime/ classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, review fix Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/ime/input_method_base.h ('k') | ui/base/ime/input_method_delegate.h » ('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) 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.
4
5 #include "ui/base/ime/input_method_base.h"
6
7 #include "base/logging.h"
8 #include "ui/base/ime/input_method_delegate.h"
9 #include "ui/base/ime/text_input_client.h"
10
11 namespace ui {
12
13 InputMethodBase::InputMethodBase()
14 : delegate_(NULL),
15 text_input_client_(NULL),
16 system_toplevel_window_focused_(false) {
17 }
18
19 InputMethodBase::~InputMethodBase() {
20 }
21
22 void InputMethodBase::SetDelegate(
23 internal::InputMethodDelegate* delegate) {
24 delegate_ = delegate;
25 }
26
27 void InputMethodBase::Init(bool focused) {
28 if (focused)
29 OnFocus();
30 }
31
32 void InputMethodBase::OnFocus() {
33 DCHECK(!system_toplevel_window_focused_);
34 system_toplevel_window_focused_ = true;
35 }
36
37 void InputMethodBase::OnBlur() {
38 DCHECK(system_toplevel_window_focused_);
39 system_toplevel_window_focused_ = false;
40 }
41
42 void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) {
43 TextInputClient* old = text_input_client_;
44 OnWillChangeFocusedClient(old, client);
45 text_input_client_ = client; // NULL allowed.
46 OnDidChangeFocusedClient(old, client);
47 }
48
49 TextInputClient* InputMethodBase::GetTextInputClient() const {
50 return system_toplevel_window_focused_ ? text_input_client_ : NULL;
51 }
52
53 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) {
54 if (!IsTextInputClientFocused(client))
55 return;
56 // TODO(yusukes): Support TextInputTypeTracker for TOUCH_UI.
57 }
58
59 TextInputType InputMethodBase::GetTextInputType() const {
60 TextInputClient* client = GetTextInputClient();
61 return client ? client->GetTextInputType() : TEXT_INPUT_TYPE_NONE;
62 }
63
64 bool InputMethodBase::IsTextInputClientFocused(const TextInputClient* client) {
65 return client && (client == GetTextInputClient());
66 }
67
68 bool InputMethodBase::IsTextInputTypeNone() const {
69 return GetTextInputType() == TEXT_INPUT_TYPE_NONE;
70 }
71
72 void InputMethodBase::OnInputMethodChanged() const {
73 TextInputClient* client = GetTextInputClient();
74 if (client && client->GetTextInputType() != TEXT_INPUT_TYPE_NONE)
75 client->OnInputMethodChanged();
76 }
77
78 void InputMethodBase::DispatchKeyEventPostIME(
79 const base::NativeEvent& native_event) const {
80 if (delegate_)
81 delegate_->DispatchKeyEventPostIME(native_event);
82 }
83
84 void InputMethodBase::DispatchFabricatedKeyEventPostIME(EventType type,
85 KeyboardCode key_code,
86 int flags) const {
87 if (delegate_)
88 delegate_->DispatchFabricatedKeyEventPostIME(type, key_code, flags);
89 }
90
91 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_base.h ('k') | ui/base/ime/input_method_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698