• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 class SkBitmap;
17 
18 namespace gfx {
19 class ImageSkia;
20 class Rect;
21 class Vector2d;
22 }
23 
24 namespace ui {
25 class GestureEvent;
26 class MouseEvent;
27 }
28 
29 namespace content {
30 class RenderFrameHost;
31 struct ContextMenuParams;
32 struct DropData;
33 struct 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.
38 class 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.
ShowContextMenu(RenderFrameHost * render_frame_host,const ContextMenuParams & 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.
StartDragging(const DropData & drop_data,blink::WebDragOperationsMask allowed_ops,const gfx::ImageSkia & image,const gfx::Vector2d & image_offset,const DragEventSourceInfo & event_info)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.)
UpdateDragCursor(blink::WebDragOperation operation)58   virtual void UpdateDragCursor(blink::WebDragOperation operation) {}
59 
60   // Notification that view for this delegate got the focus.
GotFocus()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.
TakeFocus(bool reverse)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.
ShowPopupMenu(RenderFrameHost * render_frame_host,const gfx::Rect & bounds,int item_height,double item_font_size,int selected_item,const std::vector<MenuItem> & items,bool right_aligned,bool allow_multiple_selection)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().
HidePopupMenu()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.
ShowDisambiguationPopup(const gfx::Rect & target_rect,const SkBitmap & zoomed_bitmap,const base::Callback<void (ui::GestureEvent *)> & gesture_cb,const base::Callback<void (ui::MouseEvent *)> & mouse_cb)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.
HideDisambiguationPopup()98   virtual void HideDisambiguationPopup() {}
99 #endif
100 
101  protected:
~RenderViewHostDelegateView()102   virtual ~RenderViewHostDelegateView() {}
103 };
104 
105 }  // namespace content
106 
107 #endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_VIEW_H_
108