blob: 392d5f634bc8d2aed56acbf98c85a1ec39f1bd6f [file] [log] [blame]
[email protected]4fdf6742012-01-10 20:14:361// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0dd3a0ab2011-02-18 08:17:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]674bc592011-12-20 23:00:425#ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_
6#define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_
[email protected]0dd3a0ab2011-02-18 08:17:447
[email protected]1de2b8b2011-06-29 19:38:468#include <set>
[email protected]0dd3a0ab2011-02-18 08:17:449#include <string>
[email protected]0dd3a0ab2011-02-18 08:17:4410
11#include "base/basictypes.h"
[email protected]f13b4202012-06-12 23:53:2312#include "base/callback.h"
[email protected]26dd01c2013-06-12 13:52:1313#include "base/strings/string16.h"
[email protected]8d128d62011-09-13 22:11:5714#include "content/common/content_export.h"
[email protected]e6e646d2011-12-01 00:50:1115#include "content/public/browser/navigation_type.h"
[email protected]f13b4202012-06-12 23:53:2316#include "content/public/common/media_stream_request.h"
[email protected]2905f742011-10-13 03:51:5817#include "content/public/common/page_transition_types.h"
[email protected]4fdf6742012-01-10 20:14:3618#include "content/public/common/window_container_type.h"
[email protected]2255a9332013-06-17 05:12:3119#include "third_party/WebKit/public/web/WebDragOperation.h"
[email protected]da8543762012-03-20 08:52:2020#include "third_party/skia/include/core/SkColor.h"
[email protected]f47621b2013-01-22 20:50:3321#include "ui/base/window_open_disposition.h"
[email protected]0dd3a0ab2011-02-18 08:17:4422#include "ui/gfx/native_widget_types.h"
[email protected]59363fc92012-09-05 03:46:3123#include "ui/gfx/rect_f.h"
[email protected]9b003482013-05-21 14:00:1724#include "ui/gfx/vector2d.h"
[email protected]0dd3a0ab2011-02-18 08:17:4425
[email protected]7dba43dc2011-11-10 01:57:5826class GURL;
[email protected]090550f2013-06-11 15:04:4727struct WebDropData;
[email protected]7dba43dc2011-11-10 01:57:5828
[email protected]32ded2212011-11-10 18:51:4329namespace base {
[email protected]a3ef4832013-02-02 05:12:3330class FilePath;
[email protected]32ded2212011-11-10 18:51:4331class ListValue;
32}
33
[email protected]3ab9cb82011-06-03 18:02:0734namespace content {
[email protected]3d7474ff2011-07-27 17:47:3735class BrowserContext;
[email protected]da8543762012-03-20 08:52:2036class ColorChooser;
[email protected]e582fdd2011-12-20 16:48:1737class DownloadItem;
[email protected]71a88bb2013-02-01 22:05:1538class JavaScriptDialogManager;
[email protected]691aa2f2013-05-28 22:52:0439class PageState;
[email protected]c0c1c622012-03-13 04:51:5440class RenderViewHost;
[email protected]a81343d232011-12-27 07:39:2041class WebContents;
[email protected]8ff00d72012-10-23 19:12:2142class WebContentsImpl;
[email protected]35be7ec2012-02-12 20:42:5143struct ContextMenuParams;
[email protected]e582fdd2011-12-20 16:48:1744struct FileChooserParams;
[email protected]b87ee522012-05-18 15:16:5445struct NativeWebKeyboardEvent;
[email protected]d583e3f22011-12-27 21:38:1746struct SSLStatus;
[email protected]3ab9cb82011-06-03 18:02:0747}
48
[email protected]0dd3a0ab2011-02-18 08:17:4449namespace gfx {
50class Point;
51class Rect;
52class Size;
53}
54
[email protected]16383382012-09-05 23:57:2655namespace WebKit {
56class WebLayer;
57}
58
[email protected]674bc592011-12-20 23:00:4259namespace content {
60
[email protected]e5d549d2011-12-28 01:29:2061struct OpenURLParams;
62
[email protected]0dd3a0ab2011-02-18 08:17:4463// Objects implement this interface to get notified about changes in the
[email protected]2a6bc3e2011-12-28 23:51:3364// WebContents and to provide necessary functionality.
[email protected]674bc592011-12-20 23:00:4265class CONTENT_EXPORT WebContentsDelegate {
[email protected]0dd3a0ab2011-02-18 08:17:4466 public:
[email protected]674bc592011-12-20 23:00:4267 WebContentsDelegate();
[email protected]1de2b8b2011-06-29 19:38:4668
[email protected]e5d549d2011-12-28 01:29:2069 // Opens a new URL inside the passed in WebContents (if source is 0 open
[email protected]0dd3a0ab2011-02-18 08:17:4470 // in the current front-most tab), unless |disposition| indicates the url
71 // should be opened in a new tab or window.
72 //
73 // A NULL source indicates the current tab (callers should probably use
74 // OpenURL() for these cases which does it for you).
[email protected]00c37fc2011-08-02 00:22:5075
[email protected]e5d549d2011-12-28 01:29:2076 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't
[email protected]992e4542011-07-20 23:09:2577 // opened immediately.
[email protected]e5d549d2011-12-28 01:29:2078 virtual WebContents* OpenURLFromTab(WebContents* source,
[email protected]00c37fc2011-08-02 00:22:5079 const OpenURLParams& params);
80
[email protected]ca13a442012-04-17 14:00:1281 // Called to inform the delegate that the WebContents's navigation state
[email protected]0dd3a0ab2011-02-18 08:17:4482 // changed. The |changed_flags| indicates the parts of the navigation state
83 // that have been updated, and is any combination of the
[email protected]2a6bc3e2011-12-28 23:51:3384 // |WebContents::InvalidateTypes| bits.
85 virtual void NavigationStateChanged(const WebContents* source,
[email protected]229eb7e2011-12-23 01:04:0886 unsigned changed_flags) {}
[email protected]0dd3a0ab2011-02-18 08:17:4487
[email protected]6c6b02d2011-09-02 03:36:4788 // Adds the navigation request headers to |headers|. Use
[email protected]0dd3a0ab2011-02-18 08:17:4489 // net::HttpUtil::AppendHeaderIfMissing to build the set of headers.
[email protected]229eb7e2011-12-23 01:04:0890 virtual void AddNavigationHeaders(const GURL& url, std::string* headers) {}
[email protected]0dd3a0ab2011-02-18 08:17:4491
[email protected]2a6bc3e2011-12-28 23:51:3392 // Creates a new tab with the already-created WebContents 'new_contents'.
[email protected]0dd3a0ab2011-02-18 08:17:4493 // The window for the added contents should be reparented correctly when this
94 // method returns. If |disposition| is NEW_POPUP, |pos| should hold the
[email protected]eda238a12012-09-07 23:44:0095 // initial position. If |was_blocked| is non-NULL, then |*was_blocked| will
96 // be set to true if the popup gets blocked, and left unchanged otherwise.
[email protected]2a6bc3e2011-12-28 23:51:3397 virtual void AddNewContents(WebContents* source,
98 WebContents* new_contents,
[email protected]0dd3a0ab2011-02-18 08:17:4499 WindowOpenDisposition disposition,
100 const gfx::Rect& initial_pos,
[email protected]eda238a12012-09-07 23:44:00101 bool user_gesture,
102 bool* was_blocked) {}
[email protected]0dd3a0ab2011-02-18 08:17:44103
104 // Selects the specified contents, bringing its container to the front.
[email protected]2a6bc3e2011-12-28 23:51:33105 virtual void ActivateContents(WebContents* contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44106
107 // Deactivates the specified contents by deactivating its container and
108 // potentialy moving it to the back of the Z order.
[email protected]2a6bc3e2011-12-28 23:51:33109 virtual void DeactivateContents(WebContents* contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44110
111 // Notifies the delegate that this contents is starting or is done loading
112 // some resource. The delegate should use this notification to represent
[email protected]2a6bc3e2011-12-28 23:51:33113 // loading feedback. See WebContents::IsLoading()
114 virtual void LoadingStateChanged(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44115
[email protected]8e603cd92012-10-23 22:29:26116#if defined(OS_ANDROID)
[email protected]0dd3a0ab2011-02-18 08:17:44117 // Notifies the delegate that the page has made some progress loading.
118 // |progress| is a value between 0.0 (nothing loaded) to 1.0 (page fully
119 // loaded).
[email protected]b3996ba2012-08-08 00:39:13120 virtual void LoadProgressChanged(WebContents* source,
121 double progress) {}
[email protected]8e603cd92012-10-23 22:29:26122#endif
[email protected]0dd3a0ab2011-02-18 08:17:44123
[email protected]2a6bc3e2011-12-28 23:51:33124 // Request the delegate to close this web contents, and do whatever cleanup
[email protected]0dd3a0ab2011-02-18 08:17:44125 // it needs to do.
[email protected]a81343d232011-12-27 07:39:20126 virtual void CloseContents(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44127
[email protected]cd9ed79d2011-11-15 19:22:57128 // Informs the delegate that the underlying RenderViewHost has been swapped
129 // out so it can perform any cleanup necessary.
[email protected]2a6bc3e2011-12-28 23:51:33130 virtual void SwappedOut(WebContents* source) {}
[email protected]cd9ed79d2011-11-15 19:22:57131
[email protected]ca13a442012-04-17 14:00:12132 // Request the delegate to move this WebContents to the specified position
[email protected]0dd3a0ab2011-02-18 08:17:44133 // in screen coordinates.
[email protected]2a6bc3e2011-12-28 23:51:33134 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) {}
[email protected]0dd3a0ab2011-02-18 08:17:44135
[email protected]2a6bc3e2011-12-28 23:51:33136 // Called to determine if the WebContents is contained in a popup window
[email protected]b35b26b32011-05-05 20:35:14137 // or a panel window.
[email protected]2a6bc3e2011-12-28 23:51:33138 virtual bool IsPopupOrPanel(const WebContents* source) const;
[email protected]0dd3a0ab2011-02-18 08:17:44139
[email protected]0dd3a0ab2011-02-18 08:17:44140 // Notification that the target URL has changed.
[email protected]2a6bc3e2011-12-28 23:51:33141 virtual void UpdateTargetURL(WebContents* source,
[email protected]229eb7e2011-12-23 01:04:08142 int32 page_id,
143 const GURL& url) {}
[email protected]0dd3a0ab2011-02-18 08:17:44144
145 // Notification that there was a mouse event, along with the absolute
146 // coordinates of the mouse pointer and whether it was a normal motion event
147 // (otherwise, the pointer left the contents area).
[email protected]2a6bc3e2011-12-28 23:51:33148 virtual void ContentsMouseEvent(WebContents* source,
[email protected]229eb7e2011-12-23 01:04:08149 const gfx::Point& location,
150 bool motion) {}
[email protected]0dd3a0ab2011-02-18 08:17:44151
152 // Request the delegate to change the zoom level of the current tab.
[email protected]229eb7e2011-12-23 01:04:08153 virtual void ContentsZoomChange(bool zoom_in) {}
[email protected]0dd3a0ab2011-02-18 08:17:44154
[email protected]067310262012-11-22 14:30:41155 // Called to determine if the WebContents can be overscrolled with touch/wheel
156 // gestures.
157 virtual bool CanOverscrollContent() const;
158
[email protected]24e18252012-04-16 21:26:27159 // Check whether this contents is permitted to load data URLs in WebUI mode.
160 // This is normally disallowed for security.
161 virtual bool CanLoadDataURLsInWebUI() const;
162
[email protected]b7a756d42012-01-23 18:08:17163 // Return the rect where to display the resize corner, if any, otherwise
164 // an empty rect.
165 virtual gfx::Rect GetRootWindowResizerRect() const;
166
[email protected]0dd3a0ab2011-02-18 08:17:44167 // Invoked prior to showing before unload handler confirmation dialog.
[email protected]229eb7e2011-12-23 01:04:08168 virtual void WillRunBeforeUnloadConfirm() {}
[email protected]0dd3a0ab2011-02-18 08:17:44169
170 // Returns true if javascript dialogs and unload alerts are suppressed.
171 // Default is false.
172 virtual bool ShouldSuppressDialogs();
173
[email protected]a796f202012-05-30 14:14:25174 // Add a message to the console. Returning true indicates that the delegate
175 // handled the message. If false is returned the default logging mechanism
176 // will be used for the message.
[email protected]0c9406632013-02-08 01:13:33177 virtual bool AddMessageToConsole(WebContents* source,
[email protected]a796f202012-05-30 14:14:25178 int32 level,
179 const string16& message,
180 int32 line_no,
181 const string16& source_id);
182
[email protected]0dd3a0ab2011-02-18 08:17:44183 // Tells us that we've finished firing this tab's beforeunload event.
184 // The proceed bool tells us whether the user chose to proceed closing the
[email protected]a2c92a1c2012-04-03 12:32:14185 // tab. Returns true if the tab can continue on firing its unload event.
[email protected]0dd3a0ab2011-02-18 08:17:44186 // If we're closing the entire browser, then we'll want to delay firing
187 // unload events until all the beforeunload events have fired.
[email protected]2a6bc3e2011-12-28 23:51:33188 virtual void BeforeUnloadFired(WebContents* tab,
[email protected]0dd3a0ab2011-02-18 08:17:44189 bool proceed,
190 bool* proceed_to_fire_unload);
191
[email protected]0c9406632013-02-08 01:13:33192 // Returns true if the location bar should be focused by default rather than
[email protected]af4b5f92013-03-05 07:48:38193 // the page contents. NOTE: this is only used if WebContents can't determine
194 // for itself whether the location bar should be focused by default. For a
195 // complete check, you should use WebContents::FocusLocationBarByDefault().
[email protected]0c9406632013-02-08 01:13:33196 virtual bool ShouldFocusLocationBarByDefault(WebContents* source);
197
[email protected]0dd3a0ab2011-02-18 08:17:44198 // Sets focus to the location bar or some other place that is appropriate.
199 // This is called when the tab wants to encourage user input, like for the
200 // new tab page.
[email protected]229eb7e2011-12-23 01:04:08201 virtual void SetFocusToLocationBar(bool select_all) {}
[email protected]0dd3a0ab2011-02-18 08:17:44202
203 // Returns whether the page should be focused when transitioning from crashed
204 // to live. Default is true.
205 virtual bool ShouldFocusPageAfterCrash();
206
207 // Called when a popup select is about to be displayed. The delegate can use
208 // this to disable inactive rendering for the frame in the window the select
209 // is opened within if necessary.
[email protected]229eb7e2011-12-23 01:04:08210 virtual void RenderWidgetShowing() {}
[email protected]0dd3a0ab2011-02-18 08:17:44211
212 // This is called when WebKit tells us that it is done tabbing through
[email protected]674bc592011-12-20 23:00:42213 // controls on the page. Provides a way for WebContentsDelegates to handle
[email protected]0dd3a0ab2011-02-18 08:17:44214 // this. Returns true if the delegate successfully handled it.
[email protected]0c9406632013-02-08 01:13:33215 virtual bool TakeFocus(WebContents* source,
[email protected]b3996ba2012-08-08 00:39:13216 bool reverse);
[email protected]0dd3a0ab2011-02-18 08:17:44217
218 // Invoked when the page loses mouse capture.
[email protected]229eb7e2011-12-23 01:04:08219 virtual void LostCapture() {}
[email protected]0dd3a0ab2011-02-18 08:17:44220
[email protected]2a6bc3e2011-12-28 23:51:33221 // Notification that |contents| has gained focus.
222 virtual void WebContentsFocused(WebContents* contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44223
[email protected]686493142011-07-15 21:47:22224 // Asks the delegate if the given tab can download.
[email protected]f85f5032013-04-03 09:01:54225 // Invoking the |callback| synchronously is OK.
226 virtual void CanDownload(RenderViewHost* render_view_host,
[email protected]c0c1c622012-03-13 04:51:54227 int request_id,
[email protected]f85f5032013-04-03 09:01:54228 const std::string& request_method,
229 const base::Callback<void(bool)>& callback);
[email protected]686493142011-07-15 21:47:22230
[email protected]0dd3a0ab2011-02-18 08:17:44231 // Return much extra vertical space should be allotted to the
232 // render view widget during various animations (e.g. infobar closing).
233 // This is used to make painting look smoother.
234 virtual int GetExtraRenderViewHeight() const;
235
[email protected]0dd3a0ab2011-02-18 08:17:44236 // Returns true if the context menu operation was handled by the delegate.
[email protected]35be7ec2012-02-12 20:42:51237 virtual bool HandleContextMenu(const content::ContextMenuParams& params);
[email protected]0dd3a0ab2011-02-18 08:17:44238
[email protected]ca13a442012-04-17 14:00:12239 // Opens source view for given WebContents that is navigated to the given
[email protected]0dd3a0ab2011-02-18 08:17:44240 // page url.
[email protected]2a6bc3e2011-12-28 23:51:33241 virtual void ViewSourceForTab(WebContents* source, const GURL& page_url);
[email protected]0dd3a0ab2011-02-18 08:17:44242
[email protected]932b7a12011-03-09 12:50:27243 // Opens source view for the given subframe.
[email protected]2a6bc3e2011-12-28 23:51:33244 virtual void ViewSourceForFrame(WebContents* source,
[email protected]932b7a12011-03-09 12:50:27245 const GURL& url,
[email protected]691aa2f2013-05-28 22:52:04246 const PageState& page_state);
[email protected]932b7a12011-03-09 12:50:27247
[email protected]0dd3a0ab2011-02-18 08:17:44248 // Allows delegates to handle keyboard events before sending to the renderer.
249 // Returns true if the |event| was handled. Otherwise, if the |event| would be
250 // handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
251 // |*is_keyboard_shortcut| should be set to true.
[email protected]b3996ba2012-08-08 00:39:13252 virtual bool PreHandleKeyboardEvent(WebContents* source,
253 const NativeWebKeyboardEvent& event,
[email protected]0dd3a0ab2011-02-18 08:17:44254 bool* is_keyboard_shortcut);
255
256 // Allows delegates to handle unhandled keyboard messages coming back from
257 // the renderer.
[email protected]b3996ba2012-08-08 00:39:13258 virtual void HandleKeyboardEvent(WebContents* source,
259 const NativeWebKeyboardEvent& event) {}
[email protected]0dd3a0ab2011-02-18 08:17:44260
[email protected]229eb7e2011-12-23 01:04:08261 virtual void HandleMouseDown() {}
262 virtual void HandleMouseUp() {}
[email protected]590a634e2012-07-19 16:38:23263
264 // Handles activation resulting from a pointer event (e.g. when mouse is
265 // pressed, or a touch-gesture begins).
266 virtual void HandlePointerActivate() {}
267
268 virtual void HandleGestureBegin() {}
269 virtual void HandleGestureEnd() {}
[email protected]0dd3a0ab2011-02-18 08:17:44270
[email protected]090550f2013-06-11 15:04:47271 // Called when an external drag event enters the web contents window. Return
272 // true to allow dragging and dropping on the web contents window or false to
273 // cancel the operation. This method is used by Chromium Embedded Framework.
274 virtual bool CanDragEnter(WebContents* source,
275 const WebDropData& data,
276 WebKit::WebDragOperationsMask operations_allowed);
277
[email protected]0dd3a0ab2011-02-18 08:17:44278 // Render view drag n drop ended.
[email protected]229eb7e2011-12-23 01:04:08279 virtual void DragEnded() {}
[email protected]0dd3a0ab2011-02-18 08:17:44280
281 // Shows the repost form confirmation dialog box.
[email protected]2a6bc3e2011-12-28 23:51:33282 virtual void ShowRepostFormWarningDialog(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44283
[email protected]0dd3a0ab2011-02-18 08:17:44284 // Allows delegate to override navigation to the history entries.
[email protected]2a6bc3e2011-12-28 23:51:33285 // Returns true to allow WebContents to continue with the default processing.
[email protected]0dd3a0ab2011-02-18 08:17:44286 virtual bool OnGoToEntryOffset(int offset);
287
[email protected]4fdf6742012-01-10 20:14:36288 // Allows delegate to control whether a WebContents will be created. Returns
[email protected]03b6d552012-03-29 04:03:01289 // true to allow the creation. Default is to allow it. In cases where the
290 // delegate handles the creation/navigation itself, it will use |target_url|.
[email protected]4fdf6742012-01-10 20:14:36291 virtual bool ShouldCreateWebContents(
292 WebContents* web_contents,
293 int route_id,
294 WindowContainerType window_container_type,
[email protected]03b6d552012-03-29 04:03:01295 const string16& frame_name,
296 const GURL& target_url);
[email protected]4fdf6742012-01-10 20:14:36297
[email protected]2a6bc3e2011-12-28 23:51:33298 // Notifies the delegate about the creation of a new WebContents. This
[email protected]0dd3a0ab2011-02-18 08:17:44299 // typically happens when popups are created.
[email protected]4fdf6742012-01-10 20:14:36300 virtual void WebContentsCreated(WebContents* source_contents,
301 int64 source_frame_id,
[email protected]50de3222013-03-20 15:36:13302 const string16& frame_name,
[email protected]4fdf6742012-01-10 20:14:36303 const GURL& target_url,
304 WebContents* new_contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44305
[email protected]0dd3a0ab2011-02-18 08:17:44306 // Notifies the delegate that the content restrictions for this tab has
307 // changed.
[email protected]2a6bc3e2011-12-28 23:51:33308 virtual void ContentRestrictionsChanged(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44309
[email protected]55452902011-06-01 21:57:47310 // Notification that the tab is hung.
[email protected]2a6bc3e2011-12-28 23:51:33311 virtual void RendererUnresponsive(WebContents* source) {}
[email protected]55452902011-06-01 21:57:47312
313 // Notification that the tab is no longer hung.
[email protected]2a6bc3e2011-12-28 23:51:33314 virtual void RendererResponsive(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44315
316 // Notification that a worker associated with this tab has crashed.
[email protected]2a6bc3e2011-12-28 23:51:33317 virtual void WorkerCrashed(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44318
[email protected]09b29342011-06-24 19:18:48319 // Invoked when a main fram navigation occurs.
[email protected]3bbacc5b2012-04-17 17:46:15320 virtual void DidNavigateMainFramePostCommit(WebContents* source) {}
[email protected]93f230e02011-06-01 14:40:00321
[email protected]09b29342011-06-24 19:18:48322 // Invoked when navigating to a pending entry. When invoked the
323 // NavigationController has configured its pending entry, but it has not yet
324 // been committed.
[email protected]3bbacc5b2012-04-17 17:46:15325 virtual void DidNavigateToPendingEntry(WebContents* source) {}
[email protected]93f230e02011-06-01 14:40:00326
[email protected]71a88bb2013-02-01 22:05:15327 // Returns a pointer to a service to manage JavaScript dialogs. May return
[email protected]51da7e32012-01-30 19:24:52328 // NULL in which case dialogs aren't shown.
[email protected]71a88bb2013-02-01 22:05:15329 virtual JavaScriptDialogManager* GetJavaScriptDialogManager();
[email protected]3ab9cb82011-06-03 18:02:07330
[email protected]da8543762012-03-20 08:52:20331 // Called when color chooser should open. Returns the opened color chooser.
[email protected]36193fcf2012-11-30 20:01:57332 // Ownership of the returned pointer is transferred to the caller.
[email protected]cb805452013-05-22 15:16:21333 virtual ColorChooser* OpenColorChooser(WebContents* web_contents,
334 SkColor color);
[email protected]da8543762012-03-20 08:52:20335
[email protected]3a29a6e2011-08-24 18:26:21336 // Called when a file selection is to be done.
[email protected]3bbacc5b2012-04-17 17:46:15337 virtual void RunFileChooser(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08338 const FileChooserParams& params) {}
[email protected]3a29a6e2011-08-24 18:26:21339
340 // Request to enumerate a directory. This is equivalent to running the file
341 // chooser in directory-enumeration mode and having the user select the given
342 // directory.
[email protected]3bbacc5b2012-04-17 17:46:15343 virtual void EnumerateDirectory(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08344 int request_id,
[email protected]a3ef4832013-02-02 05:12:33345 const base::FilePath& path) {}
[email protected]3a29a6e2011-08-24 18:26:21346
[email protected]8a5e0ca2011-08-25 06:30:47347 // Called when the renderer puts a tab into or out of fullscreen mode.
[email protected]3bbacc5b2012-04-17 17:46:15348 virtual void ToggleFullscreenModeForTab(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08349 bool enter_fullscreen) {}
[email protected]3bbacc5b2012-04-17 17:46:15350 virtual bool IsFullscreenForTabOrPending(
351 const WebContents* web_contents) const;
[email protected]8a5e0ca2011-08-25 06:30:47352
[email protected]9b003482013-05-21 14:00:17353 // Called when the renderer has scrolled programmatically.
354 virtual void DidProgrammaticallyScroll(WebContents* web_contents,
355 const gfx::Vector2d& scroll_point) {}
356
[email protected]7d189022011-08-25 22:54:20357 // Called when a Javascript out of memory notification is received.
[email protected]3bbacc5b2012-04-17 17:46:15358 virtual void JSOutOfMemory(WebContents* web_contents) {}
[email protected]7d189022011-08-25 22:54:20359
360 // Register a new handler for URL requests with the given scheme.
[email protected]3a3b75a2012-06-01 08:38:36361 // |user_gesture| is true if the registration is made in the context of a user
362 // gesture.
[email protected]3bbacc5b2012-04-17 17:46:15363 virtual void RegisterProtocolHandler(WebContents* web_contents,
[email protected]7d189022011-08-25 22:54:20364 const std::string& protocol,
365 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36366 const string16& title,
367 bool user_gesture) {}
[email protected]7d189022011-08-25 22:54:20368
[email protected]b888919c2011-09-02 00:32:16369 // Result of string search in the page. This includes the number of matches
370 // found and the selection rect (in screen coordinates) for the string found.
371 // If |final_update| is false, it indicates that more results follow.
[email protected]3bbacc5b2012-04-17 17:46:15372 virtual void FindReply(WebContents* web_contents,
[email protected]b888919c2011-09-02 00:32:16373 int request_id,
374 int number_of_matches,
375 const gfx::Rect& selection_rect,
376 int active_match_ordinal,
[email protected]229eb7e2011-12-23 01:04:08377 bool final_update) {}
[email protected]b888919c2011-09-02 00:32:16378
[email protected]59363fc92012-09-05 03:46:31379#if defined(OS_ANDROID)
380 // Provides the rects of the current find-in-page matches.
381 // Sent as a reply to RequestFindMatchRects.
382 virtual void FindMatchRectsReply(WebContents* web_contents,
383 int version,
384 const std::vector<gfx::RectF>& rects,
385 const gfx::RectF& active_rect) {}
386#endif
387
[email protected]0548c5352011-09-07 00:33:33388 // Invoked when the preferred size of the contents has been changed.
[email protected]3bbacc5b2012-04-17 17:46:15389 virtual void UpdatePreferredSize(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08390 const gfx::Size& pref_size) {}
[email protected]0548c5352011-09-07 00:33:33391
[email protected]61e2b3cc2012-03-02 16:13:34392 // Invoked when the contents auto-resized and the container should match it.
[email protected]3bbacc5b2012-04-17 17:46:15393 virtual void ResizeDueToAutoResize(WebContents* web_contents,
[email protected]61e2b3cc2012-03-02 16:13:34394 const gfx::Size& new_size) {}
395
[email protected]32ded2212011-11-10 18:51:43396 // Notification message from HTML UI.
[email protected]3bbacc5b2012-04-17 17:46:15397 virtual void WebUISend(WebContents* web_contents,
[email protected]32ded2212011-11-10 18:51:43398 const GURL& source_url,
399 const std::string& name,
[email protected]229eb7e2011-12-23 01:04:08400 const base::ListValue& args) {}
[email protected]32ded2212011-11-10 18:51:43401
[email protected]e9621112011-10-17 05:38:37402 // Requests to lock the mouse. Once the request is approved or rejected,
403 // GotResponseToLockMouseRequest() will be called on the requesting tab
404 // contents.
[email protected]42252e02012-04-26 16:29:39405 virtual void RequestToLockMouse(WebContents* web_contents,
[email protected]a9c81f02012-06-01 00:15:44406 bool user_gesture,
[email protected]f13b4202012-06-12 23:53:23407 bool last_unlocked_by_target) {}
[email protected]e9621112011-10-17 05:38:37408
409 // Notification that the page has lost the mouse lock.
[email protected]229eb7e2011-12-23 01:04:08410 virtual void LostMouseLock() {}
[email protected]e9621112011-10-17 05:38:37411
[email protected]f13b4202012-06-12 23:53:23412 // Asks permission to use the camera and/or microphone. If permission is
413 // granted, a call should be made to |callback| with the devices. If the
414 // request is denied, a call should be made to |callback| with an empty list
415 // of devices. |request| has the details of the request (e.g. which of audio
416 // and/or video devices are requested, and lists of available devices).
417 virtual void RequestMediaAccessPermission(
418 WebContents* web_contents,
[email protected]33662e52013-01-07 21:31:09419 const MediaStreamRequest& request,
[email protected]f13b4202012-06-12 23:53:23420 const MediaResponseCallback& callback) {}
421
[email protected]8c8fc292012-11-23 18:57:16422 // Requests permission to access the PPAPI broker. The delegate should return
423 // true and call the passed in |callback| with the result, or return false
424 // to indicate that it does not support asking for permission.
425 virtual bool RequestPpapiBrokerPermission(
426 WebContents* web_contents,
427 const GURL& url,
[email protected]a3ef4832013-02-02 05:12:33428 const base::FilePath& plugin_path,
[email protected]8c8fc292012-11-23 18:57:16429 const base::Callback<void(bool)>& callback);
430
[email protected]0dd3a0ab2011-02-18 08:17:44431 protected:
[email protected]674bc592011-12-20 23:00:42432 virtual ~WebContentsDelegate();
[email protected]1de2b8b2011-06-29 19:38:46433
434 private:
[email protected]8ff00d72012-10-23 19:12:21435 friend class WebContentsImpl;
[email protected]1de2b8b2011-06-29 19:38:46436
[email protected]674bc592011-12-20 23:00:42437 // Called when |this| becomes the WebContentsDelegate for |source|.
[email protected]2a6bc3e2011-12-28 23:51:33438 void Attach(WebContents* source);
[email protected]1de2b8b2011-06-29 19:38:46439
[email protected]674bc592011-12-20 23:00:42440 // Called when |this| is no longer the WebContentsDelegate for |source|.
[email protected]2a6bc3e2011-12-28 23:51:33441 void Detach(WebContents* source);
[email protected]1de2b8b2011-06-29 19:38:46442
[email protected]2a6bc3e2011-12-28 23:51:33443 // The WebContents that this is currently a delegate for.
444 std::set<WebContents*> attached_contents_;
[email protected]0dd3a0ab2011-02-18 08:17:44445};
446
[email protected]674bc592011-12-20 23:00:42447} // namespace content
448
449#endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_