| 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 | 11 |
| 11 #include "base/gfx/gtk_util.h" | 12 #include "base/gfx/gtk_util.h" |
| 12 #include "base/gfx/point.h" | 13 #include "base/gfx/point.h" |
| 13 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "chrome/common/page_transition_types.h" | 17 #include "chrome/common/page_transition_types.h" |
| 17 #include "webkit/api/public/WebRect.h" | 18 #include "webkit/api/public/WebRect.h" |
| 18 #include "webkit/glue/webcursor.h" | 19 #include "webkit/glue/webcursor.h" |
| 19 #include "webkit/glue/webdropdata.h" | 20 #include "webkit/glue/webdropdata.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bool allow_wildcard = true; | 85 bool allow_wildcard = true; |
| 85 WebPluginInfo info; | 86 WebPluginInfo info; |
| 86 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid, | 87 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid, |
| 87 allow_wildcard, &info, | 88 allow_wildcard, &info, |
| 88 actual_mime_type)) | 89 actual_mime_type)) |
| 89 return NULL; | 90 return NULL; |
| 90 | 91 |
| 91 const std::string& mtype = | 92 const std::string& mtype = |
| 92 (actual_mime_type && !actual_mime_type->empty()) ? *actual_mime_type | 93 (actual_mime_type && !actual_mime_type->empty()) ? *actual_mime_type |
| 93 : mime_type; | 94 : mime_type; |
| 94 | 95 // TODO(evanm): we probably shouldn't be doing this mapping to X ids at |
| 96 // this level. |
| 95 GdkNativeWindow plugin_parent = | 97 GdkNativeWindow plugin_parent = |
| 96 shell_->webViewHost()->CreatePluginContainer(); | 98 GDK_WINDOW_XWINDOW(shell_->webViewHost()->view_handle()->window); |
| 97 | 99 |
| 98 return WebPluginDelegateImpl::Create(info.path, mtype, plugin_parent); | 100 return WebPluginDelegateImpl::Create(info.path, mtype, plugin_parent); |
| 99 } | 101 } |
| 100 | 102 |
| 103 gfx::PluginWindowHandle TestWebViewDelegate::CreatePluginContainer() { |
| 104 return shell_->webViewHost()->CreatePluginContainer(); |
| 105 } |
| 106 |
| 101 void TestWebViewDelegate::WillDestroyPluginWindow(unsigned long id) { | 107 void TestWebViewDelegate::WillDestroyPluginWindow(unsigned long id) { |
| 102 shell_->webViewHost()->OnPluginWindowDestroyed(id); | 108 shell_->webViewHost()->OnPluginWindowDestroyed(id); |
| 103 } | 109 } |
| 104 | 110 |
| 105 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { | 111 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { |
| 106 GtkWidget* dialog = gtk_message_dialog_new( | 112 GtkWidget* dialog = gtk_message_dialog_new( |
| 107 shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, | 113 shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, |
| 108 GTK_BUTTONS_OK, "%s", WideToUTF8(message).c_str()); | 114 GTK_BUTTONS_OK, "%s", WideToUTF8(message).c_str()); |
| 109 gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert"); | 115 gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert"); |
| 110 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. | 116 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 const WebPluginGeometry& move) { | 231 const WebPluginGeometry& move) { |
| 226 WebWidgetHost* host = GetHostForWidget(webwidget); | 232 WebWidgetHost* host = GetHostForWidget(webwidget); |
| 227 | 233 |
| 228 // The "window" on WebPluginGeometry is actually the XEmbed parent | 234 // The "window" on WebPluginGeometry is actually the XEmbed parent |
| 229 // X window id. | 235 // X window id. |
| 230 GtkWidget* widget = ((WebViewHost*)host)->MapIDToWidget(move.window); | 236 GtkWidget* widget = ((WebViewHost*)host)->MapIDToWidget(move.window); |
| 231 // If we don't know about this plugin (maybe we're shutting down the | 237 // If we don't know about this plugin (maybe we're shutting down the |
| 232 // window?), ignore the message. | 238 // window?), ignore the message. |
| 233 if (!widget) | 239 if (!widget) |
| 234 return; | 240 return; |
| 235 DCHECK(!GTK_WIDGET_NO_WINDOW(widget) && GTK_WIDGET_REALIZED(widget)); | 241 DCHECK(!GTK_WIDGET_NO_WINDOW(widget)); |
| 242 DCHECK(GTK_WIDGET_REALIZED(widget)); |
| 236 | 243 |
| 237 if (!move.visible) { | 244 if (!move.visible) { |
| 238 gtk_widget_hide(widget); | 245 gtk_widget_hide(widget); |
| 239 return; | 246 return; |
| 240 } else { | 247 } else { |
| 241 gtk_widget_show(widget); | 248 gtk_widget_show(widget); |
| 242 } | 249 } |
| 243 | 250 |
| 244 // Update the clipping region on the GdkWindow. | 251 // Update the clipping region on the GdkWindow. |
| 245 GdkRectangle clip_rect = move.clip_rect.ToGdkRectangle(); | 252 GdkRectangle clip_rect = move.clip_rect.ToGdkRectangle(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // Private methods ----------------------------------------------------------- | 315 // Private methods ----------------------------------------------------------- |
| 309 | 316 |
| 310 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { | 317 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { |
| 311 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), | 318 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), |
| 312 ("Test Shell - " + WideToUTF8(title)).c_str()); | 319 ("Test Shell - " + WideToUTF8(title)).c_str()); |
| 313 } | 320 } |
| 314 | 321 |
| 315 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { | 322 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { |
| 316 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); | 323 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); |
| 317 } | 324 } |
| OLD | NEW |