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/renderer_host/render_view_host_delegate_view.h"
10 #include "content/browser/web_contents/web_contents_view.h"
11 #include "content/public/browser/web_contents_view_delegate.h"
12 #include "content/public/common/context_menu_params.h"
13 #include "ui/gfx/geometry/rect_f.h"
16 class ContentViewCoreImpl
;
17 class WebContentsImpl
;
19 // Android-specific implementation of the WebContentsView.
20 class WebContentsViewAndroid
: public WebContentsView
,
21 public RenderViewHostDelegateView
{
23 WebContentsViewAndroid(WebContentsImpl
* web_contents
,
24 WebContentsViewDelegate
* delegate
);
25 ~WebContentsViewAndroid() override
;
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 // WebContentsView implementation --------------------------------------------
33 gfx::NativeView
GetNativeView() const override
;
34 gfx::NativeView
GetContentNativeView() const override
;
35 gfx::NativeWindow
GetTopLevelNativeWindow() const override
;
36 void GetContainerBounds(gfx::Rect
* out
) const override
;
37 void SizeContents(const gfx::Size
& size
) override
;
38 void Focus() override
;
39 void SetInitialFocus() override
;
40 void StoreFocus() override
;
41 void RestoreFocus() override
;
42 DropData
* GetDropData() const override
;
43 gfx::Rect
GetViewBounds() const override
;
44 void CreateView(const gfx::Size
& initial_size
,
45 gfx::NativeView context
) override
;
46 RenderWidgetHostViewBase
* CreateViewForWidget(
47 RenderWidgetHost
* render_widget_host
,
48 bool is_guest_view_hack
) override
;
49 RenderWidgetHostViewBase
* CreateViewForPopupWidget(
50 RenderWidgetHost
* render_widget_host
) override
;
51 void SetPageTitle(const base::string16
& title
) override
;
52 void RenderViewCreated(RenderViewHost
* host
) override
;
53 void RenderViewSwappedIn(RenderViewHost
* host
) override
;
54 void SetOverscrollControllerEnabled(bool enabled
) override
;
56 // Backend implementation of RenderViewHostDelegateView.
57 void ShowContextMenu(RenderFrameHost
* render_frame_host
,
58 const ContextMenuParams
& params
) override
;
59 void ShowPopupMenu(RenderFrameHost
* render_frame_host
,
60 const gfx::Rect
& bounds
,
62 double item_font_size
,
64 const std::vector
<MenuItem
>& items
,
66 bool allow_multiple_selection
) override
;
67 void HidePopupMenu() override
;
68 void StartDragging(const DropData
& drop_data
,
69 blink::WebDragOperationsMask allowed_ops
,
70 const gfx::ImageSkia
& image
,
71 const gfx::Vector2d
& image_offset
,
72 const DragEventSourceInfo
& event_info
) override
;
73 void UpdateDragCursor(blink::WebDragOperation operation
) override
;
74 void GotFocus() override
;
75 void TakeFocus(bool reverse
) override
;
78 // The WebContents whose contents we display.
79 WebContentsImpl
* web_contents_
;
81 // ContentViewCoreImpl is our interface to the view system.
82 ContentViewCoreImpl
* content_view_core_
;
84 // Interface for extensions to WebContentsView. Used to show the context menu.
85 scoped_ptr
<WebContentsViewDelegate
> delegate_
;
87 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAndroid
);
90 } // namespace content
92 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_