Popular sites on the NTP: Try to keep the ordering constant
[chromium-blink-merge.git] / content / public / browser / render_view_host.h
blob5909d286f41fde172a1777fa6976dd944886645b
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_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_
8 #include "base/callback_forward.h"
9 #include "content/common/content_export.h"
10 #include "content/public/browser/render_widget_host.h"
11 #include "content/public/common/file_chooser_params.h"
12 #include "content/public/common/page_zoom.h"
13 #include "third_party/WebKit/public/web/WebDragOperation.h"
14 #include "third_party/mojo/src/mojo/public/cpp/system/core.h"
16 class GURL;
18 namespace base {
19 class FilePath;
20 class Value;
23 namespace blink {
24 struct WebMediaPlayerAction;
25 struct WebPluginAction;
28 namespace gfx {
29 class Point;
32 namespace content {
34 class ChildProcessSecurityPolicy;
35 class RenderFrameHost;
36 class RenderViewHostDelegate;
37 class SessionStorageNamespace;
38 class SiteInstance;
39 struct DropData;
40 struct FileChooserFileInfo;
41 struct WebPreferences;
43 // A RenderViewHost is responsible for creating and talking to a RenderView
44 // object in a child process. It exposes a high level API to users, for things
45 // like loading pages, adjusting the display and other browser functionality,
46 // which it translates into IPC messages sent over the IPC channel with the
47 // RenderView. It responds to all IPC messages sent by that RenderView and
48 // cracks them, calling a delegate object back with higher level types where
49 // possible.
51 // The intent of this interface is to provide a view-agnostic communication
52 // conduit with a renderer. This is so we can build HTML views not only as
53 // WebContents (see WebContents for an example) but also as views, etc.
55 // DEPRECATED: RenderViewHost is being removed as part of the SiteIsolation
56 // project. New code should not be added here, but to either RenderFrameHost
57 // (if frame specific) or WebContents (if page specific).
59 // For context, please see https://crbug.com/467770 and
60 // http://www.chromium.org/developers/design-documents/site-isolation.
61 class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
62 public:
63 // Returns the RenderViewHost given its ID and the ID of its render process.
64 // Returns nullptr if the IDs do not correspond to a live RenderViewHost.
65 static RenderViewHost* FromID(int render_process_id, int render_view_id);
67 // Downcasts from a RenderWidgetHost to a RenderViewHost. Required
68 // because RenderWidgetHost is a virtual base class.
69 static RenderViewHost* From(RenderWidgetHost* rwh);
71 ~RenderViewHost() override {}
73 // Returns the main frame for this render view.
74 virtual RenderFrameHost* GetMainFrame() = 0;
76 // Tell the render view to enable a set of javascript bindings. The argument
77 // should be a combination of values from BindingsPolicy.
78 virtual void AllowBindings(int binding_flags) = 0;
80 // Tells the renderer to clear the focused element (if any).
81 virtual void ClearFocusedElement() = 0;
83 // Returns true if the current focused element is editable.
84 virtual bool IsFocusedElementEditable() = 0;
86 // Copies the image at location x, y to the clipboard (if there indeed is an
87 // image at that location).
88 virtual void CopyImageAt(int x, int y) = 0;
90 // Saves the image at location x, y to the disk (if there indeed is an
91 // image at that location).
92 virtual void SaveImageAt(int x, int y) = 0;
94 // Notifies the listener that a directory enumeration is complete.
95 virtual void DirectoryEnumerationFinished(
96 int request_id,
97 const std::vector<base::FilePath>& files) = 0;
99 // Tells the renderer not to add scrollbars with height and width below a
100 // threshold.
101 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) = 0;
103 // Notifies the renderer that a a drag operation that it started has ended,
104 // either in a drop or by being cancelled.
105 virtual void DragSourceEndedAt(
106 int client_x, int client_y, int screen_x, int screen_y,
107 blink::WebDragOperation operation) = 0;
109 // Notifies the renderer that we're done with the drag and drop operation.
110 // This allows the renderer to reset some state.
111 virtual void DragSourceSystemDragEnded() = 0;
113 // D&d drop target messages that get sent to WebKit.
114 virtual void DragTargetDragEnter(
115 const DropData& drop_data,
116 const gfx::Point& client_pt,
117 const gfx::Point& screen_pt,
118 blink::WebDragOperationsMask operations_allowed,
119 int key_modifiers) = 0;
120 virtual void DragTargetDragOver(
121 const gfx::Point& client_pt,
122 const gfx::Point& screen_pt,
123 blink::WebDragOperationsMask operations_allowed,
124 int key_modifiers) = 0;
125 virtual void DragTargetDragLeave() = 0;
126 virtual void DragTargetDrop(const gfx::Point& client_pt,
127 const gfx::Point& screen_pt,
128 int key_modifiers) = 0;
130 // Instructs the RenderView to automatically resize and send back updates
131 // for the new size.
132 virtual void EnableAutoResize(const gfx::Size& min_size,
133 const gfx::Size& max_size) = 0;
135 // Turns off auto-resize and gives a new size that the view should be.
136 virtual void DisableAutoResize(const gfx::Size& new_size) = 0;
138 // Instructs the RenderView to send back updates to the preferred size.
139 virtual void EnablePreferredSizeMode() = 0;
141 // Tells the renderer to perform the given action on the media player
142 // located at the given point.
143 virtual void ExecuteMediaPlayerActionAtLocation(
144 const gfx::Point& location,
145 const blink::WebMediaPlayerAction& action) = 0;
147 // Tells the renderer to perform the given action on the plugin located at
148 // the given point.
149 virtual void ExecutePluginActionAtLocation(
150 const gfx::Point& location, const blink::WebPluginAction& action) = 0;
152 // Notifies the Listener that one or more files have been chosen by the user
153 // from a file chooser dialog for the form. |permissions| is the file
154 // selection mode in which the chooser dialog was created.
155 virtual void FilesSelectedInChooser(
156 const std::vector<content::FileChooserFileInfo>& files,
157 FileChooserParams::Mode permissions) = 0;
159 virtual RenderViewHostDelegate* GetDelegate() const = 0;
161 // Returns a bitwise OR of bindings types that have been enabled for this
162 // RenderView. See BindingsPolicy for details.
163 virtual int GetEnabledBindings() const = 0;
165 virtual SiteInstance* GetSiteInstance() const = 0;
167 // Returns true if the RenderView is active and has not crashed.
168 virtual bool IsRenderViewLive() const = 0;
170 // Notification that a move or resize renderer's containing window has
171 // started.
172 virtual void NotifyMoveOrResizeStarted() = 0;
174 // Sets a property with the given name and value on the Web UI binding object.
175 // Must call AllowWebUIBindings() on this renderer first.
176 virtual void SetWebUIProperty(const std::string& name,
177 const std::string& value) = 0;
179 // Changes the zoom level for the current main frame.
180 virtual void Zoom(PageZoom zoom) = 0;
182 // Send the renderer process the current preferences supplied by the
183 // RenderViewHostDelegate.
184 virtual void SyncRendererPrefs() = 0;
186 // Returns the current WebKit preferences. Note: WebPreferences is cached, so
187 // this lookup will be fast
188 virtual WebPreferences GetWebkitPreferences() = 0;
190 // If any state that affects the webkit preferences changed, this method must
191 // be called. This triggers recomputing preferences.
192 virtual void OnWebkitPreferencesChanged() = 0;
194 // Passes a list of Webkit preferences to the renderer.
195 virtual void UpdateWebkitPreferences(const WebPreferences& prefs) = 0;
197 // Notify the render view host to select the word around the caret.
198 virtual void SelectWordAroundCaret() = 0;
200 #if defined(OS_ANDROID)
201 // Selects and zooms to the find result nearest to the point (x,y)
202 // defined in find-in-page coordinates.
203 virtual void ActivateNearestFindResult(int request_id, float x, float y) = 0;
205 // Asks the renderer to send the rects of the current find matches.
206 virtual void RequestFindMatchRects(int current_version) = 0;
207 #endif
209 private:
210 // This interface should only be implemented inside content.
211 friend class RenderViewHostImpl;
212 RenderViewHost() {}
215 } // namespace content
217 #endif // CONTENT_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_