Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebFrameClient_h | 31 #ifndef WebFrameClient_h |
| 32 #define WebFrameClient_h | 32 #define WebFrameClient_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "WebNavigationPolicy.h" | 35 #include "WebNavigationPolicy.h" |
| 36 #include "WebNavigationType.h" | 36 #include "WebNavigationType.h" |
| 37 #include "WebURLError.h" | |
| 37 | 38 |
| 38 namespace WebKit { | 39 namespace WebKit { |
| 39 class WebDataSource; | 40 class WebDataSource; |
| 40 class WebForm; | 41 class WebForm; |
| 41 class WebFrame; | 42 class WebFrame; |
| 42 class WebMediaPlayer; | 43 class WebMediaPlayer; |
| 43 class WebMediaPlayerClient; | 44 class WebMediaPlayerClient; |
| 44 class WebNode; | 45 class WebNode; |
| 45 class WebPlugin; | 46 class WebPlugin; |
| 46 class WebSecurityOrigin; | 47 class WebSecurityOrigin; |
| 47 class WebString; | 48 class WebString; |
| 48 class WebURL; | 49 class WebURL; |
| 49 class WebURLRequest; | 50 class WebURLRequest; |
| 50 class WebURLResponse; | 51 class WebURLResponse; |
| 51 class WebWorker; | 52 class WebWorker; |
| 52 class WebWorkerClient; | 53 class WebWorkerClient; |
| 53 struct WebPluginParams; | 54 struct WebPluginParams; |
| 54 struct WebRect; | 55 struct WebRect; |
| 55 struct WebSize; | 56 struct WebSize; |
| 56 struct WebURLError; | 57 struct WebURLError; |
| 57 | 58 |
| 58 class WebFrameClient { | 59 class WebFrameClient { |
| 59 public: | 60 public: |
| 60 // Factory methods ----------------------------------------------------- | 61 // Factory methods ----------------------------------------------------- |
| 61 | 62 |
| 62 // May return null. | 63 // May return null. |
| 63 virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) = 0; | 64 virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) { return 0; } |
| 64 | 65 |
| 65 // May return null. | 66 // May return null. |
| 66 virtual WebWorker* createWorker(WebFrame*, WebWorkerClient*) = 0; | 67 virtual WebWorker* createWorker(WebFrame*, WebWorkerClient*) { return 0; } |
| 67 | 68 |
| 68 // May return null. | 69 // May return null. |
| 69 virtual WebMediaPlayer* createMediaPlayer(WebFrame*, WebMediaPlayerClient*) = 0; | 70 virtual WebMediaPlayer* createMediaPlayer(WebFrame*, WebMediaPlayerClient*) { return 0; } |
| 70 | 71 |
| 71 | 72 |
| 72 // General notifications ----------------------------------------------- | 73 // General notifications ----------------------------------------------- |
| 73 | 74 |
| 74 // This frame is about to be closed. | 75 // This frame is about to be closed. |
| 75 virtual void willClose(WebFrame*) = 0; | 76 virtual void willClose(WebFrame*) { } |
| 76 | 77 |
| 77 | 78 |
| 78 // Load commands ------------------------------------------------------- | 79 // Load commands ------------------------------------------------------- |
| 79 | 80 |
| 80 // The client should handle the navigation externally. | 81 // The client should handle the navigation externally. |
| 81 virtual void loadURLExternally( | 82 virtual void loadURLExternally( |
| 82 WebFrame*, const WebURLRequest&, WebNavigationPolicy) = 0; | 83 WebFrame*, const WebURLRequest&, WebNavigationPolicy) { } |
| 83 | 84 |
| 84 | 85 |
| 85 // Navigational queries ------------------------------------------------ | 86 // Navigational queries ------------------------------------------------ |
| 86 | 87 |
| 87 // The client may choose to alter the navigation policy. Otherwise, | 88 // The client may choose to alter the navigation policy. Otherwise, |
| 88 // defaultPolicy should just be returned. | 89 // defaultPolicy should just be returned. |
| 89 virtual WebNavigationPolicy decidePolicyForNavigation( | 90 virtual WebNavigationPolicy decidePolicyForNavigation( |
| 90 WebFrame*, const WebURLRequest&, WebNavigationType, | 91 WebFrame*, const WebURLRequest&, WebNavigationType, |
| 91 const WebNode& originatingNode, | 92 const WebNode& originatingNode, |
| 92 WebNavigationPolicy defaultPolicy, bool isRedirect) = 0; | 93 WebNavigationPolicy defaultPolicy, bool isRedirect) |
| 94 { | |
| 95 return defaultPolicy; | |
| 96 } | |
| 93 | 97 |
| 94 // Query if the specified request can be handled. | 98 // Query if the specified request can be handled. |
| 95 virtual bool canHandleRequest( | 99 virtual bool canHandleRequest( |
| 96 WebFrame*, const WebURLRequest& request) = 0; | 100 WebFrame*, const WebURLRequest& request) { return true; } |
| 97 | 101 |
| 98 // Returns an error corresponding to canHandledRequest() returning false. | 102 // Returns an error corresponding to canHandledRequest() returning false. |
| 99 virtual WebURLError cannotHandleRequestError( | 103 virtual WebURLError cannotHandleRequestError( |
| 100 WebFrame*, const WebURLRequest& request) = 0; | 104 WebFrame*, const WebURLRequest& request) { return WebURLError(); } |
| 101 | 105 |
| 102 // Returns an error corresponding to a user cancellation event. | 106 // Returns an error corresponding to a user cancellation event. |
| 103 virtual WebURLError cancelledError( | 107 virtual WebURLError cancelledError( |
| 104 WebFrame*, const WebURLRequest& request) = 0; | 108 WebFrame*, const WebURLRequest& request) { return WebURLError(); } |
| 105 | 109 |
| 106 // Notify that a URL cannot be handled. | 110 // Notify that a URL cannot be handled. |
| 107 virtual void unableToImplementPolicyWithError( | 111 virtual void unableToImplementPolicyWithError( |
| 108 WebFrame*, const WebURLError&) = 0; | 112 WebFrame*, const WebURLError&) { }; |
|
darin (slow to review)
2009/10/29 20:05:44
nit: kill the trailing ';' here and in other simil
| |
| 109 | 113 |
| 110 | 114 |
| 111 // Navigational notifications ------------------------------------------ | 115 // Navigational notifications ------------------------------------------ |
| 112 | 116 |
| 113 // A form submission is about to occur. | 117 // A form submission is about to occur. |
| 114 virtual void willSubmitForm(WebFrame*, const WebForm&) = 0; | 118 virtual void willSubmitForm(WebFrame*, const WebForm&) { }; |
| 115 | 119 |
| 116 // A client-side redirect will occur. This may correspond to a <META | 120 // A client-side redirect will occur. This may correspond to a <META |
| 117 // refresh> or some script activity. | 121 // refresh> or some script activity. |
| 118 virtual void willPerformClientRedirect( | 122 virtual void willPerformClientRedirect( |
| 119 WebFrame*, const WebURL& from, const WebURL& to, | 123 WebFrame*, const WebURL& from, const WebURL& to, |
| 120 double interval, double fireTime) = 0; | 124 double interval, double fireTime) { }; |
| 121 | 125 |
| 122 // A client-side redirect was cancelled. | 126 // A client-side redirect was cancelled. |
| 123 virtual void didCancelClientRedirect(WebFrame*) = 0; | 127 virtual void didCancelClientRedirect(WebFrame*) { } |
| 124 | 128 |
| 125 // A client-side redirect completed. | 129 // A client-side redirect completed. |
| 126 virtual void didCompleteClientRedirect(WebFrame*, const WebURL& fromURL) = 0; | 130 virtual void didCompleteClientRedirect(WebFrame*, const WebURL& fromURL) { } |
| 127 | 131 |
| 128 // A datasource has been created for a new navigation. The given | 132 // A datasource has been created for a new navigation. The given |
| 129 // datasource will become the provisional datasource for the frame. | 133 // datasource will become the provisional datasource for the frame. |
| 130 virtual void didCreateDataSource(WebFrame*, WebDataSource*) = 0; | 134 virtual void didCreateDataSource(WebFrame*, WebDataSource*) { } |
| 131 | 135 |
| 132 // A new provisional load has been started. | 136 // A new provisional load has been started. |
| 133 virtual void didStartProvisionalLoad(WebFrame*) = 0; | 137 virtual void didStartProvisionalLoad(WebFrame*) { } |
| 134 | 138 |
| 135 // The provisional load was redirected via a HTTP 3xx response. | 139 // The provisional load was redirected via a HTTP 3xx response. |
| 136 virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) = 0; | 140 virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) { } |
| 137 | 141 |
| 138 // The provisional load failed. | 142 // The provisional load failed. |
| 139 virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) = 0; | 143 virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) { } |
| 140 | 144 |
| 141 // Notifies the client to commit data for the given frame. The client | 145 // Notifies the client to commit data for the given frame. The client |
| 142 // may optionally prevent default processing by setting preventDefault | 146 // may optionally prevent default processing by setting preventDefault |
| 143 // to true before returning. If default processing is prevented, then | 147 // to true before returning. If default processing is prevented, then |
| 144 // it is up to the client to manually call commitDocumentData on the | 148 // it is up to the client to manually call commitDocumentData on the |
| 145 // WebFrame. It is only valid to call commitDocumentData within a call | 149 // WebFrame. It is only valid to call commitDocumentData within a call |
| 146 // to didReceiveDocumentData. If commitDocumentData is not called, | 150 // to didReceiveDocumentData. If commitDocumentData is not called, |
| 147 // then an empty document will be loaded. | 151 // then an empty document will be loaded. |
| 148 virtual void didReceiveDocumentData( | 152 virtual void didReceiveDocumentData( |
| 149 WebFrame*, const char* data, size_t length, bool& preventDefault) = 0; | 153 WebFrame*, const char* data, size_t length, bool& preventDefault) { } |
| 150 | 154 |
| 151 // The provisional datasource is now committed. The first part of the | 155 // The provisional datasource is now committed. The first part of the |
| 152 // response body has been received, and the encoding of the response | 156 // response body has been received, and the encoding of the response |
| 153 // body is known. | 157 // body is known. |
| 154 virtual void didCommitProvisionalLoad(WebFrame*, bool isNewNavigation) = 0; | 158 virtual void didCommitProvisionalLoad(WebFrame*, bool isNewNavigation) { } |
| 155 | 159 |
| 156 // The window object for the frame has been cleared of any extra | 160 // The window object for the frame has been cleared of any extra |
| 157 // properties that may have been set by script from the previously | 161 // properties that may have been set by script from the previously |
| 158 // loaded document. | 162 // loaded document. |
| 159 virtual void didClearWindowObject(WebFrame*) = 0; | 163 virtual void didClearWindowObject(WebFrame*) { } |
| 160 | 164 |
| 161 // The document element has been created. | 165 // The document element has been created. |
| 162 virtual void didCreateDocumentElement(WebFrame*) = 0; | 166 virtual void didCreateDocumentElement(WebFrame*) { } |
| 163 | 167 |
| 164 // The page title is available. | 168 // The page title is available. |
| 165 virtual void didReceiveTitle(WebFrame*, const WebString& title) = 0; | 169 virtual void didReceiveTitle(WebFrame*, const WebString& title) { } |
| 166 | 170 |
| 167 // The frame's document finished loading. | 171 // The frame's document finished loading. |
| 168 virtual void didFinishDocumentLoad(WebFrame*) = 0; | 172 virtual void didFinishDocumentLoad(WebFrame*) { } |
| 169 | 173 |
| 170 // The 'load' event was dispatched. | 174 // The 'load' event was dispatched. |
| 171 virtual void didHandleOnloadEvents(WebFrame*) = 0; | 175 virtual void didHandleOnloadEvents(WebFrame*) { } |
| 172 | 176 |
| 173 // The frame's document or one of its subresources failed to load. | 177 // The frame's document or one of its subresources failed to load. |
| 174 virtual void didFailLoad(WebFrame*, const WebURLError&) = 0; | 178 virtual void didFailLoad(WebFrame*, const WebURLError&) { } |
| 175 | 179 |
| 176 // The frame's document and all of its subresources succeeded to load. | 180 // The frame's document and all of its subresources succeeded to load. |
| 177 virtual void didFinishLoad(WebFrame*) = 0; | 181 virtual void didFinishLoad(WebFrame*) { } |
| 178 | 182 |
| 179 // The navigation resulted in scrolling the page to a named anchor instead | 183 // The navigation resulted in scrolling the page to a named anchor instead |
| 180 // of downloading a new document. | 184 // of downloading a new document. |
| 181 virtual void didChangeLocationWithinPage(WebFrame*, bool isNewNavigation) = 0; | 185 virtual void didChangeLocationWithinPage(WebFrame*, bool isNewNavigation) { } |
| 182 | 186 |
| 183 // Called upon update to scroll position, document state, and other | 187 // Called upon update to scroll position, document state, and other |
| 184 // non-navigational events related to the data held by WebHistoryItem. | 188 // non-navigational events related to the data held by WebHistoryItem. |
| 185 // WARNING: This method may be called very frequently. | 189 // WARNING: This method may be called very frequently. |
| 186 virtual void didUpdateCurrentHistoryItem(WebFrame*) = 0; | 190 virtual void didUpdateCurrentHistoryItem(WebFrame*) { } |
| 187 | 191 |
| 188 | 192 |
| 189 // Low-level resource notifications ------------------------------------ | 193 // Low-level resource notifications ------------------------------------ |
| 190 | 194 |
| 191 // An identifier was assigned to the specified request. The client | 195 // An identifier was assigned to the specified request. The client |
| 192 // should remember this association if interested in subsequent events. | 196 // should remember this association if interested in subsequent events. |
| 193 virtual void assignIdentifierToRequest( | 197 virtual void assignIdentifierToRequest( |
| 194 WebFrame*, unsigned identifier, const WebURLRequest&) = 0; | 198 WebFrame*, unsigned identifier, const WebURLRequest&) { } |
| 195 | 199 |
| 196 // A request is about to be sent out, and the client may modify it. Request | 200 // A request is about to be sent out, and the client may modify it. Request |
| 197 // is writable, and changes to the URL, for example, will change the request | 201 // is writable, and changes to the URL, for example, will change the request |
| 198 // made. If this request is the result of a redirect, then redirectResponse | 202 // made. If this request is the result of a redirect, then redirectResponse |
| 199 // will be non-null and contain the response that triggered the redirect. | 203 // will be non-null and contain the response that triggered the redirect. |
| 200 virtual void willSendRequest( | 204 virtual void willSendRequest( |
| 201 WebFrame*, unsigned identifier, WebURLRequest&, | 205 WebFrame*, unsigned identifier, WebURLRequest&, |
| 202 const WebURLResponse& redirectResponse) = 0; | 206 const WebURLResponse& redirectResponse) { } |
| 203 | 207 |
| 204 // Response headers have been received for the resource request given | 208 // Response headers have been received for the resource request given |
| 205 // by identifier. | 209 // by identifier. |
| 206 virtual void didReceiveResponse( | 210 virtual void didReceiveResponse( |
| 207 WebFrame*, unsigned identifier, const WebURLResponse&) = 0; | 211 WebFrame*, unsigned identifier, const WebURLResponse&) { } |
| 208 | 212 |
| 209 // The resource request given by identifier succeeded. | 213 // The resource request given by identifier succeeded. |
| 210 virtual void didFinishResourceLoad( | 214 virtual void didFinishResourceLoad( |
| 211 WebFrame*, unsigned identifier) = 0; | 215 WebFrame*, unsigned identifier) { } |
| 212 | 216 |
| 213 // The resource request given by identifier failed. | 217 // The resource request given by identifier failed. |
| 214 virtual void didFailResourceLoad( | 218 virtual void didFailResourceLoad( |
| 215 WebFrame*, unsigned identifier, const WebURLError&) = 0; | 219 WebFrame*, unsigned identifier, const WebURLError&) { } |
| 216 | 220 |
| 217 // The specified request was satified from WebCore's memory cache. | 221 // The specified request was satified from WebCore's memory cache. |
| 218 virtual void didLoadResourceFromMemoryCache( | 222 virtual void didLoadResourceFromMemoryCache( |
| 219 WebFrame*, const WebURLRequest&, const WebURLResponse&) = 0; | 223 WebFrame*, const WebURLRequest&, const WebURLResponse&) { } |
| 220 | 224 |
| 221 // This frame has displayed inactive content (such as an image) from an | 225 // This frame has displayed inactive content (such as an image) from an |
| 222 // insecure source. Inactive content cannot spread to other frames. | 226 // insecure source. Inactive content cannot spread to other frames. |
| 223 virtual void didDisplayInsecureContent(WebFrame*) = 0; | 227 virtual void didDisplayInsecureContent(WebFrame*) { } |
| 224 | 228 |
| 225 // The indicated security origin has run active content (such as a | 229 // The indicated security origin has run active content (such as a |
| 226 // script) from an insecure source. Note that the insecure content can | 230 // script) from an insecure source. Note that the insecure content can |
| 227 // spread to other frames in the same origin. | 231 // spread to other frames in the same origin. |
| 228 virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&) = 0; | 232 virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&) { } |
| 229 | 233 |
| 230 | 234 |
| 231 // Script notifications ------------------------------------------------ | 235 // Script notifications ------------------------------------------------ |
| 232 | 236 |
| 233 // Script in the page tried to allocate too much memory. | 237 // Script in the page tried to allocate too much memory. |
| 234 virtual void didExhaustMemoryAvailableForScript(WebFrame*) = 0; | 238 virtual void didExhaustMemoryAvailableForScript(WebFrame*) { } |
| 235 | 239 |
| 236 // Notifies that a new script context has been created for this frame. | 240 // Notifies that a new script context has been created for this frame. |
| 237 // This is similar to didClearWindowObject but only called once per | 241 // This is similar to didClearWindowObject but only called once per |
| 238 // frame context. | 242 // frame context. |
| 239 virtual void didCreateScriptContext(WebFrame*) = 0; | 243 virtual void didCreateScriptContext(WebFrame*) { } |
| 240 | 244 |
| 241 // Notifies that this frame's script context has been destroyed. | 245 // Notifies that this frame's script context has been destroyed. |
| 242 virtual void didDestroyScriptContext(WebFrame*) = 0; | 246 virtual void didDestroyScriptContext(WebFrame*) { } |
| 243 | 247 |
| 244 // Notifies that a garbage-collected context was created - content | 248 // Notifies that a garbage-collected context was created - content |
| 245 // scripts. | 249 // scripts. |
| 246 virtual void didCreateIsolatedScriptContext(WebFrame*) = 0; | 250 virtual void didCreateIsolatedScriptContext(WebFrame*) { } |
| 247 | 251 |
| 248 | 252 |
| 249 // Geometry notifications ---------------------------------------------- | 253 // Geometry notifications ---------------------------------------------- |
| 250 | 254 |
| 251 // The size of the content area changed. | 255 // The size of the content area changed. |
| 252 virtual void didChangeContentsSize(WebFrame*, const WebSize&) = 0; | 256 virtual void didChangeContentsSize(WebFrame*, const WebSize&) { } |
| 253 | 257 |
| 254 | 258 |
| 255 // Find-in-page notifications ------------------------------------------ | 259 // Find-in-page notifications ------------------------------------------ |
| 256 | 260 |
| 257 // Notifies how many matches have been found so far, for a given | 261 // Notifies how many matches have been found so far, for a given |
| 258 // identifier. |finalUpdate| specifies whether this is the last update | 262 // identifier. |finalUpdate| specifies whether this is the last update |
| 259 // (all frames have completed scoping). | 263 // (all frames have completed scoping). |
| 260 virtual void reportFindInPageMatchCount( | 264 virtual void reportFindInPageMatchCount( |
| 261 int identifier, int count, bool finalUpdate) = 0; | 265 int identifier, int count, bool finalUpdate) { } |
| 262 | 266 |
| 263 // Notifies what tick-mark rect is currently selected. The given | 267 // Notifies what tick-mark rect is currently selected. The given |
| 264 // identifier lets the client know which request this message belongs | 268 // identifier lets the client know which request this message belongs |
| 265 // to, so that it can choose to ignore the message if it has moved on | 269 // to, so that it can choose to ignore the message if it has moved on |
| 266 // to other things. The selection rect is expected to have coordinates | 270 // to other things. The selection rect is expected to have coordinates |
| 267 // relative to the top left corner of the web page area and represent | 271 // relative to the top left corner of the web page area and represent |
| 268 // where on the screen the selection rect is currently located. | 272 // where on the screen the selection rect is currently located. |
| 269 virtual void reportFindInPageSelection( | 273 virtual void reportFindInPageSelection( |
| 270 int identifier, int activeMatchOrdinal, const WebRect& selection) = 0; | 274 int identifier, int activeMatchOrdinal, const WebRect& selection) { } |
| 271 | 275 |
| 272 protected: | 276 protected: |
| 273 ~WebFrameClient() { } | 277 ~WebFrameClient() { } |
| 274 }; | 278 }; |
| 275 | 279 |
| 276 } // namespace WebKit | 280 } // namespace WebKit |
| 277 | 281 |
| 278 #endif | 282 #endif |
| OLD | NEW |