Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / public / browser / render_view_host.h
blob05bac140f0da4ec38253b40b86ad0babf7929339
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 // Causes the renderer to close the current page, including running its
87 // onunload event handler. A ClosePage_ACK message will be sent to the
88 // ResourceDispatcherHost when it is finished.
89 virtual void ClosePage() = 0;
91 // Copies the image at location x, y to the clipboard (if there indeed is an
92 // image at that location).
93 virtual void CopyImageAt(int x, int y) = 0;
95 // Saves the image at location x, y to the disk (if there indeed is an
96 // image at that location).
97 virtual void SaveImageAt(int x, int y) = 0;
99 // Notifies the listener that a directory enumeration is complete.
100 virtual void DirectoryEnumerationFinished(
101 int request_id,
102 const std::vector<base::FilePath>& files) = 0;
104 // Tells the renderer not to add scrollbars with height and width below a
105 // threshold.
106 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) = 0;
108 // Notifies the renderer that a a drag operation that it started has ended,
109 // either in a drop or by being cancelled.
110 virtual void DragSourceEndedAt(
111 int client_x, int client_y, int screen_x, int screen_y,
112 blink::WebDragOperation operation) = 0;
114 // Notifies the renderer that we're done with the drag and drop operation.
115 // This allows the renderer to reset some state.
116 virtual void DragSourceSystemDragEnded() = 0;
118 // D&d drop target messages that get sent to WebKit.
119 virtual void DragTargetDragEnter(
120 const DropData& drop_data,
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 DragTargetDragOver(
126 const gfx::Point& client_pt,
127 const gfx::Point& screen_pt,
128 blink::WebDragOperationsMask operations_allowed,
129 int key_modifiers) = 0;
130 virtual void DragTargetDragLeave() = 0;
131 virtual void DragTargetDrop(const gfx::Point& client_pt,
132 const gfx::Point& screen_pt,
133 int key_modifiers) = 0;
135 // Instructs the RenderView to automatically resize and send back updates
136 // for the new size.
137 virtual void EnableAutoResize(const gfx::Size& min_size,
138 const gfx::Size& max_size) = 0;
140 // Turns off auto-resize and gives a new size that the view should be.
141 virtual void DisableAutoResize(const gfx::Size& new_size) = 0;
143 // Instructs the RenderView to send back updates to the preferred size.
144 virtual void EnablePreferredSizeMode() = 0;
146 // Tells the renderer to perform the given action on the media player
147 // located at the given point.
148 virtual void ExecuteMediaPlayerActionAtLocation(
149 const gfx::Point& location,
150 const blink::WebMediaPlayerAction& action) = 0;
152 // Tells the renderer to perform the given action on the plugin located at
153 // the given point.
154 virtual void ExecutePluginActionAtLocation(
155 const gfx::Point& location, const blink::WebPluginAction& action) = 0;
157 // Notifies the Listener that one or more files have been chosen by the user
158 // from a file chooser dialog for the form. |permissions| is the file
159 // selection mode in which the chooser dialog was created.
160 virtual void FilesSelectedInChooser(
161 const std::vector<content::FileChooserFileInfo>& files,
162 FileChooserParams::Mode permissions) = 0;
164 virtual RenderViewHostDelegate* GetDelegate() const = 0;
166 // Returns a bitwise OR of bindings types that have been enabled for this
167 // RenderView. See BindingsPolicy for details.
168 virtual int GetEnabledBindings() const = 0;
170 virtual SiteInstance* GetSiteInstance() const = 0;
172 // Returns true if the RenderView is active and has not crashed.
173 virtual bool IsRenderViewLive() const = 0;
175 // Notification that a move or resize renderer's containing window has
176 // started.
177 virtual void NotifyMoveOrResizeStarted() = 0;
179 // Sets a property with the given name and value on the Web UI binding object.
180 // Must call AllowWebUIBindings() on this renderer first.
181 virtual void SetWebUIProperty(const std::string& name,
182 const std::string& value) = 0;
184 // Changes the zoom level for the current main frame.
185 virtual void Zoom(PageZoom zoom) = 0;
187 // Send the renderer process the current preferences supplied by the
188 // RenderViewHostDelegate.
189 virtual void SyncRendererPrefs() = 0;
191 // Returns the current WebKit preferences. Note: WebPreferences is cached, so
192 // this lookup will be fast
193 virtual WebPreferences GetWebkitPreferences() = 0;
195 // If any state that affects the webkit preferences changed, this method must
196 // be called. This triggers recomputing preferences.
197 virtual void OnWebkitPreferencesChanged() = 0;
199 // Passes a list of Webkit preferences to the renderer.
200 virtual void UpdateWebkitPreferences(const WebPreferences& prefs) = 0;
202 // Notify the render view host to select the word around the caret.
203 virtual void SelectWordAroundCaret() = 0;
205 #if defined(OS_ANDROID)
206 // Selects and zooms to the find result nearest to the point (x,y)
207 // defined in find-in-page coordinates.
208 virtual void ActivateNearestFindResult(int request_id, float x, float y) = 0;
210 // Asks the renderer to send the rects of the current find matches.
211 virtual void RequestFindMatchRects(int current_version) = 0;
212 #endif
214 private:
215 // This interface should only be implemented inside content.
216 friend class RenderViewHostImpl;
217 RenderViewHost() {}
220 } // namespace content
222 #endif // CONTENT_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_