Chromium Code Reviews| Index: content/browser/web_contents/web_contents_view_aura.cc |
| diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc |
| index a899bf3310432a94005c43bb5e7b1cab8dd8053d..ae6062e202c7cd54ffa5792e2ab279bc5fcb86ee 100644 |
| --- a/content/browser/web_contents/web_contents_view_aura.cc |
| +++ b/content/browser/web_contents/web_contents_view_aura.cc |
| @@ -91,8 +91,12 @@ bool IsScrollEndEffectEnabled() { |
| RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
| RenderWidgetHostView* view) { |
| - if (!view || RenderViewHostFactory::has_factory()) |
| + if (!view || |
| + (RenderViewHostFactory::has_factory() |
| + && |
|
jam
2016/01/21 21:31:09
this indentation seems odd? why isn't this on the
ananta
2016/01/21 22:17:48
Fixed
|
| + !RenderViewHostFactory::allow_host_view_cast_in_test())) { |
| return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. |
| + } |
| RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost()); |
| WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| @@ -662,6 +666,10 @@ WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, |
| is_or_was_visible_(false) { |
| } |
| +void WebContentsViewAura::SetDelegate(WebContentsViewDelegate* delegate) { |
| + delegate_.reset(delegate); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // WebContentsViewAura, private: |
| @@ -951,11 +959,12 @@ void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, |
| selection_controller_client->HandleContextMenu(params)) { |
| return; |
| } |
| + |
| if (delegate_) { |
| RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( |
| web_contents_->GetRenderWidgetHostView()); |
| - if (view) |
| - view->OnShowContextMenu(); |
| + if (view && !view->OnShowContextMenu(params)) |
| + return; |
| delegate_->ShowContextMenu(render_frame_host, params); |
| // WARNING: we may have been deleted during the call to ShowContextMenu(). |
| @@ -1189,16 +1198,16 @@ void WebContentsViewAura::OnKeyEvent(ui::KeyEvent* event) { |
| } |
| void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { |
| - if (!web_contents_->GetDelegate()) |
| - return; |
| - |
| - ui::EventType type = event->type(); |
| - if (type == ui::ET_MOUSE_PRESSED) |
| - web_contents_->GetDelegate()->ActivateContents(web_contents_); |
| - |
| - web_contents_->GetDelegate()->ContentsMouseEvent( |
| - web_contents_, |
| - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| + if (!web_contents_->GetDelegate()) |
| + return; |
| + |
| + ui::EventType type = event->type(); |
| + if (type == ui::ET_MOUSE_PRESSED) |
| + web_contents_->GetDelegate()->ActivateContents(web_contents_); |
| + |
| + web_contents_->GetDelegate()->ContentsMouseEvent( |
| + web_contents_, |
| + gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); |
| } |