Index: ui/wm/core/input_method_event_filter.cc |
diff --git a/ui/wm/core/input_method_event_filter.cc b/ui/wm/core/input_method_event_filter.cc |
index 65bd5b506460b61d7dbe6c43a43f13f15882fe3f..10e5e5ad286685f3fb54df0de0711483324efac3 100644 |
--- a/ui/wm/core/input_method_event_filter.cc |
+++ b/ui/wm/core/input_method_event_filter.cc |
@@ -63,16 +63,16 @@ void InputMethodEventFilter::OnKeyEvent(ui::KeyEvent* event) { |
// IME again. Just let the event dispatcher continue to dispatch the event. |
event->SetTranslated(false); |
} else { |
- // If the focused window is changed, all requests to IME will be |
- // discarded so it's safe to update the target_dispatcher_ here. |
- aura::Window* target = static_cast<aura::Window*>(event->target()); |
- target_dispatcher_ = target->GetRootWindow()->GetHost()->event_processor(); |
- DCHECK(target_dispatcher_); |
if (input_method_->DispatchKeyEvent(*event)) |
event->StopPropagation(); |
} |
} |
+void InputMethodEventFilter::UpdateTargetDispatcher( |
+ ui::EventProcessor* dispatcher) { |
+ target_dispatcher_ = dispatcher; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// InputMethodEventFilter, ui::InputMethodDelegate implementation: |
@@ -86,6 +86,8 @@ bool InputMethodEventFilter::DispatchKeyEventPostIME( |
// This time we have to skip dispatching the event to the IME, we mark the |
// event as TRANSLATED so we can distinguish this event as a second time |
// dispatched event. |
+ if (!target_dispatcher_) |
+ return false; |
ui::KeyEvent aura_event(event); |
aura_event.SetTranslated(true); |
ui::EventDispatchDetails details = |