Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
| index 85172f1b2ef95af5fa6284195bb6609489d281cb..8df8bfe9ad271fe943b1d2e7b18cd1d0208e7464 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
| @@ -10,9 +10,44 @@ |
| #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| #include "chrome/browser/ui/layout_constants.h" |
| #include "content/public/browser/notification_source.h" |
| +#include "content/public/browser/render_view_host.h" |
| #include "ui/base/material_design/material_design_controller.h" |
| #include "ui/gfx/geometry/rect.h" |
| +LocationBarBubbleDelegateView::WebContentMouseHandler::WebContentMouseHandler( |
| + LocationBarBubbleDelegateView* bubble, |
| + content::WebContents* web_contents) |
| + : bubble_(bubble), web_contents_(web_contents) { |
| + DCHECK(bubble_); |
| + DCHECK(web_contents_); |
| + event_monitor_ = views::EventMonitor::CreateWindowMonitor( |
| + this, web_contents_->GetTopLevelNativeWindow()); |
| +} |
| + |
| +LocationBarBubbleDelegateView::WebContentMouseHandler:: |
| + ~WebContentMouseHandler() {} |
| + |
| +void LocationBarBubbleDelegateView::WebContentMouseHandler::OnKeyEvent( |
| + ui::KeyEvent* event) { |
| + content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
|
Peter Kasting
2016/06/13 20:27:24
Nit: Can just inline into the line below
hcarmona
2016/06/13 20:49:03
Done.
|
| + if ((event->key_code() == ui::VKEY_ESCAPE || |
| + rvh->IsFocusedElementEditable()) && |
| + event->type() == ui::ET_KEY_PRESSED) |
| + bubble_->CloseBubble(); |
| +} |
| + |
| +void LocationBarBubbleDelegateView::WebContentMouseHandler::OnMouseEvent( |
| + ui::MouseEvent* event) { |
| + if (event->type() == ui::ET_MOUSE_PRESSED) |
| + bubble_->CloseBubble(); |
| +} |
| + |
| +void LocationBarBubbleDelegateView::WebContentMouseHandler::OnTouchEvent( |
| + ui::TouchEvent* event) { |
| + if (event->type() == ui::ET_TOUCH_PRESSED) |
| + bubble_->CloseBubble(); |
| +} |
| + |
| LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( |
| views::View* anchor_view, |
| content::WebContents* web_contents) |