Commit 51c9e29f authored by sky@chromium.org's avatar sky@chromium.org

Fix use after free when handling async touch events

It's possible for the NativeView (aura::RootWindow*) in this case to
be destroyed by the time we end up processing the events.

BUG=288086
TEST=none
R=ananta@chromium.org

Review URL: https://chromiumcodereview.appspot.com/23619025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222167 0039d316-1c4b-4281-b951-d872f2087c98
parent 5a876138
...@@ -765,9 +765,14 @@ bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent( ...@@ -765,9 +765,14 @@ bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent(
OnHostKeyEvent(duplicate_event.get()); OnHostKeyEvent(duplicate_event.get());
} }
bool DesktopRootWindowHostWin::HandleTouchEvent( void DesktopRootWindowHostWin::HandleTouchEvent(
const ui::TouchEvent& event) { const ui::TouchEvent& event) {
return root_window_host_delegate_->OnHostTouchEvent( // HWNDMessageHandler asynchronously processes touch events. Because of this
// it's possible for the aura::RootWindow to have been destroyed by the time
// we attempt to process them.
if (!GetWidget()->GetNativeView())
return;
root_window_host_delegate_->OnHostTouchEvent(
const_cast<ui::TouchEvent*>(&event)); const_cast<ui::TouchEvent*>(&event));
} }
......
...@@ -178,7 +178,7 @@ class VIEWS_EXPORT DesktopRootWindowHostWin ...@@ -178,7 +178,7 @@ class VIEWS_EXPORT DesktopRootWindowHostWin
virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE;
virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual bool HandleTouchEvent(const ui::TouchEvent& event) OVERRIDE; virtual void HandleTouchEvent(const ui::TouchEvent& event) OVERRIDE;
virtual bool HandleIMEMessage(UINT message, virtual bool HandleIMEMessage(UINT message,
WPARAM w_param, WPARAM w_param,
LPARAM l_param, LPARAM l_param,
......
...@@ -784,9 +784,8 @@ bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { ...@@ -784,9 +784,8 @@ bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) {
return !!input_method; return !!input_method;
} }
bool NativeWidgetWin::HandleTouchEvent(const ui::TouchEvent& event) { void NativeWidgetWin::HandleTouchEvent(const ui::TouchEvent& event) {
NOTREACHED() << "Touch events are not supported"; NOTREACHED() << "Touch events are not supported";
return false;
} }
bool NativeWidgetWin::HandleIMEMessage(UINT message, bool NativeWidgetWin::HandleIMEMessage(UINT message,
......
...@@ -211,7 +211,7 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, ...@@ -211,7 +211,7 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate,
virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE;
virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual bool HandleTouchEvent(const ui::TouchEvent& event) OVERRIDE; virtual void HandleTouchEvent(const ui::TouchEvent& event) OVERRIDE;
virtual bool HandleIMEMessage(UINT message, virtual bool HandleIMEMessage(UINT message,
WPARAM w_param, WPARAM w_param,
LPARAM l_param, LPARAM l_param,
......
...@@ -185,9 +185,8 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { ...@@ -185,9 +185,8 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {
// translation). Returns true if the event was sent to the input method. // translation). Returns true if the event was sent to the input method.
virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) = 0; virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) = 0;
// Called when a touch event is received. Returns true if the event was // Called when a touch event is received.
// handled by the delegate. virtual void HandleTouchEvent(const ui::TouchEvent& event) = 0;
virtual bool HandleTouchEvent(const ui::TouchEvent& event) = 0;
// Called when an IME message needs to be processed by the delegate. Returns // Called when an IME message needs to be processed by the delegate. Returns
// true if the event was handled and no default processing should be // true if the event was handled and no default processing should be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment