Chromium Code Reviews| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 delegate_(nullptr), | 21 delegate_(nullptr), |
| 22 text_input_client_(nullptr) {} | 22 text_input_client_(nullptr) {} |
| 23 | 23 |
| 24 InputMethodBase::~InputMethodBase() { | 24 InputMethodBase::~InputMethodBase() { |
| 25 FOR_EACH_OBSERVER(InputMethodObserver, | 25 FOR_EACH_OBSERVER(InputMethodObserver, |
| 26 observer_list_, | 26 observer_list_, |
| 27 OnInputMethodDestroyed(this)); | 27 OnInputMethodDestroyed(this)); |
| 28 if (ui::IMEBridge::Get() && | 28 if (ui::IMEBridge::Get() && |
| 29 ui::IMEBridge::Get()->GetInputContextHandler() == this) | 29 ui::IMEBridge::Get()->GetInputContextHandler() == this) |
| 30 ui::IMEBridge::Get()->SetInputContextHandler(nullptr); | 30 ui::IMEBridge::Get()->SetInputContextHandler(nullptr); |
| 31 | |
| 32 if (!key_events_for_testing_.empty()) { | |
|
Devlin
2016/06/23 18:43:22
Why not just std::vector<std::unique_ptr<KeyEvent>
Azure Wei
2016/06/24 06:38:19
Done. Updated with ScopedVector.
| |
| 33 for (auto key : key_events_for_testing_) | |
| 34 delete key; | |
| 35 key_events_for_testing_.clear(); | |
| 36 } | |
| 31 } | 37 } |
| 32 | 38 |
| 33 void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) { | 39 void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) { |
| 34 delegate_ = delegate; | 40 delegate_ = delegate; |
| 35 } | 41 } |
| 36 | 42 |
| 37 void InputMethodBase::OnFocus() { | 43 void InputMethodBase::OnFocus() { |
| 38 if (ui::IMEBridge::Get()) | 44 if (ui::IMEBridge::Get()) |
| 39 ui::IMEBridge::Get()->SetInputContextHandler(this); | 45 ui::IMEBridge::Get()->SetInputContextHandler(this); |
| 40 } | 46 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 else | 198 else |
| 193 GetTextInputClient()->ClearCompositionText(); | 199 GetTextInputClient()->ClearCompositionText(); |
| 194 } | 200 } |
| 195 SendFakeProcessKeyEvent(false); | 201 SendFakeProcessKeyEvent(false); |
| 196 } | 202 } |
| 197 | 203 |
| 198 void InputMethodBase::DeleteSurroundingText(int32_t offset, uint32_t length) {} | 204 void InputMethodBase::DeleteSurroundingText(int32_t offset, uint32_t length) {} |
| 199 | 205 |
| 200 void InputMethodBase::SendKeyEvent(KeyEvent* event) { | 206 void InputMethodBase::SendKeyEvent(KeyEvent* event) { |
| 201 sending_key_event_ = true; | 207 sending_key_event_ = true; |
| 208 if (track_key_events_for_testing_) { | |
| 209 key_events_for_testing_.push_back(new KeyEvent(*event)); | |
| 210 } | |
| 202 DispatchKeyEvent(event); | 211 DispatchKeyEvent(event); |
| 203 sending_key_event_ = false; | 212 sending_key_event_ = false; |
| 204 } | 213 } |
| 205 | 214 |
| 215 InputMethod* InputMethodBase::GetInputMethod() { | |
| 216 return this; | |
| 217 } | |
| 218 | |
| 219 std::vector<ui::KeyEvent*> InputMethodBase::GetKeyEventsForTesting() { | |
| 220 return key_events_for_testing_; | |
| 221 } | |
| 222 | |
| 206 } // namespace ui | 223 } // namespace ui |
| OLD | NEW |