Commit 7490c3bf authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Fix omnibox result crashes.

GetParentWidgetAndEvent can fail to find a widget; if so, don't
call through a null pointer.

BUG=883700

Change-Id: Ifa4430fe7cc7c83da9e21fa478e15b59498138ec
Reviewed-on: https://chromium-review.googlesource.com/1244019Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594083}
parent 35c0d8a8
...@@ -81,12 +81,14 @@ class TopBackgroundView : public views::View { ...@@ -81,12 +81,14 @@ class TopBackgroundView : public views::View {
// well to catch 'em all. // well to catch 'em all.
void OnMouseMoved(const ui::MouseEvent& event) override { void OnMouseMoved(const ui::MouseEvent& event) override {
auto pair = GetParentWidgetAndEvent(this, &event); auto pair = GetParentWidgetAndEvent(this, &event);
pair.widget->OnMouseEvent(&pair.event); if (pair.widget)
pair.widget->OnMouseEvent(&pair.event);
} }
void OnMouseEvent(ui::MouseEvent* event) override { void OnMouseEvent(ui::MouseEvent* event) override {
auto pair = GetParentWidgetAndEvent(this, event); auto pair = GetParentWidgetAndEvent(this, event);
pair.widget->OnMouseEvent(&pair.event); if (pair.widget)
pair.widget->OnMouseEvent(&pair.event);
// If the original event isn't marked as "handled" then it will propagate up // If the original event isn't marked as "handled" then it will propagate up
// the view hierarchy and might be double-handled. https://crbug.com/870341 // the view hierarchy and might be double-handled. https://crbug.com/870341
...@@ -95,10 +97,14 @@ class TopBackgroundView : public views::View { ...@@ -95,10 +97,14 @@ class TopBackgroundView : public views::View {
gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override { gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override {
auto pair = GetParentWidgetAndEvent(this, &event); auto pair = GetParentWidgetAndEvent(this, &event);
views::View* omnibox_view = if (pair.widget) {
pair.widget->GetRootView()->GetEventHandlerForPoint( views::View* omnibox_view =
pair.event.location()); pair.widget->GetRootView()->GetEventHandlerForPoint(
return omnibox_view->GetCursor(pair.event); pair.event.location());
return omnibox_view->GetCursor(pair.event);
}
return nullptr;
} }
#endif // !USE_AURA #endif // !USE_AURA
}; };
......
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