| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file was forked off the Mac port. | 5 // This file was forked off the Mac port. |
| 6 | 6 |
| 7 #include "webkit/tools/test_shell/test_webview_delegate.h" | 7 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
| 11 | 11 |
| 12 #include "base/gfx/gtk_util.h" | 12 #include "base/gfx/gtk_util.h" |
| 13 #include "base/gfx/point.h" | 13 #include "base/gfx/point.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "chrome/common/page_transition_types.h" | 17 #include "chrome/common/page_transition_types.h" |
| 18 #include "webkit/api/public/WebCursorInfo.h" |
| 18 #include "webkit/api/public/WebRect.h" | 19 #include "webkit/api/public/WebRect.h" |
| 19 #include "webkit/glue/webcursor.h" | 20 #include "webkit/glue/webcursor.h" |
| 20 #include "webkit/glue/webdropdata.h" | 21 #include "webkit/glue/webdropdata.h" |
| 21 #include "webkit/glue/webframe.h" | 22 #include "webkit/glue/webframe.h" |
| 22 #include "webkit/glue/webpreferences.h" | 23 #include "webkit/glue/webpreferences.h" |
| 23 #include "webkit/glue/webplugin.h" | 24 #include "webkit/glue/webplugin.h" |
| 24 #include "webkit/glue/webkit_glue.h" | 25 #include "webkit/glue/webkit_glue.h" |
| 25 #include "webkit/glue/webview.h" | 26 #include "webkit/glue/webview.h" |
| 26 #include "webkit/glue/plugins/gtk_plugin_container_manager.h" | 27 #include "webkit/glue/plugins/gtk_plugin_container_manager.h" |
| 27 #include "webkit/glue/plugins/plugin_list.h" | 28 #include "webkit/glue/plugins/plugin_list.h" |
| 28 #include "webkit/glue/window_open_disposition.h" | 29 #include "webkit/glue/window_open_disposition.h" |
| 29 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 30 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 30 #include "webkit/tools/test_shell/test_navigation_controller.h" | 31 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 31 #include "webkit/tools/test_shell/test_shell.h" | 32 #include "webkit/tools/test_shell/test_shell.h" |
| 32 | 33 |
| 34 using WebKit::WebCursorInfo; |
| 33 using WebKit::WebRect; | 35 using WebKit::WebRect; |
| 34 | 36 |
| 35 namespace { | 37 namespace { |
| 36 | 38 |
| 37 enum SelectionClipboardType { | 39 enum SelectionClipboardType { |
| 38 TEXT_HTML, | 40 TEXT_HTML, |
| 39 PLAIN_TEXT, | 41 PLAIN_TEXT, |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 GdkAtom GetTextHtmlAtom() { | 44 GdkAtom GetTextHtmlAtom() { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { | 140 void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { |
| 139 if (webwidget == shell_->webView()) { | 141 if (webwidget == shell_->webView()) { |
| 140 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( | 142 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( |
| 141 >k_widget_destroy, GTK_WIDGET(shell_->mainWnd()))); | 143 >k_widget_destroy, GTK_WIDGET(shell_->mainWnd()))); |
| 142 } else if (webwidget == shell_->popup()) { | 144 } else if (webwidget == shell_->popup()) { |
| 143 shell_->ClosePopup(); | 145 shell_->ClosePopup(); |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 | 148 |
| 147 void TestWebViewDelegate::SetCursor(WebWidget* webwidget, | 149 void TestWebViewDelegate::SetCursor(WebWidget* webwidget, |
| 148 const WebCursor& cursor) { | 150 const WebCursorInfo& cursor_info) { |
| 149 current_cursor_ = cursor; | 151 current_cursor_.InitFromCursorInfo(cursor_info); |
| 150 GdkCursorType cursor_type = current_cursor_.GetCursorType(); | 152 GdkCursorType cursor_type = current_cursor_.GetCursorType(); |
| 151 GdkCursor* gdk_cursor; | 153 GdkCursor* gdk_cursor; |
| 152 if (cursor_type == GDK_CURSOR_IS_PIXMAP) { | 154 if (cursor_type == GDK_CURSOR_IS_PIXMAP) { |
| 153 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is | 155 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is |
| 154 // that calling gdk_window_set_cursor repeatedly is expensive. We should | 156 // that calling gdk_window_set_cursor repeatedly is expensive. We should |
| 155 // avoid it here where possible. | 157 // avoid it here where possible. |
| 156 gdk_cursor = current_cursor_.GetCustomCursor(); | 158 gdk_cursor = current_cursor_.GetCustomCursor(); |
| 157 } else { | 159 } else { |
| 158 // Optimize the common case, where the cursor hasn't changed. | 160 // Optimize the common case, where the cursor hasn't changed. |
| 159 // However, we can switch between different pixmaps, so only on the | 161 // However, we can switch between different pixmaps, so only on the |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // Private methods ----------------------------------------------------------- | 265 // Private methods ----------------------------------------------------------- |
| 264 | 266 |
| 265 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { | 267 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { |
| 266 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), | 268 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), |
| 267 ("Test Shell - " + WideToUTF8(title)).c_str()); | 269 ("Test Shell - " + WideToUTF8(title)).c_str()); |
| 268 } | 270 } |
| 269 | 271 |
| 270 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { | 272 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { |
| 271 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); | 273 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); |
| 272 } | 274 } |
| OLD | NEW |