- add sources.
[platform/framework/web/crosswalk.git] / src / content / browser / web_contents / web_contents_view_guest.h
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/common/content_export.h"
12 #include "content/common/drag_event_source_info.h"
13 #include "content/port/browser/render_view_host_delegate_view.h"
14 #include "content/port/browser/web_contents_view_port.h"
15
16 namespace content {
17
18 class WebContents;
19 class WebContentsImpl;
20 class BrowserPluginGuest;
21
22 class CONTENT_EXPORT WebContentsViewGuest
23     : public WebContentsViewPort,
24       public RenderViewHostDelegateView {
25  public:
26   // The corresponding WebContentsImpl is passed in the constructor, and manages
27   // our lifetime. This doesn't need to be the case, but is this way currently
28   // because that's what was easiest when they were split.
29   // WebContentsViewGuest always has a backing platform dependent view,
30   // |platform_view|.
31   WebContentsViewGuest(WebContentsImpl* web_contents,
32                        BrowserPluginGuest* guest,
33                        scoped_ptr<WebContentsViewPort> platform_view,
34                        RenderViewHostDelegateView* platform_view_delegate_view);
35   virtual ~WebContentsViewGuest();
36
37   WebContents* web_contents();
38
39   void OnGuestInitialized(WebContentsView* parent_view);
40
41   // WebContentsView implementation --------------------------------------------
42
43   virtual gfx::NativeView GetNativeView() const OVERRIDE;
44   virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
45   virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
46   virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
47   virtual void OnTabCrashed(base::TerminationStatus status,
48                             int error_code) OVERRIDE;
49   virtual void SizeContents(const gfx::Size& size) OVERRIDE;
50   virtual void Focus() OVERRIDE;
51   virtual void SetInitialFocus() OVERRIDE;
52   virtual void StoreFocus() OVERRIDE;
53   virtual void RestoreFocus() OVERRIDE;
54   virtual DropData* GetDropData() const OVERRIDE;
55   virtual gfx::Rect GetViewBounds() const OVERRIDE;
56 #if defined(OS_MACOSX)
57   virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE;
58   virtual bool GetAllowOverlappingViews() const OVERRIDE;
59 #endif
60
61   // WebContentsViewPort implementation ----------------------------------------
62   virtual void CreateView(const gfx::Size& initial_size,
63                           gfx::NativeView context) OVERRIDE;
64   virtual RenderWidgetHostView* CreateViewForWidget(
65       RenderWidgetHost* render_widget_host) OVERRIDE;
66   virtual RenderWidgetHostView* CreateViewForPopupWidget(
67       RenderWidgetHost* render_widget_host) OVERRIDE;
68   virtual void SetPageTitle(const string16& title) OVERRIDE;
69   virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
70   virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE;
71   virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE;
72 #if defined(OS_MACOSX)
73   virtual bool IsEventTracking() const OVERRIDE;
74   virtual void CloseTabAfterEventTracking() OVERRIDE;
75 #endif
76
77   // Backend implementation of RenderViewHostDelegateView.
78   virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE;
79   virtual void ShowPopupMenu(const gfx::Rect& bounds,
80                              int item_height,
81                              double item_font_size,
82                              int selected_item,
83                              const std::vector<MenuItem>& items,
84                              bool right_aligned,
85                              bool allow_multiple_selection) OVERRIDE;
86   virtual void StartDragging(const DropData& drop_data,
87                              WebKit::WebDragOperationsMask allowed_ops,
88                              const gfx::ImageSkia& image,
89                              const gfx::Vector2d& image_offset,
90                              const DragEventSourceInfo& event_info) OVERRIDE;
91   virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
92   virtual void GotFocus() OVERRIDE;
93   virtual void TakeFocus(bool reverse) OVERRIDE;
94
95  private:
96   // The WebContentsImpl whose contents we display.
97   WebContentsImpl* web_contents_;
98   BrowserPluginGuest* guest_;
99   // The platform dependent view backing this WebContentsView.
100   // Calls to this WebContentsViewGuest are forwarded to |platform_view_|.
101   scoped_ptr<WebContentsViewPort> platform_view_;
102   gfx::Size size_;
103
104   // Delegate view for guest's platform view.
105   RenderViewHostDelegateView* platform_view_delegate_view_;
106
107   DISALLOW_COPY_AND_ASSIGN(WebContentsViewGuest);
108 };
109
110 }  // namespace content
111
112 #endif  // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_