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 "extensions/shell/browser/input_method_event_handler.h" |
| 6 |
| 7 #include "ui/base/ime/input_method.h" |
| 8 #include "ui/events/event.h" |
| 9 |
| 10 namespace extensions { |
| 11 |
| 12 InputMethodEventHandler::InputMethodEventHandler(ui::InputMethod* input_method) |
| 13 : input_method_(input_method), post_ime_(false) { |
| 14 DCHECK(input_method_); |
| 15 } |
| 16 |
| 17 InputMethodEventHandler::~InputMethodEventHandler() {} |
| 18 |
| 19 void InputMethodEventHandler::set_post_ime(bool post_ime) { |
| 20 post_ime_ = post_ime; |
| 21 } |
| 22 |
| 23 void InputMethodEventHandler::OnKeyEvent(ui::KeyEvent* event) { |
| 24 // Ignore events being dispatched back to the delegate from the input method. |
| 25 if (post_ime_) |
| 26 return; |
| 27 |
| 28 if (event->flags() & ui::EF_IS_SYNTHESIZED) |
| 29 return; |
| 30 |
| 31 input_method_->DispatchKeyEvent(event); |
| 32 event->StopPropagation(); |
| 33 } |
| 34 |
| 35 } // namespace extensions |
OLD | NEW |