OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/ime/input_method_base.h" | 5 #include "ui/base/ime/input_method_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/ime/input_method_delegate.h" | 8 #include "ui/base/ime/input_method_delegate.h" |
9 #include "ui/base/ime/input_method_observer.h" | 9 #include "ui/base/ime/input_method_observer.h" |
10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
| 11 #include "ui/events/event.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 InputMethodBase::InputMethodBase() | 15 InputMethodBase::InputMethodBase() |
15 : delegate_(NULL), | 16 : delegate_(NULL), |
16 text_input_client_(NULL), | 17 text_input_client_(NULL), |
17 system_toplevel_window_focused_(false) { | 18 system_toplevel_window_focused_(false) { |
18 } | 19 } |
19 | 20 |
20 InputMethodBase::~InputMethodBase() { | 21 InputMethodBase::~InputMethodBase() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return GetTextInputType() == TEXT_INPUT_TYPE_NONE; | 111 return GetTextInputType() == TEXT_INPUT_TYPE_NONE; |
111 } | 112 } |
112 | 113 |
113 void InputMethodBase::OnInputMethodChanged() const { | 114 void InputMethodBase::OnInputMethodChanged() const { |
114 TextInputClient* client = GetTextInputClient(); | 115 TextInputClient* client = GetTextInputClient(); |
115 if (!IsTextInputTypeNone()) | 116 if (!IsTextInputTypeNone()) |
116 client->OnInputMethodChanged(); | 117 client->OnInputMethodChanged(); |
117 } | 118 } |
118 | 119 |
119 bool InputMethodBase::DispatchKeyEventPostIME( | 120 bool InputMethodBase::DispatchKeyEventPostIME( |
120 const base::NativeEvent& native_event) const { | 121 const ui::KeyEvent& event) const { |
121 return delegate_ ? delegate_->DispatchKeyEventPostIME(native_event) : false; | 122 if (!delegate_) |
122 } | 123 return false; |
123 | 124 |
124 bool InputMethodBase::DispatchFabricatedKeyEventPostIME(EventType type, | 125 if (event.HasNativeEvent()) |
125 KeyboardCode key_code, | 126 return delegate_->DispatchKeyEventPostIME(event); |
126 int flags) const { | 127 else |
127 return delegate_ ? delegate_->DispatchFabricatedKeyEventPostIME | 128 return delegate_->DispatchFabricatedKeyEventPostIME(event.type(), |
128 (type, key_code, flags) : false; | 129 event.key_code(), |
| 130 event.flags()); |
129 } | 131 } |
130 | 132 |
131 void InputMethodBase::NotifyTextInputStateChanged( | 133 void InputMethodBase::NotifyTextInputStateChanged( |
132 const TextInputClient* client) { | 134 const TextInputClient* client) { |
133 FOR_EACH_OBSERVER(InputMethodObserver, | 135 FOR_EACH_OBSERVER(InputMethodObserver, |
134 observer_list_, | 136 observer_list_, |
135 OnTextInputStateChanged(client)); | 137 OnTextInputStateChanged(client)); |
136 } | 138 } |
137 | 139 |
138 void InputMethodBase::SetFocusedTextInputClientInternal( | 140 void InputMethodBase::SetFocusedTextInputClientInternal( |
139 TextInputClient* client) { | 141 TextInputClient* client) { |
140 TextInputClient* old = text_input_client_; | 142 TextInputClient* old = text_input_client_; |
141 OnWillChangeFocusedClient(old, client); | 143 OnWillChangeFocusedClient(old, client); |
142 text_input_client_ = client; // NULL allowed. | 144 text_input_client_ = client; // NULL allowed. |
143 OnDidChangeFocusedClient(old, client); | 145 OnDidChangeFocusedClient(old, client); |
144 NotifyTextInputStateChanged(text_input_client_); | 146 NotifyTextInputStateChanged(text_input_client_); |
145 } | 147 } |
146 | 148 |
147 } // namespace ui | 149 } // namespace ui |
OLD | NEW |