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..3fe5b5bc1482d06c78844965ff1e853199107ece 100644 |
--- a/ui/wm/core/input_method_event_filter.cc |
+++ b/ui/wm/core/input_method_event_filter.cc |
@@ -17,8 +17,7 @@ namespace wm { |
// InputMethodEventFilter, public: |
InputMethodEventFilter::InputMethodEventFilter(gfx::AcceleratedWidget widget) |
- : input_method_(ui::CreateInputMethod(this, widget)), |
- target_dispatcher_(NULL) { |
+ : input_method_(ui::CreateInputMethod(this, widget)) { |
// TODO(yusukes): Check if the root window is currently focused and pass the |
// result to Init(). |
input_method_->Init(true); |
@@ -63,11 +62,6 @@ 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(); |
} |
@@ -86,10 +80,15 @@ 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. |
+ aura::Window* target = static_cast<aura::Window*>(event.target()); |
+ if (!target) |
+ return false; |
+ ui::EventProcessor* target_dispatcher = |
+ target->GetRootWindow()->GetHost()->event_processor(); |
ui::KeyEvent aura_event(event); |
aura_event.SetTranslated(true); |
ui::EventDispatchDetails details = |
- target_dispatcher_->OnEventFromSource(&aura_event); |
+ target_dispatcher->OnEventFromSource(&aura_event); |
CHECK(!details.dispatcher_destroyed); |
return aura_event.handled(); |
} |