[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 1 | // Copyright (c) 2011 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 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 5 | #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ |
| 6 | #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 7 | #pragma once |
| 8 | |
[email protected] | 1de2b8b | 2011-06-29 19:38:46 | [diff] [blame] | 9 | #include <set> |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 10 | #include <string> |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 11 | |
| 12 | #include "base/basictypes.h" |
[email protected] | d583e3f2 | 2011-12-27 21:38:17 | [diff] [blame] | 13 | #include "base/string16.h" |
[email protected] | 8d128d6 | 2011-09-13 22:11:57 | [diff] [blame] | 14 | #include "content/common/content_export.h" |
[email protected] | e6e646d | 2011-12-01 00:50:11 | [diff] [blame] | 15 | #include "content/public/browser/navigation_type.h" |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 16 | #include "content/public/common/page_transition_types.h" |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 17 | #include "ui/gfx/native_widget_types.h" |
| 18 | #include "webkit/glue/window_open_disposition.h" |
| 19 | |
[email protected] | 7dba43dc | 2011-11-10 01:57:58 | [diff] [blame] | 20 | class FilePath; |
| 21 | class GURL; |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 22 | class TabContents; |
| 23 | struct ContextMenuParams; |
[email protected] | 7dba43dc | 2011-11-10 01:57:58 | [diff] [blame] | 24 | struct NativeWebKeyboardEvent; |
[email protected] | 7dba43dc | 2011-11-10 01:57:58 | [diff] [blame] | 25 | |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 26 | namespace base { |
| 27 | class ListValue; |
| 28 | } |
| 29 | |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 30 | namespace content { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 31 | class BrowserContext; |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 32 | class DownloadItem; |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 33 | class JavaScriptDialogCreator; |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 34 | class WebContents; |
[email protected] | 0d9989d | 2011-12-21 20:26:00 | [diff] [blame] | 35 | class WebIntentsDispatcher; |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 36 | struct FileChooserParams; |
[email protected] | d583e3f2 | 2011-12-27 21:38:17 | [diff] [blame] | 37 | struct SSLStatus; |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 38 | } |
| 39 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 40 | namespace gfx { |
| 41 | class Point; |
| 42 | class Rect; |
| 43 | class Size; |
| 44 | } |
| 45 | |
| 46 | namespace history { |
| 47 | class HistoryAddPageArgs; |
| 48 | } |
| 49 | |
[email protected] | ce975194 | 2011-09-21 01:57:24 | [diff] [blame] | 50 | namespace webkit_glue { |
| 51 | struct WebIntentData; |
| 52 | } |
| 53 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 54 | namespace content { |
| 55 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame^] | 56 | struct OpenURLParams; |
| 57 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 58 | // Objects implement this interface to get notified about changes in the |
| 59 | // TabContents and to provide necessary functionality. |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 60 | class CONTENT_EXPORT WebContentsDelegate { |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 61 | public: |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 62 | WebContentsDelegate(); |
[email protected] | 1de2b8b | 2011-06-29 19:38:46 | [diff] [blame] | 63 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame^] | 64 | // Opens a new URL inside the passed in WebContents (if source is 0 open |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 65 | // in the current front-most tab), unless |disposition| indicates the url |
| 66 | // should be opened in a new tab or window. |
| 67 | // |
| 68 | // A NULL source indicates the current tab (callers should probably use |
| 69 | // OpenURL() for these cases which does it for you). |
[email protected] | 00c37fc | 2011-08-02 00:22:50 | [diff] [blame] | 70 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame^] | 71 | // Returns the WebContents the URL is opened in, or NULL if the URL wasn't |
[email protected] | 992e454 | 2011-07-20 23:09:25 | [diff] [blame] | 72 | // opened immediately. |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame^] | 73 | virtual WebContents* OpenURLFromTab(WebContents* source, |
[email protected] | 00c37fc | 2011-08-02 00:22:50 | [diff] [blame] | 74 | const OpenURLParams& params); |
| 75 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 76 | // Called to inform the delegate that the tab content's navigation state |
| 77 | // changed. The |changed_flags| indicates the parts of the navigation state |
| 78 | // that have been updated, and is any combination of the |
| 79 | // |TabContents::InvalidateTypes| bits. |
| 80 | virtual void NavigationStateChanged(const TabContents* source, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 81 | unsigned changed_flags) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 82 | |
[email protected] | 6c6b02d | 2011-09-02 03:36:47 | [diff] [blame] | 83 | // Adds the navigation request headers to |headers|. Use |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 84 | // net::HttpUtil::AppendHeaderIfMissing to build the set of headers. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 85 | virtual void AddNavigationHeaders(const GURL& url, std::string* headers) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 86 | |
| 87 | // Creates a new tab with the already-created TabContents 'new_contents'. |
| 88 | // The window for the added contents should be reparented correctly when this |
| 89 | // method returns. If |disposition| is NEW_POPUP, |pos| should hold the |
| 90 | // initial position. |
| 91 | virtual void AddNewContents(TabContents* source, |
| 92 | TabContents* new_contents, |
| 93 | WindowOpenDisposition disposition, |
| 94 | const gfx::Rect& initial_pos, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 95 | bool user_gesture) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 96 | |
| 97 | // Selects the specified contents, bringing its container to the front. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 98 | virtual void ActivateContents(TabContents* contents) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 99 | |
| 100 | // Deactivates the specified contents by deactivating its container and |
| 101 | // potentialy moving it to the back of the Z order. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 102 | virtual void DeactivateContents(TabContents* contents) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 103 | |
| 104 | // Notifies the delegate that this contents is starting or is done loading |
| 105 | // some resource. The delegate should use this notification to represent |
[email protected] | f5d978c | 2011-07-21 14:43:51 | [diff] [blame] | 106 | // loading feedback. See TabContents::IsLoading() |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 107 | virtual void LoadingStateChanged(TabContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 108 | |
| 109 | // Notifies the delegate that the page has made some progress loading. |
| 110 | // |progress| is a value between 0.0 (nothing loaded) to 1.0 (page fully |
| 111 | // loaded). |
| 112 | // Note that to receive this notification, you must have called |
| 113 | // SetReportLoadProgressEnabled(true) in the render view. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 114 | virtual void LoadProgressChanged(double progress) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 115 | |
| 116 | // Request the delegate to close this tab contents, and do whatever cleanup |
| 117 | // it needs to do. |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 118 | virtual void CloseContents(WebContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 119 | |
[email protected] | cd9ed79d | 2011-11-15 19:22:57 | [diff] [blame] | 120 | // Informs the delegate that the underlying RenderViewHost has been swapped |
| 121 | // out so it can perform any cleanup necessary. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 122 | virtual void SwappedOut(TabContents* source) {} |
[email protected] | cd9ed79d | 2011-11-15 19:22:57 | [diff] [blame] | 123 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 124 | // Request the delegate to move this tab contents to the specified position |
| 125 | // in screen coordinates. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 126 | virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 127 | |
| 128 | // Causes the delegate to detach |source| and clean up any internal data |
| 129 | // pointing to it. After this call ownership of |source| passes to the |
| 130 | // caller, and it is safe to call "source->set_delegate(someone_else);". |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 131 | virtual void DetachContents(TabContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 132 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 133 | // Called to determine if the TabContents is contained in a popup window |
| 134 | // or a panel window. |
| 135 | virtual bool IsPopupOrPanel(const TabContents* source) const; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 136 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 137 | // Notification that the target URL has changed. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 138 | virtual void UpdateTargetURL(TabContents* source, |
| 139 | int32 page_id, |
| 140 | const GURL& url) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 141 | |
| 142 | // Notification that there was a mouse event, along with the absolute |
| 143 | // coordinates of the mouse pointer and whether it was a normal motion event |
| 144 | // (otherwise, the pointer left the contents area). |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 145 | virtual void ContentsMouseEvent(TabContents* source, |
| 146 | const gfx::Point& location, |
| 147 | bool motion) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 148 | |
| 149 | // Request the delegate to change the zoom level of the current tab. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 150 | virtual void ContentsZoomChange(bool zoom_in) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 151 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 152 | // Check whether this contents is inside a window dedicated to running a web |
| 153 | // application. |
| 154 | virtual bool IsApplication() const; |
| 155 | |
| 156 | // Detach the given tab and convert it to a "webapp" view. The tab must be |
| 157 | // a TabContents with a valid WebApp set. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 158 | virtual void ConvertContentsToApplication(TabContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 159 | |
| 160 | // Whether the specified tab can be reloaded. |
| 161 | // Reloading can be disabled e. g. for the DevTools window. |
| 162 | virtual bool CanReloadContents(TabContents* source) const; |
| 163 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 164 | // Invoked prior to showing before unload handler confirmation dialog. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 165 | virtual void WillRunBeforeUnloadConfirm() {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 166 | |
| 167 | // Returns true if javascript dialogs and unload alerts are suppressed. |
| 168 | // Default is false. |
| 169 | virtual bool ShouldSuppressDialogs(); |
| 170 | |
| 171 | // Tells us that we've finished firing this tab's beforeunload event. |
| 172 | // The proceed bool tells us whether the user chose to proceed closing the |
| 173 | // tab. Returns true if the tab can continue on firing it's unload event. |
| 174 | // If we're closing the entire browser, then we'll want to delay firing |
| 175 | // unload events until all the beforeunload events have fired. |
| 176 | virtual void BeforeUnloadFired(TabContents* tab, |
| 177 | bool proceed, |
| 178 | bool* proceed_to_fire_unload); |
| 179 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 180 | // Sets focus to the location bar or some other place that is appropriate. |
| 181 | // This is called when the tab wants to encourage user input, like for the |
| 182 | // new tab page. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 183 | virtual void SetFocusToLocationBar(bool select_all) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 184 | |
| 185 | // Returns whether the page should be focused when transitioning from crashed |
| 186 | // to live. Default is true. |
| 187 | virtual bool ShouldFocusPageAfterCrash(); |
| 188 | |
| 189 | // Called when a popup select is about to be displayed. The delegate can use |
| 190 | // this to disable inactive rendering for the frame in the window the select |
| 191 | // is opened within if necessary. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 192 | virtual void RenderWidgetShowing() {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 193 | |
| 194 | // This is called when WebKit tells us that it is done tabbing through |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 195 | // controls on the page. Provides a way for WebContentsDelegates to handle |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 196 | // this. Returns true if the delegate successfully handled it. |
| 197 | virtual bool TakeFocus(bool reverse); |
| 198 | |
| 199 | // Invoked when the page loses mouse capture. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 200 | virtual void LostCapture() {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 201 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 202 | // Notification that |tab_contents| has gained focus. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 203 | virtual void TabContentsFocused(TabContents* tab_content) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 204 | |
[email protected] | 68649314 | 2011-07-15 21:47:22 | [diff] [blame] | 205 | // Asks the delegate if the given tab can download. |
| 206 | virtual bool CanDownload(TabContents* source, int request_id); |
| 207 | |
| 208 | // Notifies the delegate that a download is starting. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 209 | virtual void OnStartDownload(TabContents* source, DownloadItem* download) {} |
[email protected] | 68649314 | 2011-07-15 21:47:22 | [diff] [blame] | 210 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 211 | // Return much extra vertical space should be allotted to the |
| 212 | // render view widget during various animations (e.g. infobar closing). |
| 213 | // This is used to make painting look smoother. |
| 214 | virtual int GetExtraRenderViewHeight() const; |
| 215 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 216 | // Returns true if the context menu operation was handled by the delegate. |
| 217 | virtual bool HandleContextMenu(const ContextMenuParams& params); |
| 218 | |
| 219 | // Returns true if the context menu command was handled |
| 220 | virtual bool ExecuteContextMenuCommand(int command); |
| 221 | |
| 222 | // Shows the page info using the specified information. |
| 223 | // |url| is the url of the page/frame the info applies to, |ssl| is the SSL |
| 224 | // information for that page/frame. If |show_history| is true, a section |
| 225 | // showing how many times that URL has been visited is added to the page info. |
[email protected] | 36fc039 | 2011-12-25 03:59:51 | [diff] [blame] | 226 | virtual void ShowPageInfo(content::BrowserContext* browser_context, |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 227 | const GURL& url, |
[email protected] | d583e3f2 | 2011-12-27 21:38:17 | [diff] [blame] | 228 | const SSLStatus& ssl, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 229 | bool show_history) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 230 | |
| 231 | // Opens source view for given tab contents that is navigated to the given |
| 232 | // page url. |
| 233 | virtual void ViewSourceForTab(TabContents* source, const GURL& page_url); |
| 234 | |
[email protected] | 932b7a1 | 2011-03-09 12:50:27 | [diff] [blame] | 235 | // Opens source view for the given subframe. |
| 236 | virtual void ViewSourceForFrame(TabContents* source, |
| 237 | const GURL& url, |
| 238 | const std::string& content_state); |
| 239 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 240 | // Allows delegates to handle keyboard events before sending to the renderer. |
| 241 | // Returns true if the |event| was handled. Otherwise, if the |event| would be |
| 242 | // handled in HandleKeyboardEvent() method as a normal keyboard shortcut, |
| 243 | // |*is_keyboard_shortcut| should be set to true. |
| 244 | virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 245 | bool* is_keyboard_shortcut); |
| 246 | |
| 247 | // Allows delegates to handle unhandled keyboard messages coming back from |
| 248 | // the renderer. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 249 | virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 250 | |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 251 | virtual void HandleMouseDown() {} |
| 252 | virtual void HandleMouseUp() {} |
| 253 | virtual void HandleMouseActivate() {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 254 | |
| 255 | // Render view drag n drop ended. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 256 | virtual void DragEnded() {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 257 | |
| 258 | // Shows the repost form confirmation dialog box. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 259 | virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 260 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 261 | // Allows delegate to override navigation to the history entries. |
| 262 | // Returns true to allow TabContents to continue with the default processing. |
| 263 | virtual bool OnGoToEntryOffset(int offset); |
| 264 | |
| 265 | // Returns whether this tab contents should add the specified navigation to |
| 266 | // history. |
| 267 | virtual bool ShouldAddNavigationToHistory( |
| 268 | const history::HistoryAddPageArgs& add_page_args, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 269 | NavigationType navigation_type); |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 270 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 271 | // Returns the native window framing the view containing the tab contents. |
| 272 | virtual gfx::NativeWindow GetFrameNativeWindow(); |
| 273 | |
| 274 | // Notifies the delegate about the creation of a new TabContents. This |
| 275 | // typically happens when popups are created. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 276 | virtual void TabContentsCreated(TabContents* new_contents) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 277 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 278 | // Notifies the delegate that the content restrictions for this tab has |
| 279 | // changed. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 280 | virtual void ContentRestrictionsChanged(TabContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 281 | |
[email protected] | 5545290 | 2011-06-01 21:57:47 | [diff] [blame] | 282 | // Notification that the tab is hung. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 283 | virtual void RendererUnresponsive(TabContents* source) {} |
[email protected] | 5545290 | 2011-06-01 21:57:47 | [diff] [blame] | 284 | |
| 285 | // Notification that the tab is no longer hung. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 286 | virtual void RendererResponsive(TabContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 287 | |
| 288 | // Notification that a worker associated with this tab has crashed. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 289 | virtual void WorkerCrashed(TabContents* source) {} |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 290 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 291 | // Invoked when a main fram navigation occurs. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 292 | virtual void DidNavigateMainFramePostCommit(TabContents* tab) {} |
[email protected] | 93f230e0 | 2011-06-01 14:40:00 | [diff] [blame] | 293 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 294 | // Invoked when navigating to a pending entry. When invoked the |
| 295 | // NavigationController has configured its pending entry, but it has not yet |
| 296 | // been committed. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 297 | virtual void DidNavigateToPendingEntry(TabContents* tab) {} |
[email protected] | 93f230e0 | 2011-06-01 14:40:00 | [diff] [blame] | 298 | |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 299 | // Returns a pointer to a service to create JavaScript dialogs. The default |
| 300 | // pointer returned is to a stub service that marks all dialogs as suppressed |
| 301 | // and displays nothing. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 302 | virtual JavaScriptDialogCreator* GetJavaScriptDialogCreator(); |
[email protected] | 3ab9cb8 | 2011-06-03 18:02:07 | [diff] [blame] | 303 | |
[email protected] | 3a29a6e | 2011-08-24 18:26:21 | [diff] [blame] | 304 | // Called when a file selection is to be done. |
| 305 | virtual void RunFileChooser(TabContents* tab, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 306 | const FileChooserParams& params) {} |
[email protected] | 3a29a6e | 2011-08-24 18:26:21 | [diff] [blame] | 307 | |
| 308 | // Request to enumerate a directory. This is equivalent to running the file |
| 309 | // chooser in directory-enumeration mode and having the user select the given |
| 310 | // directory. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 311 | virtual void EnumerateDirectory(TabContents* tab, |
| 312 | int request_id, |
| 313 | const FilePath& path) {} |
[email protected] | 3a29a6e | 2011-08-24 18:26:21 | [diff] [blame] | 314 | |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 315 | // Called when the renderer puts a tab into or out of fullscreen mode. |
| 316 | virtual void ToggleFullscreenModeForTab(TabContents* tab, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 317 | bool enter_fullscreen) {} |
[email protected] | 5d5f7af | 2011-10-01 01:38:12 | [diff] [blame] | 318 | virtual bool IsFullscreenForTab(const TabContents* tab) const; |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 319 | |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 320 | // Called when a Javascript out of memory notification is received. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 321 | virtual void JSOutOfMemory(TabContents* tab) {} |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 322 | |
| 323 | // Register a new handler for URL requests with the given scheme. |
| 324 | virtual void RegisterProtocolHandler(TabContents* tab, |
| 325 | const std::string& protocol, |
| 326 | const GURL& url, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 327 | const string16& title) {} |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 328 | |
| 329 | // Register a new handler for Intents with the given action and type filter. |
| 330 | virtual void RegisterIntentHandler(TabContents* tab, |
| 331 | const string16& action, |
| 332 | const string16& type, |
| 333 | const string16& href, |
[email protected] | 63c23932 | 2011-10-31 23:56:30 | [diff] [blame] | 334 | const string16& title, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 335 | const string16& disposition) {} |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 336 | |
[email protected] | 0d9989d | 2011-12-21 20:26:00 | [diff] [blame] | 337 | // Web Intents notification handler. Takes ownership of the |
| 338 | // |intents_dispatcher|. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 339 | virtual void WebIntentDispatch(TabContents* tab, |
| 340 | WebIntentsDispatcher* intents_dispatcher); |
[email protected] | 7d18902 | 2011-08-25 22:54:20 | [diff] [blame] | 341 | |
[email protected] | b888919c | 2011-09-02 00:32:16 | [diff] [blame] | 342 | // Result of string search in the page. This includes the number of matches |
| 343 | // found and the selection rect (in screen coordinates) for the string found. |
| 344 | // If |final_update| is false, it indicates that more results follow. |
| 345 | virtual void FindReply(TabContents* tab, |
| 346 | int request_id, |
| 347 | int number_of_matches, |
| 348 | const gfx::Rect& selection_rect, |
| 349 | int active_match_ordinal, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 350 | bool final_update) {} |
[email protected] | b888919c | 2011-09-02 00:32:16 | [diff] [blame] | 351 | |
[email protected] | d952a05 | 2011-09-06 18:42:45 | [diff] [blame] | 352 | // Notification that a plugin has crashed. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 353 | virtual void CrashedPlugin(TabContents* tab, const FilePath& plugin_path) {} |
[email protected] | d952a05 | 2011-09-06 18:42:45 | [diff] [blame] | 354 | |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 355 | // Invoked when the preferred size of the contents has been changed. |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 356 | virtual void UpdatePreferredSize(TabContents* tab, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 357 | const gfx::Size& pref_size) {} |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 358 | |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 359 | // Notification message from HTML UI. |
| 360 | virtual void WebUISend(TabContents* tab, |
| 361 | const GURL& source_url, |
| 362 | const std::string& name, |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 363 | const base::ListValue& args) {} |
[email protected] | 32ded221 | 2011-11-10 18:51:43 | [diff] [blame] | 364 | |
[email protected] | e962111 | 2011-10-17 05:38:37 | [diff] [blame] | 365 | // Requests to lock the mouse. Once the request is approved or rejected, |
| 366 | // GotResponseToLockMouseRequest() will be called on the requesting tab |
| 367 | // contents. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 368 | virtual void RequestToLockMouse(TabContents* tab) {} |
[email protected] | e962111 | 2011-10-17 05:38:37 | [diff] [blame] | 369 | |
| 370 | // Notification that the page has lost the mouse lock. |
[email protected] | 229eb7e | 2011-12-23 01:04:08 | [diff] [blame] | 371 | virtual void LostMouseLock() {} |
[email protected] | e962111 | 2011-10-17 05:38:37 | [diff] [blame] | 372 | |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 373 | protected: |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 374 | virtual ~WebContentsDelegate(); |
[email protected] | 1de2b8b | 2011-06-29 19:38:46 | [diff] [blame] | 375 | |
| 376 | private: |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 377 | friend class ::TabContents; |
[email protected] | 1de2b8b | 2011-06-29 19:38:46 | [diff] [blame] | 378 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 379 | // Called when |this| becomes the WebContentsDelegate for |source|. |
[email protected] | 1de2b8b | 2011-06-29 19:38:46 | [diff] [blame] | 380 | void Attach(TabContents* source); |
| 381 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 382 | // Called when |this| is no longer the WebContentsDelegate for |source|. |
[email protected] | 1de2b8b | 2011-06-29 19:38:46 | [diff] [blame] | 383 | void Detach(TabContents* source); |
| 384 | |
| 385 | // The TabContents that this is currently a delegate for. |
| 386 | std::set<TabContents*> attached_contents_; |
[email protected] | 0dd3a0ab | 2011-02-18 08:17:44 | [diff] [blame] | 387 | }; |
| 388 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 389 | } // namespace content |
| 390 | |
| 391 | #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ |