cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / browser / renderer_host / render_view_host_delegate.h
blob904598d3a71442e813d371f91f2c7960e5b49e6f
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_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/process/kill.h"
13 #include "base/strings/string16.h"
14 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
15 #include "content/common/content_export.h"
16 #include "net/base/load_states.h"
17 #include "third_party/WebKit/public/platform/WebDisplayMode.h"
18 #include "third_party/WebKit/public/web/WebPopupType.h"
19 #include "ui/base/window_open_disposition.h"
21 class GURL;
22 class SkBitmap;
23 struct ViewHostMsg_CreateWindow_Params;
24 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
26 namespace base {
27 class ListValue;
28 class TimeTicks;
31 namespace IPC {
32 class Message;
35 namespace gfx {
36 class Point;
37 class Rect;
38 class Size;
41 namespace content {
43 class BrowserContext;
44 class CrossSiteTransferringRequest;
45 class FrameTree;
46 class PageState;
47 class RenderViewHost;
48 class RenderViewHostDelegateView;
49 class SessionStorageNamespace;
50 class SiteInstance;
51 class WebContents;
52 class WebContentsImpl;
53 struct FileChooserParams;
54 struct GlobalRequestID;
55 struct NativeWebKeyboardEvent;
56 struct Referrer;
57 struct RendererPreferences;
58 struct WebPreferences;
61 // RenderViewHostDelegate
63 // An interface implemented by an object interested in knowing about the state
64 // of the RenderViewHost.
66 // This interface currently encompasses every type of message that was
67 // previously being sent by WebContents itself. Some of these notifications
68 // may not be relevant to all users of RenderViewHost and we should consider
69 // exposing a more generic Send function on RenderViewHost and a response
70 // listener here to serve that need.
71 class CONTENT_EXPORT RenderViewHostDelegate {
72 public:
73 // Returns the current delegate associated with a feature. May return NULL if
74 // there is no corresponding delegate.
75 virtual RenderViewHostDelegateView* GetDelegateView();
77 // This is used to give the delegate a chance to filter IPC messages.
78 virtual bool OnMessageReceived(RenderViewHost* render_view_host,
79 const IPC::Message& message);
81 // Return this object cast to a WebContents, if it is one. If the object is
82 // not a WebContents, returns NULL. DEPRECATED: Be sure to include brettw or
83 // jam as reviewers before you use this method. http://crbug.com/82582
84 virtual WebContents* GetAsWebContents();
86 // Return the rect where to display the resize corner, if any, otherwise
87 // an empty rect.
88 virtual gfx::Rect GetRootWindowResizerRect() const = 0;
90 // The RenderView is being constructed (message sent to the renderer process
91 // to construct a RenderView). Now is a good time to send other setup events
92 // to the RenderView. This precedes any other commands to the RenderView.
93 virtual void RenderViewCreated(RenderViewHost* render_view_host) {}
95 // The RenderView has been constructed.
96 virtual void RenderViewReady(RenderViewHost* render_view_host) {}
98 // The process containing the RenderView exited somehow (either cleanly,
99 // crash, or user kill).
100 virtual void RenderViewTerminated(RenderViewHost* render_view_host,
101 base::TerminationStatus status,
102 int error_code) {}
104 // The RenderView is going to be deleted. This is called when each
105 // RenderView is going to be destroyed
106 virtual void RenderViewDeleted(RenderViewHost* render_view_host) {}
108 // The state for the page changed and should be updated.
109 virtual void UpdateState(RenderViewHost* render_view_host,
110 int32 page_id,
111 const PageState& state) {}
113 // The destination URL has changed should be updated.
114 virtual void UpdateTargetURL(RenderViewHost* render_view_host,
115 const GURL& url) {}
117 // The page is trying to close the RenderView's representation in the client.
118 virtual void Close(RenderViewHost* render_view_host) {}
120 // The page is trying to move the RenderView's representation in the client.
121 virtual void RequestMove(const gfx::Rect& new_bounds) {}
123 // The pending page load was canceled.
124 virtual void DidCancelLoading() {}
126 // The RenderView's main frame document element is ready. This happens when
127 // the document has finished parsing.
128 virtual void DocumentAvailableInMainFrame(RenderViewHost* render_view_host) {}
130 // The page wants to close the active view in this tab.
131 virtual void RouteCloseEvent(RenderViewHost* rvh) {}
133 // Return a dummy RendererPreferences object that will be used by the renderer
134 // associated with the owning RenderViewHost.
135 virtual RendererPreferences GetRendererPrefs(
136 BrowserContext* browser_context) const = 0;
138 // Notification the user has made a gesture while focus was on the
139 // page. This is used to avoid uninitiated user downloads (aka carpet
140 // bombing), see DownloadRequestLimiter for details.
141 virtual void OnUserGesture() {}
143 // Notification from the renderer host that blocked UI event occurred.
144 // This happens when there are tab-modal dialogs. In this case, the
145 // notification is needed to let us draw attention to the dialog (i.e.
146 // refocus on the modal dialog, flash title etc).
147 virtual void OnIgnoredUIEvent() {}
149 // Notification that the renderer has become unresponsive. The
150 // delegate can use this notification to show a warning to the user.
151 virtual void RendererUnresponsive(RenderViewHost* render_view_host) {}
153 // Notification that a previously unresponsive renderer has become
154 // responsive again. The delegate can use this notification to end the
155 // warning shown to the user.
156 virtual void RendererResponsive(RenderViewHost* render_view_host) {}
158 // Notification that the RenderViewHost's load state changed.
159 virtual void LoadStateChanged(const GURL& url,
160 const net::LoadStateWithParam& load_state,
161 uint64 upload_position,
162 uint64 upload_size) {}
164 // The page wants the hosting window to activate/deactivate itself (it
165 // called the JavaScript window.focus()/blur() method).
166 virtual void Activate() {}
167 virtual void Deactivate() {}
169 // Notification that the view has lost capture.
170 virtual void LostCapture() {}
172 // Called when a file selection is to be done.
173 virtual void RunFileChooser(
174 RenderViewHost* render_view_host,
175 const FileChooserParams& params) {}
177 // Returns whether the associated tab is in fullscreen mode.
178 virtual bool IsFullscreenForCurrentTab() const;
180 // Returns the display mode for the view.
181 virtual blink::WebDisplayMode GetDisplayMode() const;
183 // The contents' preferred size changed.
184 virtual void UpdatePreferredSize(const gfx::Size& pref_size) {}
186 // The contents auto-resized and the container should match it.
187 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) {}
189 // Requests to lock the mouse. Once the request is approved or rejected,
190 // GotResponseToLockMouseRequest() will be called on the requesting render
191 // view host.
192 virtual void RequestToLockMouse(bool user_gesture,
193 bool last_unlocked_by_target) {}
195 // Notification that the view has lost the mouse lock.
196 virtual void LostMouseLock() {}
198 // The page is trying to open a new page (e.g. a popup window). The window
199 // should be created associated with the given |route_id| in the process of
200 // |source_site_instance|, but it should not be shown yet. That
201 // should happen in response to ShowCreatedWindow.
202 // |params.window_container_type| describes the type of RenderViewHost
203 // container that is requested -- in particular, the window.open call may
204 // have specified 'background' and 'persistent' in the feature string.
206 // The passed |params.frame_name| parameter is the name parameter that was
207 // passed to window.open(), and will be empty if none was passed.
209 // Note: this is not called "CreateWindow" because that will clash with
210 // the Windows function which is actually a #define.
212 // TODO(alexmos): This should be moved to RenderFrameHostDelegate, and the
213 // corresponding IPC message should be sent by the RenderFrame creating the
214 // new window.
215 virtual void CreateNewWindow(
216 SiteInstance* source_site_instance,
217 int route_id,
218 int main_frame_route_id,
219 const ViewHostMsg_CreateWindow_Params& params,
220 SessionStorageNamespace* session_storage_namespace) {}
222 // The page is trying to open a new widget (e.g. a select popup). The
223 // widget should be created associated with the given |route_id| in the
224 // process |render_process_id|, but it should not be shown yet. That should
225 // happen in response to ShowCreatedWidget.
226 // |popup_type| indicates if the widget is a popup and what kind of popup it
227 // is (select, autofill...).
228 virtual void CreateNewWidget(int32 render_process_id,
229 int32 route_id,
230 int32 surface_id,
231 blink::WebPopupType popup_type) {}
233 // Creates a full screen RenderWidget. Similar to above.
234 virtual void CreateNewFullscreenWidget(int32 render_process_id,
235 int32 route_id,
236 int32 surface_id) {}
238 // Show a previously created page with the specified disposition and bounds.
239 // The window is identified by the route_id passed to CreateNewWindow.
241 // Note: this is not called "ShowWindow" because that will clash with
242 // the Windows function which is actually a #define.
243 virtual void ShowCreatedWindow(int route_id,
244 WindowOpenDisposition disposition,
245 const gfx::Rect& initial_rect,
246 bool user_gesture) {}
248 // Show the newly created widget with the specified bounds.
249 // The widget is identified by the route_id passed to CreateNewWidget.
250 virtual void ShowCreatedWidget(int route_id,
251 const gfx::Rect& initial_rect) {}
253 // Show the newly created full screen widget. Similar to above.
254 virtual void ShowCreatedFullscreenWidget(int route_id) {}
256 // Returns the SessionStorageNamespace the render view should use. Might
257 // create the SessionStorageNamespace on the fly.
258 virtual SessionStorageNamespace* GetSessionStorageNamespace(
259 SiteInstance* instance);
261 // Returns a copy of the map of all session storage namespaces related
262 // to this view.
263 virtual SessionStorageNamespaceMap GetSessionStorageNamespaceMap();
265 // Returns true if the RenderViewHost will never be visible.
266 virtual bool IsNeverVisible();
268 // Returns the FrameTree the render view should use. Guaranteed to be constant
269 // for the lifetime of the render view.
271 // TODO(ajwong): Remove once the main frame RenderFrameHost is no longer
272 // created by the RenderViewHost.
273 virtual FrameTree* GetFrameTree();
275 // Optional state storage for if the Virtual Keyboard has been requested by
276 // this page or not. If it has, this can be used to suppress things like the
277 // link disambiguation dialog, which doesn't interact well with the virtual
278 // keyboard.
279 virtual void SetIsVirtualKeyboardRequested(bool requested) {}
280 virtual bool IsVirtualKeyboardRequested();
282 protected:
283 virtual ~RenderViewHostDelegate() {}
286 } // namespace content
288 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_DELEGATE_H_