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