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