summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 05:23:46 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 05:23:46 +0000
commit867056cc13fad6ec04efb849b366b60477cef978 (patch)
tree1f28f5506758160a347877bde95df1a71dabc4ee /webkit
parenta3406979cd56b42ec58244e6382ca77c2c93205d (diff)
downloadchromium_src-867056cc13fad6ec04efb849b366b60477cef978.zip
chromium_src-867056cc13fad6ec04efb849b366b60477cef978.tar.gz
chromium_src-867056cc13fad6ec04efb849b366b60477cef978.tar.bz2
Add default implementations for WebViewClient and WebWidgetClient
methods. Once these interfaces live upstream, we'll want to allow the addition of new methods w/o requiring the consumer (chrome) to implement the new methods. That'll make webkit merging easier, and it'll also make it possible to use a newer webkit with an older chrome. Obviously, this only works if the methods are not crucial to webkit working properly, but that is generally the case for *Client methods. R=dglazkov BUG=none TEST=none Review URL: http://codereview.chromium.org/346042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/public/WebViewClient.h111
-rw-r--r--webkit/api/public/WebWidgetClient.h30
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h55
3 files changed, 69 insertions, 127 deletions
diff --git a/webkit/api/public/WebViewClient.h b/webkit/api/public/WebViewClient.h
index 5c0cbf5..0fec2c7 100644
--- a/webkit/api/public/WebViewClient.h
+++ b/webkit/api/public/WebViewClient.h
@@ -34,6 +34,7 @@
#include "WebDragOperation.h"
#include "WebEditingAction.h"
#include "WebFileChooserCompletion.h"
+#include "WebString.h"
#include "WebTextAffinity.h"
#include "WebTextDirection.h"
#include "WebWidgetClient.h"
@@ -46,7 +47,6 @@ namespace WebKit {
class WebNode;
class WebNotificationPresenter;
class WebRange;
- class WebString;
class WebURL;
class WebView;
class WebWidget;
@@ -63,62 +63,62 @@ namespace WebKit {
// Factory methods -----------------------------------------------------
// Create a new related WebView.
- virtual WebView* createView(WebFrame* creator) = 0;
+ virtual WebView* createView(WebFrame* creator) { return 0; }
// Create a new WebPopupMenu. In the second form, the client is
// responsible for rendering the contents of the popup menu.
- virtual WebWidget* createPopupMenu(bool activatable) = 0;
- virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) = 0;
+ virtual WebWidget* createPopupMenu(bool activatable) { return 0; }
+ virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; }
// Misc ----------------------------------------------------------------
// A new message was added to the console.
virtual void didAddMessageToConsole(
- const WebConsoleMessage&, const WebString& sourceName, unsigned sourceLine) = 0;
+ const WebConsoleMessage&, const WebString& sourceName, unsigned sourceLine) { }
// Called when script in the page calls window.print(). If frame is
// non-null, then it selects a particular frame, including its
// children, to print. Otherwise, the main frame and its children
// should be printed.
- virtual void printPage(WebFrame*) = 0;
+ virtual void printPage(WebFrame*) { }
// Called to retrieve the provider of desktop notifications.
- virtual WebNotificationPresenter* notificationPresenter() = 0;
+ virtual WebNotificationPresenter* notificationPresenter() { return 0; }
// Navigational --------------------------------------------------------
// These notifications bracket any loading that occurs in the WebView.
- virtual void didStartLoading() = 0;
- virtual void didStopLoading() = 0;
+ virtual void didStartLoading() { }
+ virtual void didStopLoading() { }
// Editing -------------------------------------------------------------
// These methods allow the client to intercept and overrule editing
// operations.
- virtual bool shouldBeginEditing(const WebRange&) = 0;
- virtual bool shouldEndEditing(const WebRange&) = 0;
+ virtual bool shouldBeginEditing(const WebRange&) { return true; }
+ virtual bool shouldEndEditing(const WebRange&) { return true; }
virtual bool shouldInsertNode(
- const WebNode&, const WebRange&, WebEditingAction) = 0;
+ const WebNode&, const WebRange&, WebEditingAction) { return true; }
virtual bool shouldInsertText(
- const WebString&, const WebRange&, WebEditingAction) = 0;
+ const WebString&, const WebRange&, WebEditingAction) { return true; }
virtual bool shouldChangeSelectedRange(
const WebRange& from, const WebRange& to, WebTextAffinity,
- bool stillSelecting) = 0;
- virtual bool shouldDeleteRange(const WebRange&) = 0;
- virtual bool shouldApplyStyle(const WebString& style, const WebRange&) = 0;
+ bool stillSelecting) { return true; }
+ virtual bool shouldDeleteRange(const WebRange&) { return true; }
+ virtual bool shouldApplyStyle(const WebString& style, const WebRange&) { return true; }
- virtual bool isSmartInsertDeleteEnabled() = 0;
- virtual bool isSelectTrailingWhitespaceEnabled() = 0;
- virtual void setInputMethodEnabled(bool enabled) = 0;
+ virtual bool isSmartInsertDeleteEnabled() { return true; }
+ virtual bool isSelectTrailingWhitespaceEnabled() { return true; }
+ virtual void setInputMethodEnabled(bool enabled) { }
- virtual void didBeginEditing() = 0;
- virtual void didChangeSelection(bool isSelectionEmpty) = 0;
- virtual void didChangeContents() = 0;
- virtual void didExecuteCommand(const WebString& commandName) = 0;
- virtual void didEndEditing() = 0;
+ virtual void didBeginEditing() { }
+ virtual void didChangeSelection(bool isSelectionEmpty) { }
+ virtual void didChangeContents() { }
+ virtual void didExecuteCommand(const WebString& commandName) { }
+ virtual void didEndEditing() { }
// This method is called in response to WebView's handleInputEvent()
// when the default action for the current keyboard event is not
@@ -127,7 +127,7 @@ namespace WebKit {
//
// Returns true if the keyboard event was handled by the embedder,
// indicating that the default action should be suppressed.
- virtual bool handleCurrentKeyboardEvent() = 0;
+ virtual bool handleCurrentKeyboardEvent() { return false; }
// Spellchecker --------------------------------------------------------
@@ -138,20 +138,20 @@ namespace WebKit {
// will indicates its length. Otherwise, if there was not a spelling
// error, then upon return misspelledLength is 0.
virtual void spellCheck(
- const WebString& text, int& misspelledOffset, int& misspelledLength) = 0;
+ const WebString& text, int& misspelledOffset, int& misspelledLength) { }
// Computes an auto-corrected replacement for a misspelled word. If no
// replacement is found, then an empty string is returned.
- virtual WebString autoCorrectWord(const WebString& misspelledWord) = 0;
+ virtual WebString autoCorrectWord(const WebString& misspelledWord) { return WebString(); }
// Show or hide the spelling UI.
- virtual void showSpellingUI(bool show) = 0;
+ virtual void showSpellingUI(bool show) { }
// Returns true if the spelling UI is showing.
- virtual bool isShowingSpellingUI() = 0;
+ virtual bool isShowingSpellingUI() { return false; }
// Update the spelling UI with the given word.
- virtual void updateSpellingUIWithMisspelledWord(const WebString& word) = 0;
+ virtual void updateSpellingUIWithMisspelledWord(const WebString& word) { }
// Dialogs -------------------------------------------------------------
@@ -162,18 +162,18 @@ namespace WebKit {
// WebFileChooseCompletion will never be called.
virtual bool runFileChooser(
bool multiSelect, const WebString& title,
- const WebString& initialValue, WebFileChooserCompletion*) = 0;
+ const WebString& initialValue, WebFileChooserCompletion*) { return false; }
// Displays a modal alert dialog containing the given message. Returns
// once the user dismisses the dialog.
virtual void runModalAlertDialog(
- WebFrame*, const WebString& message) = 0;
+ WebFrame*, const WebString& message) { }
// Displays a modal confirmation dialog with the given message as
// description and OK/Cancel choices. Returns true if the user selects
// 'OK' or false otherwise.
virtual bool runModalConfirmDialog(
- WebFrame*, const WebString& message) = 0;
+ WebFrame*, const WebString& message) { return false; }
// Displays a modal input dialog with the given message as description
// and OK/Cancel choices. The input field is pre-filled with
@@ -182,49 +182,46 @@ namespace WebKit {
// the input field.
virtual bool runModalPromptDialog(
WebFrame*, const WebString& message, const WebString& defaultValue,
- WebString* actualValue) = 0;
+ WebString* actualValue) { return false; }
// Displays a modal confirmation dialog containing the given message as
// description and OK/Cancel choices, where 'OK' means that it is okay
// to proceed with closing the view. Returns true if the user selects
// 'OK' or false otherwise.
virtual bool runModalBeforeUnloadDialog(
- WebFrame*, const WebString& message) = 0;
+ WebFrame*, const WebString& message) { return true; }
- // Shows a context menu with commands relevant to a specific element on
- // the given frame. Additional context data is supplied.
- virtual void showContextMenu(WebFrame*, const WebContextMenuData&) = 0;
// UI ------------------------------------------------------------------
// Called when script modifies window.status
- virtual void setStatusText(const WebString&) = 0;
+ virtual void setStatusText(const WebString&) { }
// Called when hovering over an anchor with the given URL.
- virtual void setMouseOverURL(const WebURL&) = 0;
+ virtual void setMouseOverURL(const WebURL&) { }
// Called when keyboard focus switches to an anchor with the given URL.
- virtual void setKeyboardFocusURL(const WebURL&) = 0;
+ virtual void setKeyboardFocusURL(const WebURL&) { }
// Called when a tooltip should be shown at the current cursor position.
- virtual void setToolTipText(const WebString&, WebTextDirection hint) = 0;
+ virtual void setToolTipText(const WebString&, WebTextDirection hint) { }
- // Called when a context menu should be shown at the current cursor position.
- // FIXME hook this up
- //virtual void showContextMenu(const WebContextMenuInfo&) = 0;
+ // Shows a context menu with commands relevant to a specific element on
+ // the given frame. Additional context data is supplied.
+ virtual void showContextMenu(WebFrame*, const WebContextMenuData&) { }
// Called when a drag-n-drop operation should begin.
virtual void startDragging(
- const WebPoint& from, const WebDragData&, WebDragOperationsMask) = 0;
+ const WebPoint& from, const WebDragData&, WebDragOperationsMask) { }
// Called to determine if drag-n-drop operations may initiate a page
// navigation.
- virtual bool acceptsLoadDrops() = 0;
+ virtual bool acceptsLoadDrops() { return true; }
// Take focus away from the WebView by focusing an adjacent UI element
// in the containing window.
- virtual void focusNext() = 0;
- virtual void focusPrevious() = 0;
+ virtual void focusNext() { }
+ virtual void focusPrevious() { }
// Session history -----------------------------------------------------
@@ -232,29 +229,29 @@ namespace WebKit {
// Tells the embedder to navigate back or forward in session history by
// the given offset (relative to the current position in session
// history).
- virtual void navigateBackForwardSoon(int offset) = 0;
+ virtual void navigateBackForwardSoon(int offset) { }
// Returns the number of history items before/after the current
// history item.
- virtual int historyBackListCount() = 0;
- virtual int historyForwardListCount() = 0;
+ virtual int historyBackListCount() { return 0; }
+ virtual int historyForwardListCount() { return 0; }
// Called to notify the embedder when a new history item is added.
- virtual void didAddHistoryItem() = 0;
+ virtual void didAddHistoryItem() { }
// Accessibility -------------------------------------------------------
// Notifies embedder that the focus has changed to the given
// accessibility object.
- virtual void focusAccessibilityObject(const WebAccessibilityObject&) = 0;
+ virtual void focusAccessibilityObject(const WebAccessibilityObject&) { }
// Developer tools -----------------------------------------------------
// Called to notify the client that the inspector's settings were
// changed and should be saved. See WebView::inspectorSettings.
- virtual void didUpdateInspectorSettings() = 0;
+ virtual void didUpdateInspectorSettings() { }
// Autofill ------------------------------------------------------------
@@ -264,12 +261,12 @@ namespace WebKit {
// far and the WebNode corresponds to the input field.
virtual void queryAutofillSuggestions(const WebNode&,
const WebString& name,
- const WebString& value) = 0;
+ const WebString& value) { }
// Instructs the browser to remove the autofill entry specified from
// its DB.
virtual void removeAutofillSuggestions(const WebString& name,
- const WebString& value) = 0;
+ const WebString& value) { }
protected:
~WebViewClient() { }
diff --git a/webkit/api/public/WebWidgetClient.h b/webkit/api/public/WebWidgetClient.h
index 8479bb6..c3bcc17 100644
--- a/webkit/api/public/WebWidgetClient.h
+++ b/webkit/api/public/WebWidgetClient.h
@@ -33,54 +33,54 @@
#include "WebCommon.h"
#include "WebNavigationPolicy.h"
+#include "WebRect.h"
+#include "WebScreenInfo.h"
namespace WebKit {
class WebWidget;
struct WebCursorInfo;
- struct WebRect;
- struct WebScreenInfo;
class WebWidgetClient {
public:
// Called when a region of the WebWidget needs to be re-painted.
- virtual void didInvalidateRect(const WebRect&) = 0;
+ virtual void didInvalidateRect(const WebRect&) { }
// Called when a region of the WebWidget, given by clipRect, should be
// scrolled by the specified dx and dy amounts.
- virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) = 0;
+ virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) { }
// Called when the widget acquires or loses focus, respectively.
- virtual void didFocus() = 0;
- virtual void didBlur() = 0;
+ virtual void didFocus() { }
+ virtual void didBlur() { }
// Called when the cursor for the widget changes.
- virtual void didChangeCursor(const WebCursorInfo&) = 0;
+ virtual void didChangeCursor(const WebCursorInfo&) { }
// Called when the widget should be closed. WebWidget::close() should
// be called asynchronously as a result of this notification.
- virtual void closeWidgetSoon() = 0;
+ virtual void closeWidgetSoon() { }
// Called to show the widget according to the given policy.
- virtual void show(WebNavigationPolicy) = 0;
+ virtual void show(WebNavigationPolicy) { }
// Called to block execution of the current thread until the widget is
// closed.
- virtual void runModal() = 0;
+ virtual void runModal() { }
// Called to get/set the position of the widget in screen coordinates.
- virtual WebRect windowRect() = 0;
- virtual void setWindowRect(const WebRect&) = 0;
+ virtual WebRect windowRect() { return WebRect(); }
+ virtual void setWindowRect(const WebRect&) { }
// Called to get the position of the resizer rect in window coordinates.
- virtual WebRect windowResizerRect() = 0;
+ virtual WebRect windowResizerRect() { return WebRect(); }
// Called to get the position of the root window containing the widget
// in screen coordinates.
- virtual WebRect rootWindowRect() = 0;
+ virtual WebRect rootWindowRect() { return WebRect(); }
// Called to query information about the screen where this widget is
// displayed.
- virtual WebScreenInfo screenInfo() = 0;
+ virtual WebScreenInfo screenInfo() { return WebScreenInfo(); }
protected:
~WebWidgetClient() { }
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index eb74e09..a191d95 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -73,12 +73,6 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual void didAddMessageToConsole(
const WebKit::WebConsoleMessage& message,
const WebKit::WebString& source_name, unsigned source_line);
- virtual void printPage(WebKit::WebFrame* frame) {}
- virtual WebKit::WebNotificationPresenter* notificationPresenter() {
- return NULL;
- }
- virtual void didStartLoading() {}
- virtual void didStopLoading() {}
virtual bool shouldBeginEditing(const WebKit::WebRange& range);
virtual bool shouldEndEditing(const WebKit::WebRange& range);
virtual bool shouldInsertNode(
@@ -95,25 +89,12 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
const WebKit::WebString& style, const WebKit::WebRange& range);
virtual bool isSmartInsertDeleteEnabled();
virtual bool isSelectTrailingWhitespaceEnabled();
- virtual void setInputMethodEnabled(bool enabled) {}
virtual void didBeginEditing();
virtual void didChangeSelection(bool is_selection_empty);
virtual void didChangeContents();
- virtual void didExecuteCommand(const WebKit::WebString& command_name) {}
virtual void didEndEditing();
- virtual bool handleCurrentKeyboardEvent() { return false; }
- virtual void spellCheck(
- const WebKit::WebString& text, int& offset, int& length) {}
virtual WebKit::WebString autoCorrectWord(
const WebKit::WebString& misspelled_word);
- virtual void showSpellingUI(bool show) {}
- virtual bool isShowingSpellingUI() { return false; }
- virtual void updateSpellingUIWithMisspelledWord(
- const WebKit::WebString& word) {}
- virtual bool runFileChooser(
- bool multi_select, const WebKit::WebString& title,
- const WebKit::WebString& initial_value,
- WebKit::WebFileChooserCompletion* chooser_completion){ return false; }
virtual void runModalAlertDialog(
WebKit::WebFrame* frame, const WebKit::WebString& message);
virtual bool runModalConfirmDialog(
@@ -126,28 +107,14 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual void showContextMenu(
WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data);
virtual void setStatusText(const WebKit::WebString& text);
- virtual void setMouseOverURL(const WebKit::WebURL& url) {}
- virtual void setKeyboardFocusURL(const WebKit::WebURL& url) {}
- virtual void setToolTipText(
- const WebKit::WebString& text, WebKit::WebTextDirection hint) {}
virtual void startDragging(
const WebKit::WebPoint& from, const WebKit::WebDragData& data,
WebKit::WebDragOperationsMask mask);
- virtual bool acceptsLoadDrops() { return true; }
- virtual void focusNext() {}
- virtual void focusPrevious() {}
virtual void navigateBackForwardSoon(int offset);
virtual int historyBackListCount();
virtual int historyForwardListCount();
- virtual void didAddHistoryItem() {}
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& object);
- virtual void didUpdateInspectorSettings() {}
- virtual void queryAutofillSuggestions(
- const WebKit::WebNode&, const WebKit::WebString& name,
- const WebKit::WebString& value) {}
- virtual void removeAutofillSuggestions(
- const WebKit::WebString& name, const WebKit::WebString& value) {}
// WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect& rect);
@@ -172,7 +139,6 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
WebKit::WebFrame*, WebKit::WebWorkerClient*);
virtual WebKit::WebMediaPlayer* createMediaPlayer(
WebKit::WebFrame*, WebKit::WebMediaPlayerClient*);
- virtual void willClose(WebKit::WebFrame*) {}
virtual void loadURLExternally(
WebKit::WebFrame*, const WebKit::WebURLRequest&,
WebKit::WebNavigationPolicy);
@@ -188,26 +154,19 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
WebKit::WebFrame*, const WebKit::WebURLRequest& request);
virtual void unableToImplementPolicyWithError(
WebKit::WebFrame*, const WebKit::WebURLError&);
- virtual void willSubmitForm(WebKit::WebFrame*, const WebKit::WebForm&) {}
virtual void willPerformClientRedirect(
WebKit::WebFrame*, const WebKit::WebURL& from, const WebKit::WebURL& to,
double interval, double fire_time);
virtual void didCancelClientRedirect(WebKit::WebFrame*);
- virtual void didCompleteClientRedirect(
- WebKit::WebFrame*, const WebKit::WebURL& from) {}
virtual void didCreateDataSource(
WebKit::WebFrame*, WebKit::WebDataSource*);
virtual void didStartProvisionalLoad(WebKit::WebFrame*);
virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*);
virtual void didFailProvisionalLoad(
WebKit::WebFrame*, const WebKit::WebURLError&);
- virtual void didReceiveDocumentData(
- WebKit::WebFrame*, const char* data, size_t length,
- bool& preventDefault) {}
virtual void didCommitProvisionalLoad(
WebKit::WebFrame*, bool is_new_navigation);
virtual void didClearWindowObject(WebKit::WebFrame*);
- virtual void didCreateDocumentElement(WebKit::WebFrame*) {}
virtual void didReceiveTitle(
WebKit::WebFrame*, const WebKit::WebString& title);
virtual void didFinishDocumentLoad(WebKit::WebFrame*);
@@ -217,7 +176,6 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual void didFinishLoad(WebKit::WebFrame*);
virtual void didChangeLocationWithinPage(
WebKit::WebFrame*, bool isNewNavigation);
- virtual void didUpdateCurrentHistoryItem(WebKit::WebFrame*) {}
virtual void assignIdentifierToRequest(
WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&);
virtual void willSendRequest(
@@ -229,22 +187,9 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
WebKit::WebFrame*, unsigned identifier);
virtual void didFailResourceLoad(
WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);
- virtual void didLoadResourceFromMemoryCache(
- WebKit::WebFrame*, const WebKit::WebURLRequest&,
- const WebKit::WebURLResponse&) {}
virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
virtual void didRunInsecureContent(
WebKit::WebFrame* frame, const WebKit::WebSecurityOrigin& origin);
- virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame*) {}
- virtual void didCreateScriptContext(WebKit::WebFrame* frame) {}
- virtual void didDestroyScriptContext(WebKit::WebFrame* frame) {}
- virtual void didCreateIsolatedScriptContext(WebKit::WebFrame* frame) {}
- virtual void didChangeContentsSize(
- WebKit::WebFrame*, const WebKit::WebSize&) {}
- virtual void reportFindInPageMatchCount(
- int identifier, int count, bool final_update) {}
- virtual void reportFindInPageSelection(
- int identifier, int ordinal, const WebKit::WebRect& selection) {}
// webkit_glue::WebPluginPageDelegate
virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate(