web_contents_view_guest.h revision 116680a4aac90f2aa7413d9095a592090648e557
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_ 6#define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_ 7 8#include <vector> 9 10#include "base/memory/scoped_ptr.h" 11#include "content/browser/renderer_host/render_view_host_delegate_view.h" 12#include "content/browser/web_contents/web_contents_view.h" 13#include "content/common/content_export.h" 14#include "content/common/drag_event_source_info.h" 15 16namespace content { 17 18class WebContents; 19class WebContentsImpl; 20class BrowserPluginGuest; 21 22class WebContentsViewGuest : public WebContentsView, 23 public RenderViewHostDelegateView { 24 public: 25 // The corresponding WebContentsImpl is passed in the constructor, and manages 26 // our lifetime. This doesn't need to be the case, but is this way currently 27 // because that's what was easiest when they were split. 28 // WebContentsViewGuest always has a backing platform dependent view, 29 // |platform_view|. 30 WebContentsViewGuest(WebContentsImpl* web_contents, 31 BrowserPluginGuest* guest, 32 scoped_ptr<WebContentsView> platform_view, 33 RenderViewHostDelegateView* platform_view_delegate_view); 34 virtual ~WebContentsViewGuest(); 35 36 WebContents* web_contents(); 37 38 void OnGuestInitialized(WebContentsView* parent_view); 39 40 // Converts the guest specific coordinates in |params| to embedder specific 41 // ones. 42 ContextMenuParams ConvertContextMenuParams( 43 const ContextMenuParams& params) const; 44 45 // WebContentsView implementation -------------------------------------------- 46 virtual gfx::NativeView GetNativeView() const OVERRIDE; 47 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; 48 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; 49 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; 50 virtual void SizeContents(const gfx::Size& size) OVERRIDE; 51 virtual void Focus() OVERRIDE; 52 virtual void SetInitialFocus() OVERRIDE; 53 virtual void StoreFocus() OVERRIDE; 54 virtual void RestoreFocus() OVERRIDE; 55 virtual DropData* GetDropData() const OVERRIDE; 56 virtual gfx::Rect GetViewBounds() const OVERRIDE; 57 virtual void CreateView(const gfx::Size& initial_size, 58 gfx::NativeView context) OVERRIDE; 59 virtual RenderWidgetHostViewBase* CreateViewForWidget( 60 RenderWidgetHost* render_widget_host) OVERRIDE; 61 virtual RenderWidgetHostViewBase* CreateViewForPopupWidget( 62 RenderWidgetHost* render_widget_host) OVERRIDE; 63 virtual void SetPageTitle(const base::string16& title) OVERRIDE; 64 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; 65 virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; 66 virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; 67#if defined(OS_MACOSX) 68 virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; 69 virtual bool GetAllowOverlappingViews() const OVERRIDE; 70 virtual void SetAllowOtherViews(bool allow) OVERRIDE; 71 virtual bool GetAllowOtherViews() const OVERRIDE; 72 virtual bool IsEventTracking() const OVERRIDE; 73 virtual void CloseTabAfterEventTracking() OVERRIDE; 74#endif 75 76 // Backend implementation of RenderViewHostDelegateView. 77 virtual void ShowContextMenu(RenderFrameHost* render_frame_host, 78 const ContextMenuParams& params) OVERRIDE; 79 virtual void StartDragging(const DropData& drop_data, 80 blink::WebDragOperationsMask allowed_ops, 81 const gfx::ImageSkia& image, 82 const gfx::Vector2d& image_offset, 83 const DragEventSourceInfo& event_info) OVERRIDE; 84 virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE; 85 virtual void GotFocus() OVERRIDE; 86 virtual void TakeFocus(bool reverse) OVERRIDE; 87 88 private: 89 // The WebContentsImpl whose contents we display. 90 WebContentsImpl* web_contents_; 91 BrowserPluginGuest* guest_; 92 // The platform dependent view backing this WebContentsView. 93 // Calls to this WebContentsViewGuest are forwarded to |platform_view_|. 94 scoped_ptr<WebContentsView> platform_view_; 95 gfx::Size size_; 96 97 // Delegate view for guest's platform view. 98 RenderViewHostDelegateView* platform_view_delegate_view_; 99 100 DISALLOW_COPY_AND_ASSIGN(WebContentsViewGuest); 101}; 102 103} // namespace content 104 105#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_ 106