diff options
author | yaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 21:26:20 +0000 |
---|---|---|
committer | yaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 21:26:20 +0000 |
commit | 410e1cf5baf2c4dd1c7eac1834642443e65ee385 (patch) | |
tree | e81b480144bc05296a3238e7848d62c8a575c2c3 | |
parent | bb05e45ae19103b8baece7c6d513ba2aa67fd422 (diff) | |
download | chromium_src-410e1cf5baf2c4dd1c7eac1834642443e65ee385.zip chromium_src-410e1cf5baf2c4dd1c7eac1834642443e65ee385.tar.gz chromium_src-410e1cf5baf2c4dd1c7eac1834642443e65ee385.tar.bz2 |
Adds default implementations to WebFrameClient
http://code.google.com/p/chromium/issues/detail?id=26068
Review URL: http://codereview.chromium.org/342024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30516 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/api/public/WebFrameClient.h | 92 | ||||
-rw-r--r-- | webkit/api/src/EmptyWebFrameClientImpl.h | 92 | ||||
-rw-r--r-- | webkit/api/src/WebWorkerImpl.cpp | 3 | ||||
-rw-r--r-- | webkit/webkit.gyp | 1 |
4 files changed, 49 insertions, 139 deletions
diff --git a/webkit/api/public/WebFrameClient.h b/webkit/api/public/WebFrameClient.h index b848cc3..d79a5b64 100644 --- a/webkit/api/public/WebFrameClient.h +++ b/webkit/api/public/WebFrameClient.h @@ -34,6 +34,7 @@ #include "WebCommon.h" #include "WebNavigationPolicy.h" #include "WebNavigationType.h" +#include "WebURLError.h" namespace WebKit { class WebDataSource; @@ -60,26 +61,26 @@ namespace WebKit { // Factory methods ----------------------------------------------------- // May return null. - virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) = 0; + virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) { return 0; } // May return null. - virtual WebWorker* createWorker(WebFrame*, WebWorkerClient*) = 0; + virtual WebWorker* createWorker(WebFrame*, WebWorkerClient*) { return 0; } // May return null. - virtual WebMediaPlayer* createMediaPlayer(WebFrame*, WebMediaPlayerClient*) = 0; + virtual WebMediaPlayer* createMediaPlayer(WebFrame*, WebMediaPlayerClient*) { return 0; } // General notifications ----------------------------------------------- // This frame is about to be closed. - virtual void willClose(WebFrame*) = 0; + virtual void willClose(WebFrame*) { } // Load commands ------------------------------------------------------- // The client should handle the navigation externally. virtual void loadURLExternally( - WebFrame*, const WebURLRequest&, WebNavigationPolicy) = 0; + WebFrame*, const WebURLRequest&, WebNavigationPolicy) { } // Navigational queries ------------------------------------------------ @@ -89,54 +90,57 @@ namespace WebKit { virtual WebNavigationPolicy decidePolicyForNavigation( WebFrame*, const WebURLRequest&, WebNavigationType, const WebNode& originatingNode, - WebNavigationPolicy defaultPolicy, bool isRedirect) = 0; + WebNavigationPolicy defaultPolicy, bool isRedirect) + { + return defaultPolicy; + } // Query if the specified request can be handled. virtual bool canHandleRequest( - WebFrame*, const WebURLRequest& request) = 0; + WebFrame*, const WebURLRequest& request) { return true; } // Returns an error corresponding to canHandledRequest() returning false. virtual WebURLError cannotHandleRequestError( - WebFrame*, const WebURLRequest& request) = 0; + WebFrame*, const WebURLRequest& request) { return WebURLError(); } // Returns an error corresponding to a user cancellation event. virtual WebURLError cancelledError( - WebFrame*, const WebURLRequest& request) = 0; + WebFrame*, const WebURLRequest& request) { return WebURLError(); } // Notify that a URL cannot be handled. virtual void unableToImplementPolicyWithError( - WebFrame*, const WebURLError&) = 0; + WebFrame*, const WebURLError&) { }; // Navigational notifications ------------------------------------------ // A form submission is about to occur. - virtual void willSubmitForm(WebFrame*, const WebForm&) = 0; + virtual void willSubmitForm(WebFrame*, const WebForm&) { }; // A client-side redirect will occur. This may correspond to a <META // refresh> or some script activity. virtual void willPerformClientRedirect( WebFrame*, const WebURL& from, const WebURL& to, - double interval, double fireTime) = 0; + double interval, double fireTime) { }; // A client-side redirect was cancelled. - virtual void didCancelClientRedirect(WebFrame*) = 0; + virtual void didCancelClientRedirect(WebFrame*) { } // A client-side redirect completed. - virtual void didCompleteClientRedirect(WebFrame*, const WebURL& fromURL) = 0; + virtual void didCompleteClientRedirect(WebFrame*, const WebURL& fromURL) { } // A datasource has been created for a new navigation. The given // datasource will become the provisional datasource for the frame. - virtual void didCreateDataSource(WebFrame*, WebDataSource*) = 0; + virtual void didCreateDataSource(WebFrame*, WebDataSource*) { } // A new provisional load has been started. - virtual void didStartProvisionalLoad(WebFrame*) = 0; + virtual void didStartProvisionalLoad(WebFrame*) { } // The provisional load was redirected via a HTTP 3xx response. - virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) = 0; + virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) { } // The provisional load failed. - virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) = 0; + virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) { } // Notifies the client to commit data for the given frame. The client // may optionally prevent default processing by setting preventDefault @@ -146,44 +150,44 @@ namespace WebKit { // to didReceiveDocumentData. If commitDocumentData is not called, // then an empty document will be loaded. virtual void didReceiveDocumentData( - WebFrame*, const char* data, size_t length, bool& preventDefault) = 0; + WebFrame*, const char* data, size_t length, bool& preventDefault) { } // The provisional datasource is now committed. The first part of the // response body has been received, and the encoding of the response // body is known. - virtual void didCommitProvisionalLoad(WebFrame*, bool isNewNavigation) = 0; + virtual void didCommitProvisionalLoad(WebFrame*, bool isNewNavigation) { } // The window object for the frame has been cleared of any extra // properties that may have been set by script from the previously // loaded document. - virtual void didClearWindowObject(WebFrame*) = 0; + virtual void didClearWindowObject(WebFrame*) { } // The document element has been created. - virtual void didCreateDocumentElement(WebFrame*) = 0; + virtual void didCreateDocumentElement(WebFrame*) { } // The page title is available. - virtual void didReceiveTitle(WebFrame*, const WebString& title) = 0; + virtual void didReceiveTitle(WebFrame*, const WebString& title) { } // The frame's document finished loading. - virtual void didFinishDocumentLoad(WebFrame*) = 0; + virtual void didFinishDocumentLoad(WebFrame*) { } // The 'load' event was dispatched. - virtual void didHandleOnloadEvents(WebFrame*) = 0; + virtual void didHandleOnloadEvents(WebFrame*) { } // The frame's document or one of its subresources failed to load. - virtual void didFailLoad(WebFrame*, const WebURLError&) = 0; + virtual void didFailLoad(WebFrame*, const WebURLError&) { } // The frame's document and all of its subresources succeeded to load. - virtual void didFinishLoad(WebFrame*) = 0; + virtual void didFinishLoad(WebFrame*) { } // The navigation resulted in scrolling the page to a named anchor instead // of downloading a new document. - virtual void didChangeLocationWithinPage(WebFrame*, bool isNewNavigation) = 0; + virtual void didChangeLocationWithinPage(WebFrame*, bool isNewNavigation) { } // Called upon update to scroll position, document state, and other // non-navigational events related to the data held by WebHistoryItem. // WARNING: This method may be called very frequently. - virtual void didUpdateCurrentHistoryItem(WebFrame*) = 0; + virtual void didUpdateCurrentHistoryItem(WebFrame*) { } // Low-level resource notifications ------------------------------------ @@ -191,7 +195,7 @@ namespace WebKit { // An identifier was assigned to the specified request. The client // should remember this association if interested in subsequent events. virtual void assignIdentifierToRequest( - WebFrame*, unsigned identifier, const WebURLRequest&) = 0; + WebFrame*, unsigned identifier, const WebURLRequest&) { } // A request is about to be sent out, and the client may modify it. Request // is writable, and changes to the URL, for example, will change the request @@ -199,57 +203,57 @@ namespace WebKit { // will be non-null and contain the response that triggered the redirect. virtual void willSendRequest( WebFrame*, unsigned identifier, WebURLRequest&, - const WebURLResponse& redirectResponse) = 0; + const WebURLResponse& redirectResponse) { } // Response headers have been received for the resource request given // by identifier. virtual void didReceiveResponse( - WebFrame*, unsigned identifier, const WebURLResponse&) = 0; + WebFrame*, unsigned identifier, const WebURLResponse&) { } // The resource request given by identifier succeeded. virtual void didFinishResourceLoad( - WebFrame*, unsigned identifier) = 0; + WebFrame*, unsigned identifier) { } // The resource request given by identifier failed. virtual void didFailResourceLoad( - WebFrame*, unsigned identifier, const WebURLError&) = 0; + WebFrame*, unsigned identifier, const WebURLError&) { } // The specified request was satified from WebCore's memory cache. virtual void didLoadResourceFromMemoryCache( - WebFrame*, const WebURLRequest&, const WebURLResponse&) = 0; + WebFrame*, const WebURLRequest&, const WebURLResponse&) { } // This frame has displayed inactive content (such as an image) from an // insecure source. Inactive content cannot spread to other frames. - virtual void didDisplayInsecureContent(WebFrame*) = 0; + virtual void didDisplayInsecureContent(WebFrame*) { } // The indicated security origin has run active content (such as a // script) from an insecure source. Note that the insecure content can // spread to other frames in the same origin. - virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&) = 0; + virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&) { } // Script notifications ------------------------------------------------ // Script in the page tried to allocate too much memory. - virtual void didExhaustMemoryAvailableForScript(WebFrame*) = 0; + virtual void didExhaustMemoryAvailableForScript(WebFrame*) { } // Notifies that a new script context has been created for this frame. // This is similar to didClearWindowObject but only called once per // frame context. - virtual void didCreateScriptContext(WebFrame*) = 0; + virtual void didCreateScriptContext(WebFrame*) { } // Notifies that this frame's script context has been destroyed. - virtual void didDestroyScriptContext(WebFrame*) = 0; + virtual void didDestroyScriptContext(WebFrame*) { } // Notifies that a garbage-collected context was created - content // scripts. - virtual void didCreateIsolatedScriptContext(WebFrame*) = 0; + virtual void didCreateIsolatedScriptContext(WebFrame*) { } // Geometry notifications ---------------------------------------------- // The size of the content area changed. - virtual void didChangeContentsSize(WebFrame*, const WebSize&) = 0; + virtual void didChangeContentsSize(WebFrame*, const WebSize&) { } // Find-in-page notifications ------------------------------------------ @@ -258,7 +262,7 @@ namespace WebKit { // identifier. |finalUpdate| specifies whether this is the last update // (all frames have completed scoping). virtual void reportFindInPageMatchCount( - int identifier, int count, bool finalUpdate) = 0; + int identifier, int count, bool finalUpdate) { } // Notifies what tick-mark rect is currently selected. The given // identifier lets the client know which request this message belongs @@ -267,7 +271,7 @@ namespace WebKit { // relative to the top left corner of the web page area and represent // where on the screen the selection rect is currently located. virtual void reportFindInPageSelection( - int identifier, int activeMatchOrdinal, const WebRect& selection) = 0; + int identifier, int activeMatchOrdinal, const WebRect& selection) { } protected: ~WebFrameClient() { } diff --git a/webkit/api/src/EmptyWebFrameClientImpl.h b/webkit/api/src/EmptyWebFrameClientImpl.h deleted file mode 100644 index fadeaff..0000000 --- a/webkit/api/src/EmptyWebFrameClientImpl.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef EmptyWebFrameClientImpl_h -#define EmptyWebFrameClientImpl_h - -#include "WebFrameClient.h" -#include "WebURLError.h" - -namespace WebKit { - -// Extend from this if you only need to override a few WebFrameClient methods. -class EmptyWebFrameClient : public WebFrameClient { -public: - virtual WebPlugin* createPlugin(WebFrame*, const WebPluginParams&) { return 0; } - virtual WebWorker* createWorker(WebFrame*, WebWorkerClient*) { return 0; } - virtual WebMediaPlayer* createMediaPlayer(WebFrame*, WebMediaPlayerClient*) { return 0; } - virtual void willClose(WebFrame*) {} - virtual void loadURLExternally(WebFrame*, const WebURLRequest&, WebNavigationPolicy) {} - virtual WebNavigationPolicy decidePolicyForNavigation( - WebFrame*, const WebURLRequest&, WebNavigationType, const WebNode&, - WebNavigationPolicy defaultPolicy, bool) { return defaultPolicy; } - virtual bool canHandleRequest(WebFrame*, const WebURLRequest&) { return true; } - virtual WebURLError cannotHandleRequestError(WebFrame*, const WebURLRequest&) { return WebURLError(); } - virtual WebURLError cancelledError(WebFrame*, const WebURLRequest&) { return WebURLError(); } - virtual void unableToImplementPolicyWithError(WebFrame*, const WebURLError&) {} - virtual void willSubmitForm(WebFrame*, const WebForm&) {} - virtual void willPerformClientRedirect(WebFrame*, const WebURL&, const WebURL&, double, double) {} - virtual void didCancelClientRedirect(WebFrame*) {} - virtual void didCompleteClientRedirect(WebFrame*, const WebURL& from) {} - virtual void didCreateDataSource(WebFrame*, WebDataSource*) {} - virtual void didStartProvisionalLoad(WebFrame*) {} - virtual void didReceiveServerRedirectForProvisionalLoad(WebFrame*) {} - virtual void didFailProvisionalLoad(WebFrame*, const WebURLError&) {} - virtual void didReceiveDocumentData(WebFrame*, const char*, size_t, bool&) {} - virtual void didCommitProvisionalLoad(WebFrame*, bool) {} - virtual void didClearWindowObject(WebFrame*) {} - virtual void didCreateDocumentElement(WebFrame*) {} - virtual void didReceiveTitle(WebFrame*, const WebString&) {} - virtual void didFinishDocumentLoad(WebFrame*) {} - virtual void didHandleOnloadEvents(WebFrame*) {} - virtual void didFailLoad(WebFrame*, const WebURLError&) {} - virtual void didFinishLoad(WebFrame*) {} - virtual void didChangeLocationWithinPage(WebFrame*, bool) {} - virtual void didUpdateCurrentHistoryItem(WebFrame*) {} - virtual void assignIdentifierToRequest(WebFrame*, unsigned, const WebURLRequest&) {} - virtual void willSendRequest(WebFrame*, unsigned, WebURLRequest&, const WebURLResponse&) {} - virtual void didReceiveResponse(WebFrame*, unsigned, const WebURLResponse&) {} - virtual void didFinishResourceLoad(WebFrame*, unsigned) {} - virtual void didFailResourceLoad(WebFrame*, unsigned, const WebURLError&) {} - virtual void didLoadResourceFromMemoryCache(WebFrame*, const WebURLRequest&, const WebURLResponse&) {} - virtual void didDisplayInsecureContent(WebFrame*) {} - virtual void didRunInsecureContent(WebFrame*, const WebSecurityOrigin&) {} - virtual void didExhaustMemoryAvailableForScript(WebFrame*) {} - virtual void didCreateScriptContext(WebFrame*) {} - virtual void didDestroyScriptContext(WebFrame*) {} - virtual void didCreateIsolatedScriptContext(WebFrame*) {} - virtual void didChangeContentsSize(WebFrame*, const WebSize&) {} - virtual void reportFindInPageMatchCount(int, int, bool) {} - virtual void reportFindInPageSelection(int, int, const WebRect&) {} -}; - -} // namespace WebKit - -#endif diff --git a/webkit/api/src/WebWorkerImpl.cpp b/webkit/api/src/WebWorkerImpl.cpp index 677fdea..8e6f6df 100644 --- a/webkit/api/src/WebWorkerImpl.cpp +++ b/webkit/api/src/WebWorkerImpl.cpp @@ -45,7 +45,6 @@ #include <wtf/MainThread.h> #include <wtf/Threading.h> -#include "EmptyWebFrameClientImpl.h" #include "PlatformMessagePortChannel.h" #include "WebDataSourceImpl.h" #include "WebFrameClient.h" @@ -66,7 +65,7 @@ namespace WebKit { // Dummy WebViewDelegate - we only need it in Worker process to load a // 'shadow page' which will initialize WebCore loader. -class WorkerWebFrameClient : public WebKit::EmptyWebFrameClient { +class WorkerWebFrameClient : public WebKit::WebFrameClient { public: // Tell the loader to load the data into the 'shadow page' synchronously, // so we can grab the resulting Document right after load. diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index e246987..578fbc9 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -187,7 +187,6 @@ 'api/src/DragClientImpl.h', 'api/src/EditorClientImpl.cpp', 'api/src/EditorClientImpl.h', - 'api/src/EmptyWebFrameClientImpl.h', 'api/src/gtk/WebFontInfo.cpp', 'api/src/gtk/WebFontInfo.h', 'api/src/gtk/WebInputEventFactory.cpp', |