web_contents_view_guest.cc revision 116680a4aac90f2aa7413d9095a592090648e557
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/web_contents/web_contents_view_guest.h" 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "build/build_config.h" 8c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "content/browser/browser_plugin/browser_plugin_embedder.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/browser_plugin/browser_plugin_guest.h" 101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/browser/frame_host/interstitial_page_impl.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/browser/frame_host/render_widget_host_view_guest.h" 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/renderer_host/render_view_host_factory.h" 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/renderer_host/render_view_host_impl.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/web_contents/web_contents_impl.h" 15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "content/common/drag_messages.h" 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/public/browser/user_metrics.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/web_contents_delegate.h" 187d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "content/public/common/context_menu_params.h" 19eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/public/common/drop_data.h" 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/image/image_skia.h" 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/point.h" 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/rect.h" 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/size.h" 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 25bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch#if defined(USE_AURA) 26bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch#include "ui/aura/window.h" 27bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch#endif 28bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch 29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)using blink::WebDragOperation; 30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)using blink::WebDragOperationsMask; 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content { 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebContentsViewGuest::WebContentsViewGuest( 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WebContentsImpl* web_contents, 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) BrowserPluginGuest* guest, 37010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) scoped_ptr<WebContentsView> platform_view, 387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) RenderViewHostDelegateView* platform_view_delegate_view) 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) : web_contents_(web_contents), 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) guest_(guest), 417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch platform_view_(platform_view.Pass()), 427d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) platform_view_delegate_view_(platform_view_delegate_view) { 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebContentsViewGuest::~WebContentsViewGuest() { 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)gfx::NativeView WebContentsViewGuest::GetNativeView() const { 49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return platform_view_->GetNativeView(); 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)gfx::NativeView WebContentsViewGuest::GetContentNativeView() const { 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!rwhv) 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return NULL; 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return rwhv->GetNativeView(); 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const { 60010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) return guest_->embedder_web_contents()->GetTopLevelNativeWindow(); 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 63bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdochvoid WebContentsViewGuest::OnGuestInitialized(WebContentsView* parent_view) { 64c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#if defined(USE_AURA) 65c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // In aura, ScreenPositionClient doesn't work properly if we do 66bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // not have the native view associated with this WebContentsViewGuest in the 67bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // view hierarchy. We add this view as embedder's child here. 68bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // This would go in WebContentsViewGuest::CreateView, but that is too early to 69bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // access embedder_web_contents(). Therefore, we do it here. 70bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView()); 71c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#endif // defined(USE_AURA) 72bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch} 73bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch 74010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams( 75010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) const ContextMenuParams& params) const { 76010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#if defined(USE_AURA) 77010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // Context menu uses ScreenPositionClient::ConvertPointToScreen() in aura 78010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // to calculate popup position. Guest's native view 79010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // (platform_view_->GetNativeView()) is part of the embedder's view hierarchy, 80010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // but is placed at (0, 0) w.r.t. the embedder's position. Therefore, |offset| 81010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // is added to |params|. 82010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) gfx::Rect embedder_bounds; 83010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) guest_->embedder_web_contents()->GetView()->GetContainerBounds( 84010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) &embedder_bounds); 85010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) gfx::Rect guest_bounds; 86010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) GetContainerBounds(&guest_bounds); 87010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 88010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin(); 89010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) ContextMenuParams params_in_embedder = params; 90010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) params_in_embedder.x += offset.x(); 91010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) params_in_embedder.y += offset.y(); 92010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) return params_in_embedder; 93010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#else 94010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) return params; 95010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#endif 96010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)} 97010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::GetContainerBounds(gfx::Rect* out) const { 997d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // We need embedder container's bounds to calculate our bounds. 1007d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) guest_->embedder_web_contents()->GetView()->GetContainerBounds(out); 1017d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point()); 1027d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) out->Offset(guest_coordinates.x(), guest_coordinates.y()); 1037d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) out->set_size(size_); 1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::SizeContents(const gfx::Size& size) { 107c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) size_ = size; 108c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 109c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (rwhv) 110c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) rwhv->SetSize(size); 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::SetInitialFocus() { 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->SetInitialFocus(); 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)gfx::Rect WebContentsViewGuest::GetViewBounds() const { 118c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return gfx::Rect(size_); 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_MACOSX) 1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::SetAllowOverlappingViews(bool overlapping) { 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->SetAllowOverlappingViews(overlapping); 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1257d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 1267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)bool WebContentsViewGuest::GetAllowOverlappingViews() const { 1277d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return platform_view_->GetAllowOverlappingViews(); 1287d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} 129a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 130116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid WebContentsViewGuest::SetAllowOtherViews(bool allow) { 131116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch platform_view_->SetAllowOtherViews(allow); 132a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 133a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 134116680a4aac90f2aa7413d9095a592090648e557Ben Murdochbool WebContentsViewGuest::GetAllowOtherViews() const { 135116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return platform_view_->GetAllowOtherViews(); 136a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::CreateView(const gfx::Size& initial_size, 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::NativeView context) { 1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->CreateView(initial_size, context); 142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) size_ = initial_size; 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 145010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget( 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RenderWidgetHost* render_widget_host) { 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (render_widget_host->GetView()) { 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // During testing, the view will already be set up in most cases to the 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // test view, so we don't want to clobber it with a real one. To verify that 1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // this actually is happening (and somebody isn't accidentally creating the 1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // view twice), we check for the RVH Factory, which will be set when we're 1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // making special ones (which go along with the special views). 1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DCHECK(RenderViewHostFactory::has_factory()); 154010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) return static_cast<RenderWidgetHostViewBase*>( 155010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) render_widget_host->GetView()); 1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 158010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) RenderWidgetHostViewBase* platform_widget = 159010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) platform_view_->CreateViewForWidget(render_widget_host); 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 161010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) RenderWidgetHostViewBase* view = new RenderWidgetHostViewGuest( 1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) render_widget_host, 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) guest_, 1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_widget); 1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return view; 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 169010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForPopupWidget( 1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) RenderWidgetHost* render_widget_host) { 171f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) return platform_view_->CreateViewForPopupWidget(render_widget_host); 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 174a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void WebContentsViewGuest::SetPageTitle(const base::string16& title) { 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::RenderViewCreated(RenderViewHost* host) { 1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->RenderViewCreated(host); 1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::RenderViewSwappedIn(RenderViewHost* host) { 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->RenderViewSwappedIn(host); 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::SetOverscrollControllerEnabled(bool enabled) { 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // This should never override the setting of the embedder view. 1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_MACOSX) 1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool WebContentsViewGuest::IsEventTracking() const { 1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return false; 1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::CloseTabAfterEventTracking() { 1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebContents* WebContentsViewGuest::web_contents() { 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return web_contents_; 2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::RestoreFocus() { 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->RestoreFocus(); 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::Focus() { 2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->Focus(); 2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::StoreFocus() { 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) platform_view_->StoreFocus(); 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 214eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen MurdochDropData* WebContentsViewGuest::GetDropData() const { 2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NOTIMPLEMENTED(); 2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return NULL; 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::UpdateDragCursor(WebDragOperation operation) { 220c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderViewHostImpl* embedder_render_view_host = 221c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static_cast<RenderViewHostImpl*>( 222c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) guest_->embedder_web_contents()->GetRenderViewHost()); 223c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CHECK(embedder_render_view_host); 224c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderViewHostDelegateView* view = 225c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) embedder_render_view_host->GetDelegate()->GetDelegateView(); 226c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (view) 227c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) view->UpdateDragCursor(operation); 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::GotFocus() { 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::TakeFocus(bool reverse) { 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void WebContentsViewGuest::ShowContextMenu(RenderFrameHost* render_frame_host, 2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const ContextMenuParams& params) { 2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) platform_view_delegate_view_->ShowContextMenu( 239010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) render_frame_host, ConvertContextMenuParams(params)); 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void WebContentsViewGuest::StartDragging( 243eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const DropData& drop_data, 2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) WebDragOperationsMask ops, 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::ImageSkia& image, 2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Vector2d& image_offset, 2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const DragEventSourceInfo& event_info) { 248c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WebContentsImpl* embedder_web_contents = guest_->embedder_web_contents(); 249c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) embedder_web_contents->GetBrowserPluginEmbedder()->StartDrag(guest_); 250c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderViewHostImpl* embedder_render_view_host = 251c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static_cast<RenderViewHostImpl*>( 252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) embedder_web_contents->GetRenderViewHost()); 253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CHECK(embedder_render_view_host); 254c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderViewHostDelegateView* view = 255c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) embedder_render_view_host->GetDelegate()->GetDelegateView(); 2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (view) { 2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); 258c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) view->StartDragging(drop_data, ops, image, image_offset, event_info); 2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { 260c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) embedder_web_contents->SystemDragEnded(); 2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace content 265