diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 20:20:47 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 20:20:47 +0000 |
commit | d750e4d1052bd33755326f122bb2ab73df9e0079 (patch) | |
tree | cbd51d5ddc906d39cd63d77190fa5184a5eafb3b /webkit | |
parent | 34cc1917d8003c107c1c320e5b50fe240de8a010 (diff) | |
download | chromium_src-d750e4d1052bd33755326f122bb2ab73df9e0079.zip chromium_src-d750e4d1052bd33755326f122bb2ab73df9e0079.tar.gz chromium_src-d750e4d1052bd33755326f122bb2ab73df9e0079.tar.bz2 |
Reverting 23068.
Review URL: http://codereview.chromium.org/165316
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webview.h | 3 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 5 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 4 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 1 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/test_webview_delegate.mm | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 17 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.h | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 32 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 39 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate_gtk.cc | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate_win.cc | 4 |
12 files changed, 62 insertions, 58 deletions
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index c329452..6e2c794 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -66,6 +66,9 @@ class WebView : public WebKit::WebWidget { // it, it will be NULL during closing of the view. virtual WebViewDelegate* GetDelegate() = 0; + // Changes the delegate for this WebView. It is valid to set this to NULL. + virtual void SetDelegate(WebViewDelegate* delegate) = 0; + // Instructs the EditorClient whether to pass editing notifications on to a // delegate, if one is present. This allows embedders that haven't // overridden any editor delegate methods to avoid the performance impact of diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 826d1a7..7d421af 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -845,9 +845,10 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { virtual void DidAddHistoryItem() { } WebViewDelegate() { } + virtual ~WebViewDelegate() { } - protected: - ~WebViewDelegate() { } + private: + DISALLOW_COPY_AND_ASSIGN(WebViewDelegate); }; #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 16bc819..c1c1f1e 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -1246,6 +1246,10 @@ WebViewDelegate* WebViewImpl::GetDelegate() { return delegate_; } +void WebViewImpl::SetDelegate(WebViewDelegate* delegate) { + delegate_ = delegate; +} + WebFrame* WebViewImpl::GetMainFrame() { return main_frame(); } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 275faed..f2ea84b 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -76,6 +76,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual bool ShouldClose(); virtual void ClosePage(); virtual WebViewDelegate* GetDelegate(); + virtual void SetDelegate(WebViewDelegate*); virtual void SetUseEditorDelegate(bool value); virtual void SetTabKeyCyclesThroughElements(bool value); virtual WebKit::WebFrame* GetMainFrame(); diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm index 1adb264..7724532 100644 --- a/webkit/tools/test_shell/mac/test_webview_delegate.mm +++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm @@ -23,6 +23,9 @@ using WebKit::WebWidget; // WebViewDelegate ----------------------------------------------------------- +TestWebViewDelegate::~TestWebViewDelegate() { +} + WebWidget* TestWebViewDelegate::CreatePopupWidgetWithInfo( WebView* webview, const WebPopupMenuInfo& info) { diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index df1f953..1d296bf 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -112,8 +112,8 @@ TestShell::TestShell() test_is_pending_(false), is_modal_(false), dump_stats_table_on_exit_(false) { - delegate_.reset(new TestWebViewDelegate(this)); - popup_delegate_.reset(new TestWebViewDelegate(this)); + delegate_ = new TestWebViewDelegate(this); + popup_delegate_ = new TestWebViewDelegate(this); layout_test_controller_.reset(new LayoutTestController(this)); event_sending_controller_.reset(new EventSendingController(this)); text_input_controller_.reset(new TextInputController(this)); @@ -126,8 +126,6 @@ TestShell::TestShell() } TestShell::~TestShell() { - delegate_->RevokeDragDrop(); - // Navigate to an empty page to fire all the destruction logic for the // current page. LoadURL(L"about:blank"); @@ -136,9 +134,7 @@ TestShell::~TestShell() { CallJSGC(); CallJSGC(); - // Destroy the WebView before the TestWebViewDelegate. - m_webViewHost.reset(); - + webView()->SetDelegate(NULL); PlatformCleanUp(); StatsTable *table = StatsTable::current(); @@ -506,11 +502,14 @@ void TestShell::SizeToDefault() { void TestShell::ResetTestController() { layout_test_controller_->Reset(); event_sending_controller_->Reset(); - delegate_->Reset(); + + // Reset state in the test webview delegate. + delegate_ = new TestWebViewDelegate(this); + webView()->SetDelegate(delegate_); } void TestShell::LoadURL(const wchar_t* url) { - LoadURLForFrame(url, NULL); + LoadURLForFrame(url, NULL); } bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 4b6ed14..1c18e4f 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -324,8 +324,8 @@ private: scoped_ptr<TestNavigationController> navigation_controller_; - scoped_ptr<TestWebViewDelegate> delegate_; - scoped_ptr<TestWebViewDelegate> popup_delegate_; + scoped_refptr<TestWebViewDelegate> delegate_; + scoped_refptr<TestWebViewDelegate> popup_delegate_; const TestParams* test_params_; diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 4ce9e5a..27aafcd 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -369,8 +369,7 @@ bool TestShell::Initialize(const std::wstring& startingURL) { gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1 /* append */); gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); - m_webViewHost.reset( - WebViewHost::Create(vbox, delegate_.get(), *TestShell::web_prefs_)); + m_webViewHost.reset(WebViewHost::Create(vbox, delegate_, *TestShell::web_prefs_)); // Enables output of "EDDITING DELEGATE: " debugging lines in the layout test // output. @@ -477,7 +476,7 @@ void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { WebWidget* TestShell::CreatePopupWidget(WebView* webview) { GtkWidget* popupwindow = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - WebWidgetHost* host = WebWidgetHost::Create(vbox, popup_delegate_.get()); + WebWidgetHost* host = WebWidgetHost::Create(vbox, popup_delegate_); gtk_container_add(GTK_CONTAINER(popupwindow), vbox); m_popupHost = host; diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 654dc314..f3ae7e8 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -845,32 +845,6 @@ WebScreenInfo TestWebViewDelegate::screenInfo() { return WebScreenInfo(); } -// Public methods ------------------------------------------------------------ - -TestWebViewDelegate::TestWebViewDelegate(TestShell* shell) - : policy_delegate_enabled_(false), - policy_delegate_is_permissive_(false), - policy_delegate_should_notify_done_(false), - shell_(shell), - top_loading_frame_(NULL), - page_id_(-1), - last_page_id_updated_(-1), -#if defined(OS_LINUX) - cursor_type_(GDK_X_CURSOR), -#endif - smart_insert_delete_enabled_(true), -#if defined(OS_WIN) - select_trailing_whitespace_enabled_(true), -#else - select_trailing_whitespace_enabled_(false), -#endif - block_redirects_(false) { -} - -void TestWebViewDelegate::Reset() { - *this = TestWebViewDelegate(shell_); -} - void TestWebViewDelegate::SetSmartInsertDeleteEnabled(bool enabled) { smart_insert_delete_enabled_ = enabled; // In upstream WebKit, smart insert/delete is mutually exclusive with select @@ -894,12 +868,6 @@ void TestWebViewDelegate::RegisterDragDrop() { #endif } -void TestWebViewDelegate::RevokeDragDrop() { -#if defined(OS_WIN) - ::RevokeDragDrop(shell_->webViewWnd()); -#endif -} - void TestWebViewDelegate::SetCustomPolicyDelegate(bool is_custom, bool is_permissive) { policy_delegate_enabled_ = is_custom; diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 6224b9c..81e7bab 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -21,7 +21,8 @@ #endif #include "base/basictypes.h" -#include "base/linked_ptr.h" +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" #if defined(OS_MACOSX) #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebPopupMenuInfo.h" @@ -40,7 +41,8 @@ class GURL; class TestShell; class WebWidgetHost; -class TestWebViewDelegate : public WebViewDelegate { +class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, + public WebViewDelegate { public: struct CapturedContextMenuEvent { CapturedContextMenuEvent(ContextNodeType in_node_type, @@ -58,6 +60,27 @@ class TestWebViewDelegate : public WebViewDelegate { typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; + TestWebViewDelegate(TestShell* shell) + : policy_delegate_enabled_(false), + policy_delegate_is_permissive_(false), + policy_delegate_should_notify_done_(false), + shell_(shell), + top_loading_frame_(NULL), + page_id_(-1), + last_page_id_updated_(-1), +#if defined(OS_LINUX) + cursor_type_(GDK_X_CURSOR), +#endif + smart_insert_delete_enabled_(true), +#if defined(OS_WIN) + select_trailing_whitespace_enabled_(true), +#else + select_trailing_whitespace_enabled_(false), +#endif + block_redirects_(false) { + } + virtual ~TestWebViewDelegate(); + // WebViewDelegate virtual WebView* CreateWebView(WebView* webview, bool user_gesture, @@ -234,9 +257,6 @@ class TestWebViewDelegate : public WebViewDelegate { virtual WebKit::WebRect windowResizerRect(); virtual WebKit::WebScreenInfo screenInfo(); - TestWebViewDelegate(TestShell* shell); - void Reset(); - void SetSmartInsertDeleteEnabled(bool enabled); void SetSelectTrailingWhitespaceEnabled(bool enabled); @@ -263,9 +283,6 @@ class TestWebViewDelegate : public WebViewDelegate { // Sets the webview as a drop target. void RegisterDragDrop(); - void RevokeDragDrop(); - - void ResetDragDrop(); void SetCustomPolicyDelegate(bool is_custom, bool is_permissive); void WaitForPolicyDelegate(); @@ -333,7 +350,7 @@ class TestWebViewDelegate : public WebViewDelegate { int page_id_; int last_page_id_updated_; - linked_ptr<TestShellExtraData> pending_extra_data_; + scoped_ptr<TestShellExtraData> pending_extra_data_; // Maps resource identifiers to a descriptive string. typedef std::map<uint32, std::string> ResourceMap; @@ -358,7 +375,7 @@ class TestWebViewDelegate : public WebViewDelegate { #endif #if defined(OS_MACOSX) - linked_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_; + scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_; WebKit::WebRect popup_bounds_; #endif @@ -370,6 +387,8 @@ class TestWebViewDelegate : public WebViewDelegate { // true if we should block any redirects bool block_redirects_; + + DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); }; #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index 460dceb..66d7a62 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -84,6 +84,9 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard, // WebViewDelegate ----------------------------------------------------------- +TestWebViewDelegate::~TestWebViewDelegate() { +} + WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( WebView* webview, const GURL& url, diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index fe57540..d49cb9d 100644 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -41,6 +41,10 @@ using WebKit::WebRect; // WebViewDelegate ----------------------------------------------------------- +TestWebViewDelegate::~TestWebViewDelegate() { + RevokeDragDrop(shell_->webViewWnd()); +} + WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( WebView* webview, const GURL& url, |