OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/aura/test/input_method_glue.h" |
| 6 |
| 7 #include "ui/aura/env.h" |
| 8 #include "ui/aura/window_tree_host.h" |
| 9 #include "ui/base/ime/input_method.h" |
| 10 #include "ui/events/event.h" |
| 11 |
| 12 namespace aura { |
| 13 |
| 14 InputMethodGlue::InputMethodGlue(aura::WindowTreeHost* host) : host_(host) { |
| 15 aura::Env::GetInstance()->AddPreTargetHandler(this); |
| 16 host_->GetInputMethod()->SetDelegate(this); |
| 17 } |
| 18 |
| 19 InputMethodGlue::~InputMethodGlue() { |
| 20 host_->GetInputMethod()->SetDelegate(host_); |
| 21 aura::Env::GetInstance()->RemovePreTargetHandler(this); |
| 22 } |
| 23 |
| 24 void InputMethodGlue::OnKeyEvent(ui::KeyEvent* key) { |
| 25 if (processing_ime_event_) |
| 26 return; |
| 27 host_->GetInputMethod()->DispatchKeyEvent(key); |
| 28 key->StopPropagation(); |
| 29 } |
| 30 |
| 31 ui::EventDispatchDetails InputMethodGlue::DispatchKeyEventPostIME( |
| 32 ui::KeyEvent* key) { |
| 33 base::AutoReset<bool> reset(&processing_ime_event_, true); |
| 34 return host_->DispatchKeyEventPostIME(key); |
| 35 } |
| 36 |
| 37 } // namespace aura |
OLD | NEW |