Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / render_view_host.h
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_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_
7
8 #include <list>
9
10 #include "base/callback_forward.h"
11 #include "content/common/content_export.h"
12 #include "content/public/browser/render_widget_host.h"
13 #include "content/public/common/file_chooser_params.h"
14 #include "content/public/common/page_zoom.h"
15 #include "mojo/public/cpp/system/core.h"
16 #include "third_party/WebKit/public/web/WebDragOperation.h"
17
18 class GURL;
19
20 namespace base {
21 class FilePath;
22 class Value;
23 }
24
25 namespace blink {
26 struct WebMediaPlayerAction;
27 struct WebPluginAction;
28 }
29
30 namespace gfx {
31 class Point;
32 }
33
34 namespace media {
35 class AudioOutputController;
36 }
37
38 namespace content {
39
40 class ChildProcessSecurityPolicy;
41 class RenderFrameHost;
42 class RenderViewHostDelegate;
43 class SessionStorageNamespace;
44 class SiteInstance;
45 struct DropData;
46 struct FileChooserFileInfo;
47 struct WebPreferences;
48
49 // A RenderViewHost is responsible for creating and talking to a RenderView
50 // object in a child process. It exposes a high level API to users, for things
51 // like loading pages, adjusting the display and other browser functionality,
52 // which it translates into IPC messages sent over the IPC channel with the
53 // RenderView. It responds to all IPC messages sent by that RenderView and
54 // cracks them, calling a delegate object back with higher level types where
55 // possible.
56 //
57 // The intent of this interface is to provide a view-agnostic communication
58 // conduit with a renderer. This is so we can build HTML views not only as
59 // WebContents (see WebContents for an example) but also as views, etc.
60 class CONTENT_EXPORT RenderViewHost : virtual public RenderWidgetHost {
61  public:
62   // Returns the RenderViewHost given its ID and the ID of its render process.
63   // Returns NULL if the IDs do not correspond to a live RenderViewHost.
64   static RenderViewHost* FromID(int render_process_id, int render_view_id);
65
66   // Downcasts from a RenderWidgetHost to a RenderViewHost.  Required
67   // because RenderWidgetHost is a virtual base class.
68   static RenderViewHost* From(RenderWidgetHost* rwh);
69
70   ~RenderViewHost() override {}
71
72   // Returns the main frame for this render view.
73   virtual RenderFrameHost* GetMainFrame() = 0;
74
75   // Tell the render view to enable a set of javascript bindings. The argument
76   // should be a combination of values from BindingsPolicy.
77   virtual void AllowBindings(int binding_flags) = 0;
78
79   // Tells the renderer to clear the focused element (if any).
80   virtual void ClearFocusedElement() = 0;
81
82   // Returns true if the current focused element is editable.
83   virtual bool IsFocusedElementEditable() = 0;
84
85   // Causes the renderer to close the current page, including running its
86   // onunload event handler.  A ClosePage_ACK message will be sent to the
87   // ResourceDispatcherHost when it is finished.
88   virtual void ClosePage() = 0;
89
90   // Copies the image at location x, y to the clipboard (if there indeed is an
91   // image at that location).
92   virtual void CopyImageAt(int x, int y) = 0;
93
94   // Saves the image at location x, y to the disk (if there indeed is an
95   // image at that location).
96   virtual void SaveImageAt(int x, int y) = 0;
97
98   // Notifies the listener that a directory enumeration is complete.
99   virtual void DirectoryEnumerationFinished(
100       int request_id,
101       const std::vector<base::FilePath>& files) = 0;
102
103   // Tells the renderer not to add scrollbars with height and width below a
104   // threshold.
105   virtual void DisableScrollbarsForThreshold(const gfx::Size& size) = 0;
106
107   // Notifies the renderer that a a drag operation that it started has ended,
108   // either in a drop or by being cancelled.
109   virtual void DragSourceEndedAt(
110       int client_x, int client_y, int screen_x, int screen_y,
111       blink::WebDragOperation operation) = 0;
112
113   // Notifies the renderer that we're done with the drag and drop operation.
114   // This allows the renderer to reset some state.
115   virtual void DragSourceSystemDragEnded() = 0;
116
117   // D&d drop target messages that get sent to WebKit.
118   virtual void DragTargetDragEnter(
119       const DropData& drop_data,
120       const gfx::Point& client_pt,
121       const gfx::Point& screen_pt,
122       blink::WebDragOperationsMask operations_allowed,
123       int key_modifiers) = 0;
124   virtual void DragTargetDragOver(
125       const gfx::Point& client_pt,
126       const gfx::Point& screen_pt,
127       blink::WebDragOperationsMask operations_allowed,
128       int key_modifiers) = 0;
129   virtual void DragTargetDragLeave() = 0;
130   virtual void DragTargetDrop(const gfx::Point& client_pt,
131                               const gfx::Point& screen_pt,
132                               int key_modifiers) = 0;
133
134   // Instructs the RenderView to automatically resize and send back updates
135   // for the new size.
136   virtual void EnableAutoResize(const gfx::Size& min_size,
137                                 const gfx::Size& max_size) = 0;
138
139   // Turns off auto-resize and gives a new size that the view should be.
140   virtual void DisableAutoResize(const gfx::Size& new_size) = 0;
141
142   // Instructs the RenderView to send back updates to the preferred size.
143   virtual void EnablePreferredSizeMode() = 0;
144
145   // Tells the renderer to perform the given action on the media player
146   // located at the given point.
147   virtual void ExecuteMediaPlayerActionAtLocation(
148       const gfx::Point& location,
149       const blink::WebMediaPlayerAction& action) = 0;
150
151   // Tells the renderer to perform the given action on the plugin located at
152   // the given point.
153   virtual void ExecutePluginActionAtLocation(
154       const gfx::Point& location, const blink::WebPluginAction& action) = 0;
155
156   // Asks the renderer to exit fullscreen
157   virtual void ExitFullscreen() = 0;
158
159   // Notifies the Listener that one or more files have been chosen by the user
160   // from a file chooser dialog for the form. |permissions| is the file
161   // selection mode in which the chooser dialog was created.
162   virtual void FilesSelectedInChooser(
163       const std::vector<content::FileChooserFileInfo>& files,
164       FileChooserParams::Mode permissions) = 0;
165
166   virtual RenderViewHostDelegate* GetDelegate() const = 0;
167
168   // Returns a bitwise OR of bindings types that have been enabled for this
169   // RenderView. See BindingsPolicy for details.
170   virtual int GetEnabledBindings() const = 0;
171
172   virtual SiteInstance* GetSiteInstance() const = 0;
173
174   // Returns true if the RenderView is active and has not crashed. Virtual
175   // because it is overridden by TestRenderViewHost.
176   virtual bool IsRenderViewLive() const = 0;
177
178   // Notification that a move or resize renderer's containing window has
179   // started.
180   virtual void NotifyMoveOrResizeStarted() = 0;
181
182   // Sets a property with the given name and value on the Web UI binding object.
183   // Must call AllowWebUIBindings() on this renderer first.
184   virtual void SetWebUIProperty(const std::string& name,
185                                 const std::string& value) = 0;
186
187   // Changes the zoom level for the current main frame.
188   virtual void Zoom(PageZoom zoom) = 0;
189
190   // Send the renderer process the current preferences supplied by the
191   // RenderViewHostDelegate.
192   virtual void SyncRendererPrefs() = 0;
193
194   // Returns the current WebKit preferences. Note: WebPreferences is cached, so
195   // this lookup will be fast
196   virtual WebPreferences GetWebkitPreferences() = 0;
197
198   // If any state that affects the webkit preferences changed, this method must
199   // be called. This triggers recomputing preferences.
200   virtual void OnWebkitPreferencesChanged() = 0;
201
202   // Passes a list of Webkit preferences to the renderer.
203   virtual void UpdateWebkitPreferences(const WebPreferences& prefs) = 0;
204
205   // Retrieves the list of AudioOutputController objects associated
206   // with this object and passes it to the callback you specify, on
207   // the same thread on which you called the method.
208   typedef std::list<scoped_refptr<media::AudioOutputController> >
209       AudioOutputControllerList;
210   typedef base::Callback<void(const AudioOutputControllerList&)>
211       GetAudioOutputControllersCallback;
212   virtual void GetAudioOutputControllers(
213       const GetAudioOutputControllersCallback& callback) const = 0;
214
215   // Notify the render view host to select the word around the caret.
216   virtual void SelectWordAroundCaret() = 0;
217
218 #if defined(OS_ANDROID)
219   // Selects and zooms to the find result nearest to the point (x,y)
220   // defined in find-in-page coordinates.
221   virtual void ActivateNearestFindResult(int request_id, float x, float y) = 0;
222
223   // Asks the renderer to send the rects of the current find matches.
224   virtual void RequestFindMatchRects(int current_version) = 0;
225 #endif
226
227  private:
228   // This interface should only be implemented inside content.
229   friend class RenderViewHostImpl;
230   RenderViewHost() {}
231 };
232
233 }  // namespace content
234
235 #endif  // CONTENT_PUBLIC_BROWSER_RENDER_VIEW_HOST_H_