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.
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_
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"
19 class WebContentsImpl
;
20 class BrowserPluginGuest
;
22 class WebContentsViewGuest
: public WebContentsView
,
23 public RenderViewHostDelegateView
{
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,
30 WebContentsViewGuest(WebContentsImpl
* web_contents
,
31 BrowserPluginGuest
* guest
,
32 scoped_ptr
<WebContentsView
> platform_view
,
33 RenderViewHostDelegateView
* platform_view_delegate_view
);
34 ~WebContentsViewGuest() override
;
36 WebContents
* web_contents();
38 void OnGuestAttached(WebContentsView
* parent_view
);
40 void OnGuestDetached(WebContentsView
* old_parent_view
);
42 // WebContentsView implementation --------------------------------------------
43 gfx::NativeView
GetNativeView() const override
;
44 gfx::NativeView
GetContentNativeView() const override
;
45 gfx::NativeWindow
GetTopLevelNativeWindow() const override
;
46 void GetContainerBounds(gfx::Rect
* out
) const override
;
47 void SizeContents(const gfx::Size
& size
) override
;
48 void Focus() override
;
49 void SetInitialFocus() override
;
50 void StoreFocus() override
;
51 void RestoreFocus() override
;
52 DropData
* GetDropData() const override
;
53 gfx::Rect
GetViewBounds() const override
;
54 void CreateView(const gfx::Size
& initial_size
,
55 gfx::NativeView context
) override
;
56 RenderWidgetHostViewBase
* CreateViewForWidget(
57 RenderWidgetHost
* render_widget_host
,
58 bool is_guest_view_hack
) override
;
59 RenderWidgetHostViewBase
* CreateViewForPopupWidget(
60 RenderWidgetHost
* render_widget_host
) override
;
61 void SetPageTitle(const base::string16
& title
) override
;
62 void RenderViewCreated(RenderViewHost
* host
) override
;
63 void RenderViewSwappedIn(RenderViewHost
* host
) override
;
64 void SetOverscrollControllerEnabled(bool enabled
) override
;
65 #if defined(OS_MACOSX)
66 void SetAllowOtherViews(bool allow
) override
;
67 bool GetAllowOtherViews() const override
;
68 bool IsEventTracking() const override
;
69 void CloseTabAfterEventTracking() override
;
72 // Backend implementation of RenderViewHostDelegateView.
73 void ShowContextMenu(RenderFrameHost
* render_frame_host
,
74 const ContextMenuParams
& params
) override
;
75 void StartDragging(const DropData
& drop_data
,
76 blink::WebDragOperationsMask allowed_ops
,
77 const gfx::ImageSkia
& image
,
78 const gfx::Vector2d
& image_offset
,
79 const DragEventSourceInfo
& event_info
) override
;
80 void UpdateDragCursor(blink::WebDragOperation operation
) override
;
81 void GotFocus() override
;
82 void TakeFocus(bool reverse
) override
;
85 // The WebContentsImpl whose contents we display.
86 WebContentsImpl
* web_contents_
;
87 BrowserPluginGuest
* guest_
;
88 // The platform dependent view backing this WebContentsView.
89 // Calls to this WebContentsViewGuest are forwarded to |platform_view_|.
90 scoped_ptr
<WebContentsView
> platform_view_
;
93 // Delegate view for guest's platform view.
94 RenderViewHostDelegateView
* platform_view_delegate_view_
;
96 DISALLOW_COPY_AND_ASSIGN(WebContentsViewGuest
);
99 } // namespace content
101 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_