blob: 48d90ac9cc18447162fd6087e7f508d9bdb219d0 [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]d583e3f22011-12-27 21:38:1713#include "base/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]da8543762012-03-20 08:52:2019#include "third_party/skia/include/core/SkColor.h"
[email protected]0dd3a0ab2011-02-18 08:17:4420#include "ui/gfx/native_widget_types.h"
[email protected]59363fc92012-09-05 03:46:3121#include "ui/gfx/rect_f.h"
[email protected]0dd3a0ab2011-02-18 08:17:4422#include "webkit/glue/window_open_disposition.h"
23
[email protected]7dba43dc2011-11-10 01:57:5824class FilePath;
25class GURL;
[email protected]b172aee2012-04-10 17:05:2626class WebContentsImpl;
[email protected]7dba43dc2011-11-10 01:57:5827
[email protected]32ded2212011-11-10 18:51:4328namespace base {
29class ListValue;
30}
31
[email protected]3ab9cb82011-06-03 18:02:0732namespace content {
[email protected]3d7474ff2011-07-27 17:47:3733class BrowserContext;
[email protected]da8543762012-03-20 08:52:2034class ColorChooser;
[email protected]e582fdd2011-12-20 16:48:1735class DownloadItem;
[email protected]3ab9cb82011-06-03 18:02:0736class JavaScriptDialogCreator;
[email protected]c0c1c622012-03-13 04:51:5437class RenderViewHost;
[email protected]a81343d232011-12-27 07:39:2038class WebContents;
[email protected]0d9989d2011-12-21 20:26:0039class WebIntentsDispatcher;
[email protected]35be7ec2012-02-12 20:42:5140struct ContextMenuParams;
[email protected]e582fdd2011-12-20 16:48:1741struct FileChooserParams;
[email protected]b87ee522012-05-18 15:16:5442struct NativeWebKeyboardEvent;
[email protected]d583e3f22011-12-27 21:38:1743struct SSLStatus;
[email protected]3ab9cb82011-06-03 18:02:0744}
45
[email protected]0dd3a0ab2011-02-18 08:17:4446namespace gfx {
47class Point;
48class Rect;
49class Size;
50}
51
52namespace history {
53class HistoryAddPageArgs;
54}
55
[email protected]ce9751942011-09-21 01:57:2456namespace webkit_glue {
57struct WebIntentData;
[email protected]3a3b75a2012-06-01 08:38:3658struct WebIntentServiceData;
[email protected]ce9751942011-09-21 01:57:2459}
60
[email protected]16383382012-09-05 23:57:2661namespace WebKit {
62class WebLayer;
63}
64
[email protected]674bc592011-12-20 23:00:4265namespace content {
66
[email protected]e5d549d2011-12-28 01:29:2067struct OpenURLParams;
68
[email protected]f13b4202012-06-12 23:53:2369typedef base::Callback< void(const MediaStreamDevices&) > MediaResponseCallback;
70
[email protected]0dd3a0ab2011-02-18 08:17:4471// Objects implement this interface to get notified about changes in the
[email protected]2a6bc3e2011-12-28 23:51:3372// WebContents and to provide necessary functionality.
[email protected]674bc592011-12-20 23:00:4273class CONTENT_EXPORT WebContentsDelegate {
[email protected]0dd3a0ab2011-02-18 08:17:4474 public:
[email protected]674bc592011-12-20 23:00:4275 WebContentsDelegate();
[email protected]1de2b8b2011-06-29 19:38:4676
[email protected]e5d549d2011-12-28 01:29:2077 // Opens a new URL inside the passed in WebContents (if source is 0 open
[email protected]0dd3a0ab2011-02-18 08:17:4478 // in the current front-most tab), unless |disposition| indicates the url
79 // should be opened in a new tab or window.
80 //
81 // A NULL source indicates the current tab (callers should probably use
82 // OpenURL() for these cases which does it for you).
[email protected]00c37fc2011-08-02 00:22:5083
[email protected]e5d549d2011-12-28 01:29:2084 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't
[email protected]992e4542011-07-20 23:09:2585 // opened immediately.
[email protected]e5d549d2011-12-28 01:29:2086 virtual WebContents* OpenURLFromTab(WebContents* source,
[email protected]00c37fc2011-08-02 00:22:5087 const OpenURLParams& params);
88
[email protected]ca13a442012-04-17 14:00:1289 // Called to inform the delegate that the WebContents's navigation state
[email protected]0dd3a0ab2011-02-18 08:17:4490 // changed. The |changed_flags| indicates the parts of the navigation state
91 // that have been updated, and is any combination of the
[email protected]2a6bc3e2011-12-28 23:51:3392 // |WebContents::InvalidateTypes| bits.
93 virtual void NavigationStateChanged(const WebContents* source,
[email protected]229eb7e2011-12-23 01:04:0894 unsigned changed_flags) {}
[email protected]0dd3a0ab2011-02-18 08:17:4495
[email protected]6c6b02d2011-09-02 03:36:4796 // Adds the navigation request headers to |headers|. Use
[email protected]0dd3a0ab2011-02-18 08:17:4497 // net::HttpUtil::AppendHeaderIfMissing to build the set of headers.
[email protected]229eb7e2011-12-23 01:04:0898 virtual void AddNavigationHeaders(const GURL& url, std::string* headers) {}
[email protected]0dd3a0ab2011-02-18 08:17:4499
[email protected]2a6bc3e2011-12-28 23:51:33100 // Creates a new tab with the already-created WebContents 'new_contents'.
[email protected]0dd3a0ab2011-02-18 08:17:44101 // The window for the added contents should be reparented correctly when this
102 // method returns. If |disposition| is NEW_POPUP, |pos| should hold the
[email protected]eda238a12012-09-07 23:44:00103 // initial position. If |was_blocked| is non-NULL, then |*was_blocked| will
104 // be set to true if the popup gets blocked, and left unchanged otherwise.
[email protected]2a6bc3e2011-12-28 23:51:33105 virtual void AddNewContents(WebContents* source,
106 WebContents* new_contents,
[email protected]0dd3a0ab2011-02-18 08:17:44107 WindowOpenDisposition disposition,
108 const gfx::Rect& initial_pos,
[email protected]eda238a12012-09-07 23:44:00109 bool user_gesture,
110 bool* was_blocked) {}
[email protected]0dd3a0ab2011-02-18 08:17:44111
112 // Selects the specified contents, bringing its container to the front.
[email protected]2a6bc3e2011-12-28 23:51:33113 virtual void ActivateContents(WebContents* contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44114
115 // Deactivates the specified contents by deactivating its container and
116 // potentialy moving it to the back of the Z order.
[email protected]2a6bc3e2011-12-28 23:51:33117 virtual void DeactivateContents(WebContents* contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44118
119 // Notifies the delegate that this contents is starting or is done loading
120 // some resource. The delegate should use this notification to represent
[email protected]2a6bc3e2011-12-28 23:51:33121 // loading feedback. See WebContents::IsLoading()
122 virtual void LoadingStateChanged(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44123
124 // Notifies the delegate that the page has made some progress loading.
125 // |progress| is a value between 0.0 (nothing loaded) to 1.0 (page fully
126 // loaded).
127 // Note that to receive this notification, you must have called
128 // SetReportLoadProgressEnabled(true) in the render view.
[email protected]b3996ba2012-08-08 00:39:13129 virtual void LoadProgressChanged(WebContents* source,
130 double progress) {}
[email protected]0dd3a0ab2011-02-18 08:17:44131
[email protected]2a6bc3e2011-12-28 23:51:33132 // Request the delegate to close this web contents, and do whatever cleanup
[email protected]0dd3a0ab2011-02-18 08:17:44133 // it needs to do.
[email protected]a81343d232011-12-27 07:39:20134 virtual void CloseContents(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44135
[email protected]cd9ed79d2011-11-15 19:22:57136 // Informs the delegate that the underlying RenderViewHost has been swapped
137 // out so it can perform any cleanup necessary.
[email protected]2a6bc3e2011-12-28 23:51:33138 virtual void SwappedOut(WebContents* source) {}
[email protected]cd9ed79d2011-11-15 19:22:57139
[email protected]ca13a442012-04-17 14:00:12140 // Request the delegate to move this WebContents to the specified position
[email protected]0dd3a0ab2011-02-18 08:17:44141 // in screen coordinates.
[email protected]2a6bc3e2011-12-28 23:51:33142 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) {}
[email protected]0dd3a0ab2011-02-18 08:17:44143
[email protected]2a6bc3e2011-12-28 23:51:33144 // Called to determine if the WebContents is contained in a popup window
[email protected]b35b26b32011-05-05 20:35:14145 // or a panel window.
[email protected]2a6bc3e2011-12-28 23:51:33146 virtual bool IsPopupOrPanel(const WebContents* source) const;
[email protected]0dd3a0ab2011-02-18 08:17:44147
[email protected]0dd3a0ab2011-02-18 08:17:44148 // Notification that the target URL has changed.
[email protected]2a6bc3e2011-12-28 23:51:33149 virtual void UpdateTargetURL(WebContents* source,
[email protected]229eb7e2011-12-23 01:04:08150 int32 page_id,
151 const GURL& url) {}
[email protected]0dd3a0ab2011-02-18 08:17:44152
153 // Notification that there was a mouse event, along with the absolute
154 // coordinates of the mouse pointer and whether it was a normal motion event
155 // (otherwise, the pointer left the contents area).
[email protected]2a6bc3e2011-12-28 23:51:33156 virtual void ContentsMouseEvent(WebContents* source,
[email protected]229eb7e2011-12-23 01:04:08157 const gfx::Point& location,
158 bool motion) {}
[email protected]0dd3a0ab2011-02-18 08:17:44159
160 // Request the delegate to change the zoom level of the current tab.
[email protected]229eb7e2011-12-23 01:04:08161 virtual void ContentsZoomChange(bool zoom_in) {}
[email protected]0dd3a0ab2011-02-18 08:17:44162
[email protected]0dd3a0ab2011-02-18 08:17:44163 // Check whether this contents is inside a window dedicated to running a web
164 // application.
165 virtual bool IsApplication() const;
166
[email protected]24e18252012-04-16 21:26:27167 // Check whether this contents is permitted to load data URLs in WebUI mode.
168 // This is normally disallowed for security.
169 virtual bool CanLoadDataURLsInWebUI() const;
170
[email protected]b7a756d42012-01-23 18:08:17171 // Return the rect where to display the resize corner, if any, otherwise
172 // an empty rect.
173 virtual gfx::Rect GetRootWindowResizerRect() const;
174
[email protected]0dd3a0ab2011-02-18 08:17:44175 // Invoked prior to showing before unload handler confirmation dialog.
[email protected]229eb7e2011-12-23 01:04:08176 virtual void WillRunBeforeUnloadConfirm() {}
[email protected]0dd3a0ab2011-02-18 08:17:44177
178 // Returns true if javascript dialogs and unload alerts are suppressed.
179 // Default is false.
180 virtual bool ShouldSuppressDialogs();
181
[email protected]a796f202012-05-30 14:14:25182 // Add a message to the console. Returning true indicates that the delegate
183 // handled the message. If false is returned the default logging mechanism
184 // will be used for the message.
185 virtual bool AddMessageToConsole(WebContents* soruce,
186 int32 level,
187 const string16& message,
188 int32 line_no,
189 const string16& source_id);
190
[email protected]0dd3a0ab2011-02-18 08:17:44191 // Tells us that we've finished firing this tab's beforeunload event.
192 // The proceed bool tells us whether the user chose to proceed closing the
[email protected]a2c92a1c2012-04-03 12:32:14193 // tab. Returns true if the tab can continue on firing its unload event.
[email protected]0dd3a0ab2011-02-18 08:17:44194 // If we're closing the entire browser, then we'll want to delay firing
195 // unload events until all the beforeunload events have fired.
[email protected]2a6bc3e2011-12-28 23:51:33196 virtual void BeforeUnloadFired(WebContents* tab,
[email protected]0dd3a0ab2011-02-18 08:17:44197 bool proceed,
198 bool* proceed_to_fire_unload);
199
[email protected]0dd3a0ab2011-02-18 08:17:44200 // Sets focus to the location bar or some other place that is appropriate.
201 // This is called when the tab wants to encourage user input, like for the
202 // new tab page.
[email protected]229eb7e2011-12-23 01:04:08203 virtual void SetFocusToLocationBar(bool select_all) {}
[email protected]0dd3a0ab2011-02-18 08:17:44204
205 // Returns whether the page should be focused when transitioning from crashed
206 // to live. Default is true.
207 virtual bool ShouldFocusPageAfterCrash();
208
209 // Called when a popup select is about to be displayed. The delegate can use
210 // this to disable inactive rendering for the frame in the window the select
211 // is opened within if necessary.
[email protected]229eb7e2011-12-23 01:04:08212 virtual void RenderWidgetShowing() {}
[email protected]0dd3a0ab2011-02-18 08:17:44213
214 // This is called when WebKit tells us that it is done tabbing through
[email protected]674bc592011-12-20 23:00:42215 // controls on the page. Provides a way for WebContentsDelegates to handle
[email protected]0dd3a0ab2011-02-18 08:17:44216 // this. Returns true if the delegate successfully handled it.
[email protected]b3996ba2012-08-08 00:39:13217 virtual bool TakeFocus(WebContents* soruce,
218 bool reverse);
[email protected]0dd3a0ab2011-02-18 08:17:44219
220 // Invoked when the page loses mouse capture.
[email protected]229eb7e2011-12-23 01:04:08221 virtual void LostCapture() {}
[email protected]0dd3a0ab2011-02-18 08:17:44222
[email protected]2a6bc3e2011-12-28 23:51:33223 // Notification that |contents| has gained focus.
224 virtual void WebContentsFocused(WebContents* contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44225
[email protected]686493142011-07-15 21:47:22226 // Asks the delegate if the given tab can download.
[email protected]c0c1c622012-03-13 04:51:54227 virtual bool CanDownload(RenderViewHost* render_view_host,
228 int request_id,
229 const std::string& request_method);
[email protected]686493142011-07-15 21:47:22230
231 // Notifies the delegate that a download is starting.
[email protected]2a6bc3e2011-12-28 23:51:33232 virtual void OnStartDownload(WebContents* source, DownloadItem* download) {}
[email protected]686493142011-07-15 21:47:22233
[email protected]0dd3a0ab2011-02-18 08:17:44234 // Return much extra vertical space should be allotted to the
235 // render view widget during various animations (e.g. infobar closing).
236 // This is used to make painting look smoother.
237 virtual int GetExtraRenderViewHeight() const;
238
[email protected]0dd3a0ab2011-02-18 08:17:44239 // Returns true if the context menu operation was handled by the delegate.
[email protected]35be7ec2012-02-12 20:42:51240 virtual bool HandleContextMenu(const content::ContextMenuParams& params);
[email protected]0dd3a0ab2011-02-18 08:17:44241
242 // Returns true if the context menu command was handled
243 virtual bool ExecuteContextMenuCommand(int command);
244
[email protected]ca13a442012-04-17 14:00:12245 // Opens source view for given WebContents that is navigated to the given
[email protected]0dd3a0ab2011-02-18 08:17:44246 // page url.
[email protected]2a6bc3e2011-12-28 23:51:33247 virtual void ViewSourceForTab(WebContents* source, const GURL& page_url);
[email protected]0dd3a0ab2011-02-18 08:17:44248
[email protected]932b7a12011-03-09 12:50:27249 // Opens source view for the given subframe.
[email protected]2a6bc3e2011-12-28 23:51:33250 virtual void ViewSourceForFrame(WebContents* source,
[email protected]932b7a12011-03-09 12:50:27251 const GURL& url,
252 const std::string& content_state);
253
[email protected]0dd3a0ab2011-02-18 08:17:44254 // Allows delegates to handle keyboard events before sending to the renderer.
255 // Returns true if the |event| was handled. Otherwise, if the |event| would be
256 // handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
257 // |*is_keyboard_shortcut| should be set to true.
[email protected]b3996ba2012-08-08 00:39:13258 virtual bool PreHandleKeyboardEvent(WebContents* source,
259 const NativeWebKeyboardEvent& event,
[email protected]0dd3a0ab2011-02-18 08:17:44260 bool* is_keyboard_shortcut);
261
262 // Allows delegates to handle unhandled keyboard messages coming back from
263 // the renderer.
[email protected]b3996ba2012-08-08 00:39:13264 virtual void HandleKeyboardEvent(WebContents* source,
265 const NativeWebKeyboardEvent& event) {}
[email protected]0dd3a0ab2011-02-18 08:17:44266
[email protected]229eb7e2011-12-23 01:04:08267 virtual void HandleMouseDown() {}
268 virtual void HandleMouseUp() {}
[email protected]590a634e2012-07-19 16:38:23269
270 // Handles activation resulting from a pointer event (e.g. when mouse is
271 // pressed, or a touch-gesture begins).
272 virtual void HandlePointerActivate() {}
273
274 virtual void HandleGestureBegin() {}
275 virtual void HandleGestureEnd() {}
[email protected]0dd3a0ab2011-02-18 08:17:44276
277 // Render view drag n drop ended.
[email protected]229eb7e2011-12-23 01:04:08278 virtual void DragEnded() {}
[email protected]0dd3a0ab2011-02-18 08:17:44279
280 // Shows the repost form confirmation dialog box.
[email protected]2a6bc3e2011-12-28 23:51:33281 virtual void ShowRepostFormWarningDialog(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44282
[email protected]0dd3a0ab2011-02-18 08:17:44283 // Allows delegate to override navigation to the history entries.
[email protected]2a6bc3e2011-12-28 23:51:33284 // Returns true to allow WebContents to continue with the default processing.
[email protected]0dd3a0ab2011-02-18 08:17:44285 virtual bool OnGoToEntryOffset(int offset);
286
[email protected]ca13a442012-04-17 14:00:12287 // Returns whether this WebContents should add the specified navigation to
[email protected]0dd3a0ab2011-02-18 08:17:44288 // history.
289 virtual bool ShouldAddNavigationToHistory(
290 const history::HistoryAddPageArgs& add_page_args,
[email protected]229eb7e2011-12-23 01:04:08291 NavigationType navigation_type);
[email protected]0dd3a0ab2011-02-18 08:17:44292
[email protected]ca13a442012-04-17 14:00:12293 // Returns the native window framing the view containing the WebContents.
[email protected]0dd3a0ab2011-02-18 08:17:44294 virtual gfx::NativeWindow GetFrameNativeWindow();
295
[email protected]4fdf6742012-01-10 20:14:36296 // Allows delegate to control whether a WebContents will be created. Returns
[email protected]03b6d552012-03-29 04:03:01297 // true to allow the creation. Default is to allow it. In cases where the
298 // delegate handles the creation/navigation itself, it will use |target_url|.
[email protected]4fdf6742012-01-10 20:14:36299 virtual bool ShouldCreateWebContents(
300 WebContents* web_contents,
301 int route_id,
302 WindowContainerType window_container_type,
[email protected]03b6d552012-03-29 04:03:01303 const string16& frame_name,
304 const GURL& target_url);
[email protected]4fdf6742012-01-10 20:14:36305
[email protected]2a6bc3e2011-12-28 23:51:33306 // Notifies the delegate about the creation of a new WebContents. This
[email protected]0dd3a0ab2011-02-18 08:17:44307 // typically happens when popups are created.
[email protected]4fdf6742012-01-10 20:14:36308 virtual void WebContentsCreated(WebContents* source_contents,
309 int64 source_frame_id,
310 const GURL& target_url,
311 WebContents* new_contents) {}
[email protected]0dd3a0ab2011-02-18 08:17:44312
[email protected]0dd3a0ab2011-02-18 08:17:44313 // Notifies the delegate that the content restrictions for this tab has
314 // changed.
[email protected]2a6bc3e2011-12-28 23:51:33315 virtual void ContentRestrictionsChanged(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44316
[email protected]55452902011-06-01 21:57:47317 // Notification that the tab is hung.
[email protected]2a6bc3e2011-12-28 23:51:33318 virtual void RendererUnresponsive(WebContents* source) {}
[email protected]55452902011-06-01 21:57:47319
320 // Notification that the tab is no longer hung.
[email protected]2a6bc3e2011-12-28 23:51:33321 virtual void RendererResponsive(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44322
323 // Notification that a worker associated with this tab has crashed.
[email protected]2a6bc3e2011-12-28 23:51:33324 virtual void WorkerCrashed(WebContents* source) {}
[email protected]0dd3a0ab2011-02-18 08:17:44325
[email protected]09b29342011-06-24 19:18:48326 // Invoked when a main fram navigation occurs.
[email protected]3bbacc5b2012-04-17 17:46:15327 virtual void DidNavigateMainFramePostCommit(WebContents* source) {}
[email protected]93f230e02011-06-01 14:40:00328
[email protected]09b29342011-06-24 19:18:48329 // Invoked when navigating to a pending entry. When invoked the
330 // NavigationController has configured its pending entry, but it has not yet
331 // been committed.
[email protected]3bbacc5b2012-04-17 17:46:15332 virtual void DidNavigateToPendingEntry(WebContents* source) {}
[email protected]93f230e02011-06-01 14:40:00333
[email protected]51da7e32012-01-30 19:24:52334 // Returns a pointer to a service to create JavaScript dialogs. May return
335 // NULL in which case dialogs aren't shown.
[email protected]229eb7e2011-12-23 01:04:08336 virtual JavaScriptDialogCreator* GetJavaScriptDialogCreator();
[email protected]3ab9cb82011-06-03 18:02:07337
[email protected]da8543762012-03-20 08:52:20338 // Called when color chooser should open. Returns the opened color chooser.
[email protected]3bbacc5b2012-04-17 17:46:15339 virtual content::ColorChooser* OpenColorChooser(WebContents* web_contents,
[email protected]da8543762012-03-20 08:52:20340 int color_chooser_id,
[email protected]55578b0a2012-04-18 14:31:32341 SkColor color);
[email protected]da8543762012-03-20 08:52:20342
343 virtual void DidEndColorChooser() {}
344
[email protected]3a29a6e2011-08-24 18:26:21345 // Called when a file selection is to be done.
[email protected]3bbacc5b2012-04-17 17:46:15346 virtual void RunFileChooser(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08347 const FileChooserParams& params) {}
[email protected]3a29a6e2011-08-24 18:26:21348
349 // Request to enumerate a directory. This is equivalent to running the file
350 // chooser in directory-enumeration mode and having the user select the given
351 // directory.
[email protected]3bbacc5b2012-04-17 17:46:15352 virtual void EnumerateDirectory(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08353 int request_id,
354 const FilePath& path) {}
[email protected]3a29a6e2011-08-24 18:26:21355
[email protected]8a5e0ca2011-08-25 06:30:47356 // Called when the renderer puts a tab into or out of fullscreen mode.
[email protected]3bbacc5b2012-04-17 17:46:15357 virtual void ToggleFullscreenModeForTab(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08358 bool enter_fullscreen) {}
[email protected]3bbacc5b2012-04-17 17:46:15359 virtual bool IsFullscreenForTabOrPending(
360 const WebContents* web_contents) const;
[email protected]8a5e0ca2011-08-25 06:30:47361
[email protected]7d189022011-08-25 22:54:20362 // Called when a Javascript out of memory notification is received.
[email protected]3bbacc5b2012-04-17 17:46:15363 virtual void JSOutOfMemory(WebContents* web_contents) {}
[email protected]7d189022011-08-25 22:54:20364
365 // Register a new handler for URL requests with the given scheme.
[email protected]3a3b75a2012-06-01 08:38:36366 // |user_gesture| is true if the registration is made in the context of a user
367 // gesture.
[email protected]3bbacc5b2012-04-17 17:46:15368 virtual void RegisterProtocolHandler(WebContents* web_contents,
[email protected]7d189022011-08-25 22:54:20369 const std::string& protocol,
370 const GURL& url,
[email protected]3a3b75a2012-06-01 08:38:36371 const string16& title,
372 bool user_gesture) {}
[email protected]7d189022011-08-25 22:54:20373
[email protected]3a3b75a2012-06-01 08:38:36374 // Register a new Web Intents service.
375 // |user_gesture| is true if the registration is made in the context of a user
376 // gesture. |web_contents| is the context in which the registration was
377 // performed, and |data| is the service record being registered.
378 virtual void RegisterIntentHandler(
379 WebContents* web_contents,
380 const webkit_glue::WebIntentServiceData& data,
381 bool user_gesture) {}
[email protected]7d189022011-08-25 22:54:20382
[email protected]0b5af6f2012-02-03 23:14:16383 // Web Intents notification handler. See WebIntentsDispatcher for
384 // documentation of callee responsibility for the dispatcher.
[email protected]3bbacc5b2012-04-17 17:46:15385 virtual void WebIntentDispatch(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08386 WebIntentsDispatcher* intents_dispatcher);
[email protected]7d189022011-08-25 22:54:20387
[email protected]b888919c2011-09-02 00:32:16388 // Result of string search in the page. This includes the number of matches
389 // found and the selection rect (in screen coordinates) for the string found.
390 // If |final_update| is false, it indicates that more results follow.
[email protected]3bbacc5b2012-04-17 17:46:15391 virtual void FindReply(WebContents* web_contents,
[email protected]b888919c2011-09-02 00:32:16392 int request_id,
393 int number_of_matches,
394 const gfx::Rect& selection_rect,
395 int active_match_ordinal,
[email protected]229eb7e2011-12-23 01:04:08396 bool final_update) {}
[email protected]b888919c2011-09-02 00:32:16397
[email protected]59363fc92012-09-05 03:46:31398#if defined(OS_ANDROID)
399 // Provides the rects of the current find-in-page matches.
400 // Sent as a reply to RequestFindMatchRects.
401 virtual void FindMatchRectsReply(WebContents* web_contents,
402 int version,
403 const std::vector<gfx::RectF>& rects,
404 const gfx::RectF& active_rect) {}
405#endif
406
[email protected]0548c5352011-09-07 00:33:33407 // Invoked when the preferred size of the contents has been changed.
[email protected]3bbacc5b2012-04-17 17:46:15408 virtual void UpdatePreferredSize(WebContents* web_contents,
[email protected]229eb7e2011-12-23 01:04:08409 const gfx::Size& pref_size) {}
[email protected]0548c5352011-09-07 00:33:33410
[email protected]61e2b3cc2012-03-02 16:13:34411 // Invoked when the contents auto-resized and the container should match it.
[email protected]3bbacc5b2012-04-17 17:46:15412 virtual void ResizeDueToAutoResize(WebContents* web_contents,
[email protected]61e2b3cc2012-03-02 16:13:34413 const gfx::Size& new_size) {}
414
[email protected]32ded2212011-11-10 18:51:43415 // Notification message from HTML UI.
[email protected]3bbacc5b2012-04-17 17:46:15416 virtual void WebUISend(WebContents* web_contents,
[email protected]32ded2212011-11-10 18:51:43417 const GURL& source_url,
418 const std::string& name,
[email protected]229eb7e2011-12-23 01:04:08419 const base::ListValue& args) {}
[email protected]32ded2212011-11-10 18:51:43420
[email protected]e9621112011-10-17 05:38:37421 // Requests to lock the mouse. Once the request is approved or rejected,
422 // GotResponseToLockMouseRequest() will be called on the requesting tab
423 // contents.
[email protected]42252e02012-04-26 16:29:39424 virtual void RequestToLockMouse(WebContents* web_contents,
[email protected]a9c81f02012-06-01 00:15:44425 bool user_gesture,
[email protected]f13b4202012-06-12 23:53:23426 bool last_unlocked_by_target) {}
[email protected]e9621112011-10-17 05:38:37427
428 // Notification that the page has lost the mouse lock.
[email protected]229eb7e2011-12-23 01:04:08429 virtual void LostMouseLock() {}
[email protected]e9621112011-10-17 05:38:37430
[email protected]f13b4202012-06-12 23:53:23431 // Asks permission to use the camera and/or microphone. If permission is
432 // granted, a call should be made to |callback| with the devices. If the
433 // request is denied, a call should be made to |callback| with an empty list
434 // of devices. |request| has the details of the request (e.g. which of audio
435 // and/or video devices are requested, and lists of available devices).
436 virtual void RequestMediaAccessPermission(
437 WebContents* web_contents,
438 const MediaStreamRequest* request,
439 const MediaResponseCallback& callback) {}
440
[email protected]16383382012-09-05 23:57:26441#if defined(OS_ANDROID)
442 // Returns true if the delegate wants to handle the url instead. Default
443 // returns false.
444 virtual bool ShouldOverrideLoading(const GURL& url);
445
446 // Called when a compositing layer becomes available for this web contents
447 // so the delegate can add it to the layer tree.
448 virtual void AttachLayer(WebContents* web_contents,
449 WebKit::WebLayer* layer) {}
450
451 // Called before a compositing layer becomes invalid so the delegate can
452 // remove it from the layer tree.
453 virtual void RemoveLayer(WebContents* web_contents,
454 WebKit::WebLayer* layer) {}
455#endif
456
[email protected]0dd3a0ab2011-02-18 08:17:44457 protected:
[email protected]674bc592011-12-20 23:00:42458 virtual ~WebContentsDelegate();
[email protected]1de2b8b2011-06-29 19:38:46459
460 private:
[email protected]b172aee2012-04-10 17:05:26461 friend class ::WebContentsImpl;
[email protected]1de2b8b2011-06-29 19:38:46462
[email protected]674bc592011-12-20 23:00:42463 // Called when |this| becomes the WebContentsDelegate for |source|.
[email protected]2a6bc3e2011-12-28 23:51:33464 void Attach(WebContents* source);
[email protected]1de2b8b2011-06-29 19:38:46465
[email protected]674bc592011-12-20 23:00:42466 // Called when |this| is no longer the WebContentsDelegate for |source|.
[email protected]2a6bc3e2011-12-28 23:51:33467 void Detach(WebContents* source);
[email protected]1de2b8b2011-06-29 19:38:46468
[email protected]2a6bc3e2011-12-28 23:51:33469 // The WebContents that this is currently a delegate for.
470 std::set<WebContents*> attached_contents_;
[email protected]0dd3a0ab2011-02-18 08:17:44471};
472
[email protected]674bc592011-12-20 23:00:42473} // namespace content
474
475#endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_