render_view_host_delegate_view.h revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_VIEW_H_ 6#define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_VIEW_H_ 7 8#include <vector> 9 10#include "base/basictypes.h" 11#include "base/callback.h" 12#include "content/common/content_export.h" 13#include "content/common/drag_event_source_info.h" 14#include "third_party/WebKit/public/web/WebDragOperation.h" 15 16class SkBitmap; 17 18namespace gfx { 19class ImageSkia; 20class Rect; 21class Vector2d; 22} 23 24namespace ui { 25class GestureEvent; 26class MouseEvent; 27} 28 29namespace content { 30class RenderFrameHost; 31struct ContextMenuParams; 32struct DropData; 33struct MenuItem; 34 35// This class provides a way for the RenderViewHost to reach out to its 36// delegate's view. It only needs to be implemented by embedders if they don't 37// use the default WebContentsView implementations. 38class CONTENT_EXPORT RenderViewHostDelegateView { 39 public: 40 // A context menu should be shown, to be built using the context information 41 // provided in the supplied params. 42 virtual void ShowContextMenu(RenderFrameHost* render_frame_host, 43 const ContextMenuParams& params) {} 44 45 // The user started dragging content of the specified type within the 46 // RenderView. Contextual information about the dragged content is supplied 47 // by DropData. If the delegate's view cannot start the drag for /any/ 48 // reason, it must inform the renderer that the drag has ended; otherwise, 49 // this results in bugs like http://crbug.com/157134. 50 virtual void StartDragging(const DropData& drop_data, 51 blink::WebDragOperationsMask allowed_ops, 52 const gfx::ImageSkia& image, 53 const gfx::Vector2d& image_offset, 54 const DragEventSourceInfo& event_info) {} 55 56 // The page wants to update the mouse cursor during a drag & drop operation. 57 // |operation| describes the current operation (none, move, copy, link.) 58 virtual void UpdateDragCursor(blink::WebDragOperation operation) {} 59 60 // Notification that view for this delegate got the focus. 61 virtual void GotFocus() {} 62 63 // Callback to inform the browser that the page is returning the focus to 64 // the browser's chrome. If reverse is true, it means the focus was 65 // retrieved by doing a Shift-Tab. 66 virtual void TakeFocus(bool reverse) {} 67 68#if defined(OS_MACOSX) || defined(OS_ANDROID) 69 // Shows a popup menu with the specified items. 70 // This method should call RenderFrameHost::DidSelectPopupMenuItem[s]() or 71 // RenderFrameHost::DidCancelPopupMenu() based on the user action. 72 virtual void ShowPopupMenu(RenderFrameHost* render_frame_host, 73 const gfx::Rect& bounds, 74 int item_height, 75 double item_font_size, 76 int selected_item, 77 const std::vector<MenuItem>& items, 78 bool right_aligned, 79 bool allow_multiple_selection) {}; 80 81 // Hides a popup menu opened by ShowPopupMenu(). 82 virtual void HidePopupMenu() {}; 83#endif 84 85#if defined(TOOLKIT_VIEWS) || defined(USE_AURA) 86 // Shows a Link Disambiguation Popup. |target_rect| is the area the user 87 // touched that resulted in ambiguity, in DIPs in the host's coordinate 88 // system, |zoomed_bitmap| is an enlarged image of that |target_rect|, and 89 // |callback| is for forwarding on to the original scale web content. 90 virtual void ShowDisambiguationPopup( 91 const gfx::Rect& target_rect, 92 const SkBitmap& zoomed_bitmap, 93 const base::Callback<void(ui::GestureEvent*)>& gesture_cb, 94 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) {} 95 96 // Hides the Link Disambiguation Popup, if it was showing, otherwise does 97 // nothing. 98 virtual void HideDisambiguationPopup() {} 99#endif 100 101 protected: 102 virtual ~RenderViewHostDelegateView() {} 103}; 104 105} // namespace content 106 107#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_VIEW_H_ 108