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..dc1936e9f9d678b2f6ea784b880deb397d56cf4e 100644 |
--- a/content/browser/web_contents/web_contents_view_aura.cc |
+++ b/content/browser/web_contents/web_contents_view_aura.cc |
@@ -91,8 +91,10 @@ bool IsScrollEndEffectEnabled() { |
RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
RenderWidgetHostView* view) { |
- if (!view || RenderViewHostFactory::has_factory()) |
+ if (!view || (RenderViewHostFactory::has_factory() && |
+ !RenderViewHostFactory::is_real_render_view_host())) { |
return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. |
+ } |
RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost()); |
WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
@@ -662,6 +664,11 @@ WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, |
is_or_was_visible_(false) { |
} |
+void WebContentsViewAura::SetDelegateForTesting( |
+ WebContentsViewDelegate* delegate) { |
+ delegate_.reset(delegate); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// WebContentsViewAura, private: |
@@ -951,11 +958,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 +1197,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); |
} |