Add test_runner support for new accessibility event
[chromium-blink-merge.git] / content / public / browser / render_view_host.h
blob018884c1edeb2a1ef79a40d9793226d93181d9a8
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.
54 class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
55 public:
56 // Returns the RenderViewHost given its ID and the ID of its render process.
57 // Returns nullptr if the IDs do not correspond to a live RenderViewHost.
58 static RenderViewHost* FromID(int render_process_id, int render_view_id);
60 // Downcasts from a RenderWidgetHost to a RenderViewHost. Required
61 // because RenderWidgetHost is a virtual base class.
62 static RenderViewHost* From(RenderWidgetHost* rwh);
64 ~RenderViewHost() override {}
66 // Returns the main frame for this render view.
67 virtual RenderFrameHost* GetMainFrame() = 0;
69 // Tell the render view to enable a set of javascript bindings. The argument
70 // should be a combination of values from BindingsPolicy.
71 virtual void AllowBindings(int binding_flags) = 0;
73 // Tells the renderer to clear the focused element (if any).
74 virtual void ClearFocusedElement() = 0;
76 // Returns true if the current focused element is editable.
77 virtual bool IsFocusedElementEditable() = 0;
79 // Causes the renderer to close the current page, including running its
80 // onunload event handler. A ClosePage_ACK message will be sent to the
81 // ResourceDispatcherHost when it is finished.
82 virtual void ClosePage() = 0;
84 // Copies the image at location x, y to the clipboard (if there indeed is an
85 // image at that location).
86 virtual void CopyImageAt(int x, int y) = 0;
88 // Saves the image at location x, y to the disk (if there indeed is an
89 // image at that location).
90 virtual void SaveImageAt(int x, int y) = 0;
92 // Notifies the listener that a directory enumeration is complete.
93 virtual void DirectoryEnumerationFinished(
94 int request_id,
95 const std::vector<base::FilePath>& files) = 0;
97 // Tells the renderer not to add scrollbars with height and width below a
98 // threshold.
99 virtual void DisableScrollbarsForThreshold(const gfx::Size& size) = 0;
101 // Notifies the renderer that a a drag operation that it started has ended,
102 // either in a drop or by being cancelled.
103 virtual void DragSourceEndedAt(
104 int client_x, int client_y, int screen_x, int screen_y,
105 blink::WebDragOperation operation) = 0;
107 // Notifies the renderer that we're done with the drag and drop operation.
108 // This allows the renderer to reset some state.
109 virtual void DragSourceSystemDragEnded() = 0;
111 // D&d drop target messages that get sent to WebKit.
112 virtual void DragTargetDragEnter(
113 const DropData& drop_data,
114 const gfx::Point& client_pt,
115 const gfx::Point& screen_pt,
116 blink::WebDragOperationsMask operations_allowed,
117 int key_modifiers) = 0;
118 virtual void DragTargetDragOver(
119 const gfx::Point& client_pt,
120 const gfx::Point& screen_pt,
121 blink::WebDragOperationsMask operations_allowed,
122 int key_modifiers) = 0;
123 virtual void DragTargetDragLeave() = 0;
124 virtual void DragTargetDrop(const gfx::Point& client_pt,
125 const gfx::Point& screen_pt,
126 int key_modifiers) = 0;
128 // Instructs the RenderView to automatically resize and send back updates
129 // for the new size.
130 virtual void EnableAutoResize(const gfx::Size& min_size,
131 const gfx::Size& max_size) = 0;
133 // Turns off auto-resize and gives a new size that the view should be.
134 virtual void DisableAutoResize(const gfx::Size& new_size) = 0;
136 // Instructs the RenderView to send back updates to the preferred size.
137 virtual void EnablePreferredSizeMode() = 0;
139 // Tells the renderer to perform the given action on the media player
140 // located at the given point.
141 virtual void ExecuteMediaPlayerActionAtLocation(
142 const gfx::Point& location,
143 const blink::WebMediaPlayerAction& action) = 0;
145 // Tells the renderer to perform the given action on the plugin located at
146 // the given point.
147 virtual void ExecutePluginActionAtLocation(
148 const gfx::Point& location, const blink::WebPluginAction& action) = 0;
150 // Notifies the Listener that one or more files have been chosen by the user
151 // from a file chooser dialog for the form. |permissions| is the file
152 // selection mode in which the chooser dialog was created.
153 virtual void FilesSelectedInChooser(
154 const std::vector<content::FileChooserFileInfo>& files,
155 FileChooserParams::Mode permissions) = 0;
157 virtual RenderViewHostDelegate* GetDelegate() const = 0;
159 // Returns a bitwise OR of bindings types that have been enabled for this
160 // RenderView. See BindingsPolicy for details.
161 virtual int GetEnabledBindings() const = 0;
163 virtual SiteInstance* GetSiteInstance() const = 0;
165 // Returns true if the RenderView is active and has not crashed. Virtual
166 // because it is overridden by TestRenderViewHost.
167 virtual bool IsRenderViewLive() const = 0;
169 // Notification that a move or resize renderer's containing window has
170 // started.
171 virtual void NotifyMoveOrResizeStarted() = 0;
173 // Sets a property with the given name and value on the Web UI binding object.
174 // Must call AllowWebUIBindings() on this renderer first.
175 virtual void SetWebUIProperty(const std::string& name,
176 const std::string& value) = 0;
178 // Changes the zoom level for the current main frame.
179 virtual void Zoom(PageZoom zoom) = 0;
181 // Send the renderer process the current preferences supplied by the
182 // RenderViewHostDelegate.
183 virtual void SyncRendererPrefs() = 0;
185 // Returns the current WebKit preferences. Note: WebPreferences is cached, so
186 // this lookup will be fast
187 virtual WebPreferences GetWebkitPreferences() = 0;
189 // If any state that affects the webkit preferences changed, this method must
190 // be called. This triggers recomputing preferences.
191 virtual void OnWebkitPreferencesChanged() = 0;
193 // Passes a list of Webkit preferences to the renderer.
194 virtual void UpdateWebkitPreferences(const WebPreferences& prefs) = 0;
196 // Notify the render view host to select the word around the caret.
197 virtual void SelectWordAroundCaret() = 0;
199 #if defined(OS_ANDROID)
200 // Selects and zooms to the find result nearest to the point (x,y)
201 // defined in find-in-page coordinates.
202 virtual void ActivateNearestFindResult(int request_id, float x, float y) = 0;
204 // Asks the renderer to send the rects of the current find matches.
205 virtual void RequestFindMatchRects(int current_version) = 0;
206 #endif
208 private:
209 // This interface should only be implemented inside content.
210 friend class RenderViewHostImpl;
211 RenderViewHost() {}
214 } // namespace content
216 #endif // CONTENT_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_