| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #ifndef WebFrameClient_h | |
| 32 #define WebFrameClient_h | |
| 33 | |
| 34 #include "../platform/WebCommon.h" | |
| 35 #include "../platform/WebFileSystem.h" | |
| 36 #include "../platform/WebFileSystemType.h" | |
| 37 #include "../platform/WebURLError.h" | |
| 38 #include "../platform/WebURLRequest.h" | |
| 39 #include "WebDOMMessageEvent.h" | |
| 40 #include "WebIconURL.h" | |
| 41 #include "WebNavigationPolicy.h" | |
| 42 #include "WebNavigationType.h" | |
| 43 #include "WebSecurityOrigin.h" | |
| 44 #include "WebStorageQuotaType.h" | |
| 45 #include "WebTextDirection.h" | |
| 46 #include <v8.h> | |
| 47 | |
| 48 namespace WebKit { | |
| 49 | |
| 50 class WebApplicationCacheHost; | |
| 51 class WebApplicationCacheHostClient; | |
| 52 class WebCachedURLRequest; | |
| 53 class WebCookieJar; | |
| 54 class WebDataSource; | |
| 55 class WebDOMEvent; | |
| 56 class WebFormElement; | |
| 57 class WebFrame; | |
| 58 class WebMediaPlayer; | |
| 59 class WebMediaPlayerClient; | |
| 60 class WebNode; | |
| 61 class WebPlugin; | |
| 62 class WebRTCPeerConnectionHandler; | |
| 63 class WebSharedWorker; | |
| 64 class WebSharedWorkerClient; | |
| 65 class WebSocketStreamHandle; | |
| 66 class WebStorageQuotaCallbacks; | |
| 67 class WebString; | |
| 68 class WebURL; | |
| 69 class WebURLLoader; | |
| 70 class WebURLResponse; | |
| 71 class WebWorker; | |
| 72 struct WebPluginParams; | |
| 73 struct WebRect; | |
| 74 struct WebSize; | |
| 75 struct WebURLError; | |
| 76 | |
| 77 class WebFrameClient { | |
| 78 public: | |
| 79 // Factory methods ----------------------------------------------------- | |
| 80 | |
| 81 // May return null. | |
| 82 virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) { return
0; } | |
| 83 | |
| 84 // May return null. | |
| 85 virtual WebSharedWorker* createSharedWorker(WebFrame*, const WebURL&, const
WebString&, unsigned long long) { return 0; } | |
| 86 | |
| 87 // May return null. | |
| 88 virtual WebMediaPlayer* createMediaPlayer(WebFrame*, const WebURL&, WebMedia
PlayerClient*) { return 0; } | |
| 89 | |
| 90 // May return null. | |
| 91 virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebAp
plicationCacheHostClient*) { return 0; } | |
| 92 | |
| 93 | |
| 94 // Services ------------------------------------------------------------ | |
| 95 | |
| 96 // A frame specific cookie jar. May return null, in which case | |
| 97 // WebKitPlatformSupport::cookieJar() will be called to access cookies. | |
| 98 virtual WebCookieJar* cookieJar(WebFrame*) { return 0; } | |
| 99 | |
| 100 | |
| 101 // General notifications ----------------------------------------------- | |
| 102 | |
| 103 // Indicates that another page has accessed the DOM of the initial empty | |
| 104 // document of a main frame. After this, it is no longer safe to show a | |
| 105 // pending navigation's URL, because a URL spoof is possible. | |
| 106 virtual void didAccessInitialDocument(WebFrame*) { } | |
| 107 | |
| 108 // A child frame was created in this frame. This is called when the frame | |
| 109 // is created and initialized. | |
| 110 virtual void didCreateFrame(WebFrame* parent, WebFrame* child) { } | |
| 111 | |
| 112 // This frame set its opener to null, disowning it. | |
| 113 // See http://html.spec.whatwg.org/#dom-opener. | |
| 114 virtual void didDisownOpener(WebFrame*) { } | |
| 115 | |
| 116 // This frame has been detached from the view, but has not been closed yet. | |
| 117 virtual void frameDetached(WebFrame*) { } | |
| 118 | |
| 119 // This frame is about to be closed. This is called after frameDetached, | |
| 120 // when the document is being unloaded, due to new one committing. | |
| 121 virtual void willClose(WebFrame*) { } | |
| 122 | |
| 123 // This frame's name has changed. | |
| 124 virtual void didChangeName(WebFrame*, const WebString&) { } | |
| 125 | |
| 126 // Load commands ------------------------------------------------------- | |
| 127 | |
| 128 // The client should handle the navigation externally. | |
| 129 virtual void loadURLExternally( | |
| 130 WebFrame*, const WebURLRequest&, WebNavigationPolicy) { } | |
| 131 virtual void loadURLExternally( | |
| 132 WebFrame*, const WebURLRequest&, WebNavigationPolicy, const WebString& d
ownloadName) { } | |
| 133 | |
| 134 | |
| 135 // Navigational queries ------------------------------------------------ | |
| 136 | |
| 137 // The client may choose to alter the navigation policy. Otherwise, | |
| 138 // defaultPolicy should just be returned. | |
| 139 virtual WebNavigationPolicy decidePolicyForNavigation( | |
| 140 WebFrame*, const WebURLRequest&, WebNavigationType, | |
| 141 WebNavigationPolicy defaultPolicy, bool isRedirect) { return defaultPoli
cy; } | |
| 142 | |
| 143 // Returns an error corresponding to canHandledRequest() returning false. | |
| 144 virtual WebURLError cannotHandleRequestError( | |
| 145 WebFrame*, const WebURLRequest& request) { return WebURLError(); } | |
| 146 | |
| 147 // Returns an error corresponding to a user cancellation event. | |
| 148 virtual WebURLError cancelledError( | |
| 149 WebFrame*, const WebURLRequest& request) { return WebURLError(); } | |
| 150 | |
| 151 // Notify that a URL cannot be handled. | |
| 152 virtual void unableToImplementPolicyWithError( | |
| 153 WebFrame*, const WebURLError&) { } | |
| 154 | |
| 155 | |
| 156 // Navigational notifications ------------------------------------------ | |
| 157 | |
| 158 // A form submission has been requested, but the page's submit event handler | |
| 159 // hasn't yet had a chance to run (and possibly alter/interrupt the submit.) | |
| 160 virtual void willSendSubmitEvent(WebFrame*, const WebFormElement&) { } | |
| 161 | |
| 162 // A form submission is about to occur. | |
| 163 virtual void willSubmitForm(WebFrame*, const WebFormElement&) { } | |
| 164 | |
| 165 // A client-side redirect will occur. This may correspond to a <META | |
| 166 // refresh> or some script activity. | |
| 167 virtual void willPerformClientRedirect( | |
| 168 WebFrame*, const WebURL& from, const WebURL& to, | |
| 169 double interval, double fireTime) { } | |
| 170 | |
| 171 // A client-side redirect was cancelled. | |
| 172 virtual void didCancelClientRedirect(WebFrame*) { } | |
| 173 | |
| 174 // A client-side redirect completed. | |
| 175 virtual void didCompleteClientRedirect(WebFrame*, const WebURL& fromURL) { } | |
| 176 | |
| 177 // A datasource has been created for a new navigation. The given | |
| 178 // datasource will become the provisional datasource for the frame. | |
| 179 virtual void didCreateDataSource(WebFrame*, WebDataSource*) { } | |
| 180 | |
| 181 // A new provisional load has been started. | |
| 182 virtual void didStartProvisionalLoad(WebFrame*) { } | |
| 183 | |
| 184 // The provisional load was redirected via a HTTP 3xx response. | |
| 185 virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) { } | |
| 186 | |
| 187 // The provisional load failed. | |
| 188 virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) { } | |
| 189 | |
| 190 // Notifies the client to commit data for the given frame. The client | |
| 191 // may optionally prevent default processing by setting preventDefault | |
| 192 // to true before returning. If default processing is prevented, then | |
| 193 // it is up to the client to manually call commitDocumentData on the | |
| 194 // WebFrame. It is only valid to call commitDocumentData within a call | |
| 195 // to didReceiveDocumentData. If commitDocumentData is not called, | |
| 196 // then an empty document will be loaded. | |
| 197 virtual void didReceiveDocumentData( | |
| 198 WebFrame*, const char* data, size_t length, bool& preventDefault) { } | |
| 199 | |
| 200 // The provisional datasource is now committed. The first part of the | |
| 201 // response body has been received, and the encoding of the response | |
| 202 // body is known. | |
| 203 virtual void didCommitProvisionalLoad(WebFrame*, bool isNewNavigation) { } | |
| 204 | |
| 205 // The window object for the frame has been cleared of any extra | |
| 206 // properties that may have been set by script from the previously | |
| 207 // loaded document. | |
| 208 virtual void didClearWindowObject(WebFrame*) { } | |
| 209 | |
| 210 // The document element has been created. | |
| 211 virtual void didCreateDocumentElement(WebFrame*) { } | |
| 212 | |
| 213 // The page title is available. | |
| 214 virtual void didReceiveTitle(WebFrame* frame, const WebString& title, WebTex
tDirection direction) { } | |
| 215 | |
| 216 // The icon for the page have changed. | |
| 217 virtual void didChangeIcon(WebFrame*, WebIconURL::Type) { } | |
| 218 | |
| 219 // The frame's document finished loading. | |
| 220 virtual void didFinishDocumentLoad(WebFrame*) { } | |
| 221 | |
| 222 // The 'load' event was dispatched. | |
| 223 virtual void didHandleOnloadEvents(WebFrame*) { } | |
| 224 | |
| 225 // The frame's document or one of its subresources failed to load. | |
| 226 virtual void didFailLoad(WebFrame*, const WebURLError&) { } | |
| 227 | |
| 228 // The frame's document and all of its subresources succeeded to load. | |
| 229 virtual void didFinishLoad(WebFrame*) { } | |
| 230 | |
| 231 // The navigation resulted in no change to the documents within the page. | |
| 232 // For example, the navigation may have just resulted in scrolling to a | |
| 233 // named anchor or a PopState event may have been dispatched. | |
| 234 virtual void didNavigateWithinPage(WebFrame*, bool isNewNavigation) { } | |
| 235 | |
| 236 // The navigation resulted in scrolling the page to a named anchor instead | |
| 237 // of downloading a new document. | |
| 238 virtual void didChangeLocationWithinPage(WebFrame*) { } | |
| 239 | |
| 240 // Called upon update to scroll position, document state, and other | |
| 241 // non-navigational events related to the data held by WebHistoryItem. | |
| 242 // WARNING: This method may be called very frequently. | |
| 243 virtual void didUpdateCurrentHistoryItem(WebFrame*) { } | |
| 244 | |
| 245 | |
| 246 // Low-level resource notifications ------------------------------------ | |
| 247 | |
| 248 // An element will request a resource. | |
| 249 virtual void willRequestResource(WebFrame*, const WebCachedURLRequest&) { } | |
| 250 | |
| 251 // A request is about to be sent out, and the client may modify it. Request | |
| 252 // is writable, and changes to the URL, for example, will change the request | |
| 253 // made. If this request is the result of a redirect, then redirectResponse | |
| 254 // will be non-null and contain the response that triggered the redirect. | |
| 255 virtual void willSendRequest( | |
| 256 WebFrame*, unsigned identifier, WebURLRequest&, | |
| 257 const WebURLResponse& redirectResponse) { } | |
| 258 | |
| 259 // Response headers have been received for the resource request given | |
| 260 // by identifier. | |
| 261 virtual void didReceiveResponse( | |
| 262 WebFrame*, unsigned identifier, const WebURLResponse&) { } | |
| 263 | |
| 264 virtual void didChangeResourcePriority( | |
| 265 WebFrame*, unsigned identifier, const WebKit::WebURLRequest::Priority&)
{ } | |
| 266 | |
| 267 // The resource request given by identifier succeeded. | |
| 268 virtual void didFinishResourceLoad( | |
| 269 WebFrame*, unsigned identifier) { } | |
| 270 | |
| 271 // The resource request given by identifier failed. | |
| 272 virtual void didFailResourceLoad( | |
| 273 WebFrame*, unsigned identifier, const WebURLError&) { } | |
| 274 | |
| 275 // The specified request was satified from WebCore's memory cache. | |
| 276 virtual void didLoadResourceFromMemoryCache( | |
| 277 WebFrame*, const WebURLRequest&, const WebURLResponse&) { } | |
| 278 | |
| 279 // This frame has displayed inactive content (such as an image) from an | |
| 280 // insecure source. Inactive content cannot spread to other frames. | |
| 281 virtual void didDisplayInsecureContent(WebFrame*) { } | |
| 282 | |
| 283 // The indicated security origin has run active content (such as a | |
| 284 // script) from an insecure source. Note that the insecure content can | |
| 285 // spread to other frames in the same origin. | |
| 286 virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&, cons
t WebURL& insecureURL) { } | |
| 287 | |
| 288 // A reflected XSS was encountered in the page and suppressed. | |
| 289 virtual void didDetectXSS(WebFrame*, const WebURL&, bool didBlockEntirePage)
{ } | |
| 290 | |
| 291 // Script notifications ------------------------------------------------ | |
| 292 | |
| 293 // Script in the page tried to allocate too much memory. | |
| 294 virtual void didExhaustMemoryAvailableForScript(WebFrame*) { } | |
| 295 | |
| 296 // Notifies that a new script context has been created for this frame. | |
| 297 // This is similar to didClearWindowObject but only called once per | |
| 298 // frame context. | |
| 299 virtual void didCreateScriptContext(WebFrame*, v8::Handle<v8::Context>, int
extensionGroup, int worldId) { } | |
| 300 | |
| 301 // WebKit is about to release its reference to a v8 context for a frame. | |
| 302 virtual void willReleaseScriptContext(WebFrame*, v8::Handle<v8::Context>, in
t worldId) { } | |
| 303 | |
| 304 // Geometry notifications ---------------------------------------------- | |
| 305 | |
| 306 // The frame's document finished the initial layout of a page. | |
| 307 virtual void didFirstLayout(WebFrame*) { } | |
| 308 | |
| 309 // The frame's document finished the initial non-empty layout of a page. | |
| 310 virtual void didFirstVisuallyNonEmptyLayout(WebFrame*) { } | |
| 311 | |
| 312 // The size of the content area changed. | |
| 313 virtual void didChangeContentsSize(WebFrame*, const WebSize&) { } | |
| 314 | |
| 315 // The main frame scrolled. | |
| 316 virtual void didChangeScrollOffset(WebFrame*) { } | |
| 317 | |
| 318 // If the frame is loading an HTML document, this will be called to | |
| 319 // notify that the <body> will be attached soon. | |
| 320 virtual void willInsertBody(WebFrame*) { } | |
| 321 | |
| 322 // Find-in-page notifications ------------------------------------------ | |
| 323 | |
| 324 // Notifies how many matches have been found so far, for a given | |
| 325 // identifier. |finalUpdate| specifies whether this is the last update | |
| 326 // (all frames have completed scoping). | |
| 327 virtual void reportFindInPageMatchCount( | |
| 328 int identifier, int count, bool finalUpdate) { } | |
| 329 | |
| 330 // Notifies what tick-mark rect is currently selected. The given | |
| 331 // identifier lets the client know which request this message belongs | |
| 332 // to, so that it can choose to ignore the message if it has moved on | |
| 333 // to other things. The selection rect is expected to have coordinates | |
| 334 // relative to the top left corner of the web page area and represent | |
| 335 // where on the screen the selection rect is currently located. | |
| 336 virtual void reportFindInPageSelection( | |
| 337 int identifier, int activeMatchOrdinal, const WebRect& selection) { } | |
| 338 | |
| 339 // FileSystem ---------------------------------------------------- | |
| 340 | |
| 341 // Requests to open a FileSystem. | |
| 342 // |size| indicates how much storage space (in bytes) the caller expects | |
| 343 // to need. | |
| 344 // WebFileSystemCallbacks::didOpenFileSystem() must be called with | |
| 345 // a name and root path for the requested FileSystem when the operation | |
| 346 // is completed successfully. WebFileSystemCallbacks::didFail() must be | |
| 347 // called otherwise. The create bool is for indicating whether or not to | |
| 348 // create root path for file systems if it do not exist. | |
| 349 virtual void openFileSystem( | |
| 350 WebFrame*, WebFileSystemType, long long size, | |
| 351 bool create, WebFileSystemCallbacks*) { } | |
| 352 | |
| 353 // Deletes FileSystem. | |
| 354 // WebFileSystemCallbacks::didSucceed() must be called when the operation | |
| 355 // is completed successfully. WebFileSystemCallbacks::didFail() must be | |
| 356 // called otherwise. | |
| 357 // All in-flight operations and following operations may fail after the | |
| 358 // FileSystem is deleted. | |
| 359 virtual void deleteFileSystem( | |
| 360 WebFrame*, WebFileSystemType, WebFileSystemCallbacks*) { } | |
| 361 | |
| 362 // Quota --------------------------------------------------------- | |
| 363 | |
| 364 // Queries the origin's storage usage and quota information. | |
| 365 // WebStorageQuotaCallbacks::didQueryStorageUsageAndQuota will be called | |
| 366 // with the current usage and quota information for the origin. When | |
| 367 // an error occurs WebStorageQuotaCallbacks::didFail is called with an | |
| 368 // error code. | |
| 369 // The callbacks object is deleted when the callback method is called | |
| 370 // and does not need to be (and should not be) deleted manually. | |
| 371 virtual void queryStorageUsageAndQuota( | |
| 372 WebFrame*, WebStorageQuotaType, WebStorageQuotaCallbacks*) { } | |
| 373 | |
| 374 // Requests a new quota size for the origin's storage. | |
| 375 // |newQuotaInBytes| indicates how much storage space (in bytes) the | |
| 376 // caller expects to need. | |
| 377 // WebStorageQuotaCallbacks::didGrantStorageQuota will be called when | |
| 378 // a new quota is granted. WebStorageQuotaCallbacks::didFail | |
| 379 // is called with an error code otherwise. | |
| 380 // Note that the requesting quota size may not always be granted and | |
| 381 // a smaller amount of quota than requested might be returned. | |
| 382 // The callbacks object is deleted when the callback method is called | |
| 383 // and does not need to be (and should not be) deleted manually. | |
| 384 virtual void requestStorageQuota( | |
| 385 WebFrame*, WebStorageQuotaType, | |
| 386 unsigned long long newQuotaInBytes, | |
| 387 WebStorageQuotaCallbacks*) { } | |
| 388 | |
| 389 // WebSocket ----------------------------------------------------- | |
| 390 | |
| 391 // A WebSocket object is going to open new stream connection. | |
| 392 virtual void willOpenSocketStream(WebSocketStreamHandle*) { } | |
| 393 | |
| 394 // MediaStream ----------------------------------------------------- | |
| 395 | |
| 396 // A new WebRTCPeerConnectionHandler is created. | |
| 397 virtual void willStartUsingPeerConnectionHandler(WebFrame*, WebRTCPeerConnec
tionHandler*) { } | |
| 398 | |
| 399 // Messages ------------------------------------------------------ | |
| 400 | |
| 401 // Notifies the embedder that a postMessage was issued on this frame, and | |
| 402 // gives the embedder a chance to handle it instead of WebKit. Returns true | |
| 403 // if the embedder handled it. | |
| 404 virtual bool willCheckAndDispatchMessageEvent( | |
| 405 WebFrame* sourceFrame, | |
| 406 WebFrame* targetFrame, | |
| 407 WebSecurityOrigin target, | |
| 408 WebDOMMessageEvent event) { return false; } | |
| 409 | |
| 410 // Asks the embedder if a specific user agent should be used for the given | |
| 411 // URL. Non-empty strings indicate an override should be used. Otherwise, | |
| 412 // Platform::current()->userAgent() will be called to provide one. | |
| 413 virtual WebString userAgentOverride(WebFrame*, const WebURL& url) { return W
ebString(); } | |
| 414 | |
| 415 // Asks the embedder what value the network stack will send for the DNT | |
| 416 // header. An empty string indicates that no DNT header will be send. | |
| 417 virtual WebString doNotTrackValue(WebFrame*) { return WebString(); } | |
| 418 | |
| 419 // WebGL ------------------------------------------------------ | |
| 420 | |
| 421 // Asks the embedder whether WebGL is allowed for the given WebFrame. | |
| 422 // This call is placed here instead of WebPermissionClient because this | |
| 423 // class is implemented in content/, and putting it here avoids adding | |
| 424 // more public content/ APIs. | |
| 425 virtual bool allowWebGL(WebFrame*, bool defaultValue) { return defaultValue;
} | |
| 426 | |
| 427 // Notifies the client that a WebGL context was lost on this page with the | |
| 428 // given reason (one of the GL_ARB_robustness status codes; see | |
| 429 // Extensions3D.h in WebCore/platform/graphics). | |
| 430 virtual void didLoseWebGLContext(WebFrame*, int) { } | |
| 431 | |
| 432 protected: | |
| 433 ~WebFrameClient() { } | |
| 434 }; | |
| 435 | |
| 436 } // namespace WebKit | |
| 437 | |
| 438 #endif | |
| OLD | NEW |