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_ANDROID_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/port/browser/render_view_host_delegate_view.h"
11 #include "content/port/browser/web_contents_view_port.h"
12 #include "content/public/browser/web_contents_view_delegate.h"
13 #include "content/public/common/context_menu_params.h"
14 #include "ui/gfx/rect_f.h"
17 class ContentViewCoreImpl;
19 // Android-specific implementation of the WebContentsView.
20 class WebContentsViewAndroid : public WebContentsViewPort,
21 public RenderViewHostDelegateView {
23 WebContentsViewAndroid(WebContentsImpl* web_contents,
24 WebContentsViewDelegate* delegate);
25 virtual ~WebContentsViewAndroid();
27 // Sets the interface to the view system. ContentViewCoreImpl is owned
28 // by its Java ContentViewCore counterpart, whose lifetime is managed
29 // by the UI frontend.
30 void SetContentViewCore(ContentViewCoreImpl* content_view_core);
32 #if defined(VIDEO_HOLE)
33 void NotifyExternalSurface(int player_id,
35 const gfx::RectF& rect);
36 #endif // defined(VIDEO_HOLE)
38 // WebContentsView implementation --------------------------------------------
39 virtual gfx::NativeView GetNativeView() const OVERRIDE;
40 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
41 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
42 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
43 virtual void OnTabCrashed(base::TerminationStatus status,
44 int error_code) OVERRIDE;
45 virtual void SizeContents(const gfx::Size& size) OVERRIDE;
46 virtual void Focus() OVERRIDE;
47 virtual void SetInitialFocus() OVERRIDE;
48 virtual void StoreFocus() OVERRIDE;
49 virtual void RestoreFocus() OVERRIDE;
50 virtual DropData* GetDropData() const OVERRIDE;
51 virtual gfx::Rect GetViewBounds() const OVERRIDE;
53 // WebContentsViewPort implementation ----------------------------------------
54 virtual void CreateView(
55 const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
56 virtual RenderWidgetHostView* CreateViewForWidget(
57 RenderWidgetHost* render_widget_host) OVERRIDE;
58 virtual RenderWidgetHostView* CreateViewForPopupWidget(
59 RenderWidgetHost* render_widget_host) OVERRIDE;
60 virtual void SetPageTitle(const base::string16& title) OVERRIDE;
61 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
62 virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE;
63 virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE;
65 // Backend implementation of RenderViewHostDelegateView.
66 virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
67 const ContextMenuParams& params) OVERRIDE;
68 virtual void ShowPopupMenu(const gfx::Rect& bounds,
70 double item_font_size,
72 const std::vector<MenuItem>& items,
74 bool allow_multiple_selection) OVERRIDE;
75 virtual 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 virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE;
81 virtual void GotFocus() OVERRIDE;
82 virtual void TakeFocus(bool reverse) OVERRIDE;
85 // The WebContents whose contents we display.
86 WebContentsImpl* web_contents_;
88 // ContentViewCoreImpl is our interface to the view system.
89 ContentViewCoreImpl* content_view_core_;
91 // Interface for extensions to WebContentsView. Used to show the context menu.
92 scoped_ptr<WebContentsViewDelegate> delegate_;
94 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAndroid);
97 } // namespace content
99 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_