OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_CAST_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_CAST_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/common/content_export.h" |
10 #include "content/port/browser/render_view_host_delegate_view.h" | 10 #include "content/port/browser/render_view_host_delegate_view.h" |
11 #include "content/port/browser/web_contents_view_port.h" | 11 #include "content/port/browser/web_contents_view_port.h" |
12 #include "content/public/browser/web_contents_view_delegate.h" | 12 |
13 #include "content/public/common/context_menu_params.h" | 13 // Chromecast porting notes: This file was completed derived from the GTK |
14 #include "ui/gfx/rect_f.h" | 14 // version. |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class ContentViewCoreImpl; | |
18 | 17 |
19 // Android-specific implementation of the WebContentsView. | 18 class WebContents; |
20 class WebContentsViewAndroid : public WebContentsViewPort, | 19 class WebContentsImpl; |
21 public RenderViewHostDelegateView { | 20 class WebContentsViewDelegate; |
| 21 |
| 22 class CONTENT_EXPORT WebContentsViewCast |
| 23 : public WebContentsViewPort, |
| 24 public RenderViewHostDelegateView { |
22 public: | 25 public: |
23 WebContentsViewAndroid(WebContentsImpl* web_contents, | 26 // The corresponding WebContentsImpl is passed in the constructor, and manages |
24 WebContentsViewDelegate* delegate); | 27 // our lifetime. This doesn't need to be the case, but is this way currently |
25 virtual ~WebContentsViewAndroid(); | 28 // because that's what was easiest when they were split. We optionally take |
| 29 // |wrapper| which creates an intermediary widget layer for features from the |
| 30 // Embedding layer that lives with the WebContentsView. |
| 31 explicit WebContentsViewCast(WebContentsImpl* web_contents, |
| 32 WebContentsViewDelegate* delegate); |
| 33 virtual ~WebContentsViewCast(); |
26 | 34 |
27 // Sets the interface to the view system. ContentViewCoreImpl is owned | 35 WebContentsViewDelegate* delegate() const { return delegate_.get(); } |
28 // by its Java ContentViewCore counterpart, whose lifetime is managed | 36 WebContents* web_contents(); |
29 // by the UI frontend. | |
30 void SetContentViewCore(ContentViewCoreImpl* content_view_core); | |
31 | 37 |
32 // WebContentsView implementation -------------------------------------------- | 38 // WebContentsView implementation -------------------------------------------- |
| 39 |
33 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 40 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
34 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; | 41 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; |
35 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; | 42 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; |
36 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; | 43 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; |
37 virtual void OnTabCrashed(base::TerminationStatus status, | 44 virtual void OnTabCrashed(base::TerminationStatus status, |
38 int error_code) OVERRIDE; | 45 int error_code) OVERRIDE; |
39 virtual void SizeContents(const gfx::Size& size) OVERRIDE; | 46 virtual void SizeContents(const gfx::Size& size) OVERRIDE; |
40 virtual void Focus() OVERRIDE; | 47 virtual void Focus() OVERRIDE; |
41 virtual void SetInitialFocus() OVERRIDE; | 48 virtual void SetInitialFocus() OVERRIDE; |
42 virtual void StoreFocus() OVERRIDE; | 49 virtual void StoreFocus() OVERRIDE; |
43 virtual void RestoreFocus() OVERRIDE; | 50 virtual void RestoreFocus() OVERRIDE; |
44 virtual DropData* GetDropData() const OVERRIDE; | 51 virtual DropData* GetDropData() const OVERRIDE; |
45 virtual gfx::Rect GetViewBounds() const OVERRIDE; | 52 virtual gfx::Rect GetViewBounds() const OVERRIDE; |
46 | 53 |
47 // WebContentsViewPort implementation ---------------------------------------- | 54 // WebContentsViewPort implementation ---------------------------------------- |
48 virtual void CreateView( | 55 |
49 const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; | 56 virtual void CreateView(const gfx::Size& initial_size, |
| 57 gfx::NativeView context) OVERRIDE; |
50 virtual RenderWidgetHostView* CreateViewForWidget( | 58 virtual RenderWidgetHostView* CreateViewForWidget( |
51 RenderWidgetHost* render_widget_host) OVERRIDE; | 59 RenderWidgetHost* render_widget_host) OVERRIDE; |
52 virtual RenderWidgetHostView* CreateViewForPopupWidget( | 60 virtual RenderWidgetHostView* CreateViewForPopupWidget( |
53 RenderWidgetHost* render_widget_host) OVERRIDE; | 61 RenderWidgetHost* render_widget_host) OVERRIDE; |
54 virtual void SetPageTitle(const base::string16& title) OVERRIDE; | 62 virtual void SetPageTitle(const base::string16& title) OVERRIDE; |
55 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; | 63 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; |
56 virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; | 64 virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; |
57 virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; | 65 virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; |
58 | 66 |
59 // Backend implementation of RenderViewHostDelegateView. | 67 // Backend implementation of RenderViewHostDelegateView. |
60 virtual void ShowContextMenu(RenderFrameHost* render_frame_host, | 68 virtual void ShowContextMenu(RenderFrameHost* render_frame_host, |
61 const ContextMenuParams& params) OVERRIDE; | 69 const ContextMenuParams& params) OVERRIDE; |
62 virtual void ShowPopupMenu(const gfx::Rect& bounds, | 70 virtual void ShowPopupMenu(const gfx::Rect& bounds, |
63 int item_height, | 71 int item_height, |
64 double item_font_size, | 72 double item_font_size, |
65 int selected_item, | 73 int selected_item, |
66 const std::vector<MenuItem>& items, | 74 const std::vector<MenuItem>& items, |
67 bool right_aligned, | 75 bool right_aligned, |
68 bool allow_multiple_selection) OVERRIDE; | 76 bool allow_multiple_selection) OVERRIDE; |
69 virtual void HidePopupMenu() OVERRIDE; | |
70 virtual void StartDragging(const DropData& drop_data, | 77 virtual void StartDragging(const DropData& drop_data, |
71 blink::WebDragOperationsMask allowed_ops, | 78 blink::WebDragOperationsMask allowed_ops, |
72 const gfx::ImageSkia& image, | 79 const gfx::ImageSkia& image, |
73 const gfx::Vector2d& image_offset, | 80 const gfx::Vector2d& image_offset, |
74 const DragEventSourceInfo& event_info) OVERRIDE; | 81 const DragEventSourceInfo& event_info) OVERRIDE; |
75 virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE; | 82 virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE; |
76 virtual void GotFocus() OVERRIDE; | 83 virtual void GotFocus() OVERRIDE; |
77 virtual void TakeFocus(bool reverse) OVERRIDE; | 84 virtual void TakeFocus(bool reverse) OVERRIDE; |
78 | 85 |
79 private: | 86 private: |
80 // The WebContents whose contents we display. | 87 // The WebContentsImpl whose contents we display. |
81 WebContentsImpl* web_contents_; | 88 WebContentsImpl* web_contents_; |
82 | 89 |
83 // ContentViewCoreImpl is our interface to the view system. | |
84 ContentViewCoreImpl* content_view_core_; | |
85 | |
86 // Interface for extensions to WebContentsView. Used to show the context menu. | |
87 scoped_ptr<WebContentsViewDelegate> delegate_; | 90 scoped_ptr<WebContentsViewDelegate> delegate_; |
88 | 91 |
89 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAndroid); | 92 // The size we want the web contents view to be. |
| 93 gfx::Size requested_size_; |
| 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(WebContentsViewCast); |
90 }; | 96 }; |
91 | 97 |
92 } // namespace content | 98 } // namespace content |
93 | 99 |
94 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ | 100 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_CAST_H_ |
OLD | NEW |