| 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> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "webkit/glue/plugins/gtk_plugin_container_manager.h" | 29 #include "webkit/glue/plugins/gtk_plugin_container_manager.h" |
| 30 #include "webkit/glue/plugins/plugin_list.h" | 30 #include "webkit/glue/plugins/plugin_list.h" |
| 31 #include "webkit/glue/window_open_disposition.h" | 31 #include "webkit/glue/window_open_disposition.h" |
| 32 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 32 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 33 #include "webkit/tools/test_shell/test_navigation_controller.h" | 33 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 34 #include "webkit/tools/test_shell/test_shell.h" | 34 #include "webkit/tools/test_shell/test_shell.h" |
| 35 | 35 |
| 36 using WebKit::WebCursorInfo; | 36 using WebKit::WebCursorInfo; |
| 37 using WebKit::WebFrame; | 37 using WebKit::WebFrame; |
| 38 using WebKit::WebNavigationPolicy; | 38 using WebKit::WebNavigationPolicy; |
| 39 using WebKit::WebPopupMenuInfo; |
| 39 using WebKit::WebRect; | 40 using WebKit::WebRect; |
| 41 using WebKit::WebWidget; |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 enum SelectionClipboardType { | 45 enum SelectionClipboardType { |
| 44 TEXT_HTML, | 46 TEXT_HTML, |
| 45 PLAIN_TEXT, | 47 PLAIN_TEXT, |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 GdkAtom GetTextHtmlAtom() { | 50 GdkAtom GetTextHtmlAtom() { |
| 49 GdkAtom kTextHtmlGdkAtom = gdk_atom_intern_static_string("text/html"); | 51 GdkAtom kTextHtmlGdkAtom = gdk_atom_intern_static_string("text/html"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 75 reinterpret_cast<const guchar*>(selection.data()), | 77 reinterpret_cast<const guchar*>(selection.data()), |
| 76 selection.length()); | 78 selection.length()); |
| 77 } else { | 79 } else { |
| 78 gtk_selection_data_set_text(selection_data, selection.data(), | 80 gtk_selection_data_set_text(selection_data, selection.data(), |
| 79 selection.length()); | 81 selection.length()); |
| 80 } | 82 } |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace | 85 } // namespace |
| 84 | 86 |
| 85 // WebViewDelegate ------------------------------------------------------------ | 87 // WebViewClient -------------------------------------------------------------- |
| 86 | 88 |
| 87 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { | 89 WebWidget* TestWebViewDelegate::createPopupMenu( |
| 88 GtkWidget* dialog = gtk_message_dialog_new( | 90 const WebPopupMenuInfo& info) { |
| 89 shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, | 91 NOTREACHED(); |
| 90 GTK_BUTTONS_OK, "%s", WideToUTF8(message).c_str()); | 92 return NULL; |
| 91 gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert"); | |
| 92 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. | |
| 93 gtk_widget_destroy(dialog); | |
| 94 } | 93 } |
| 95 | 94 |
| 96 // WebWidgetClient ------------------------------------------------------------ | 95 // WebWidgetClient ------------------------------------------------------------ |
| 97 | 96 |
| 98 void TestWebViewDelegate::show(WebNavigationPolicy policy) { | 97 void TestWebViewDelegate::show(WebNavigationPolicy policy) { |
| 99 WebWidgetHost* host = GetWidgetHost(); | 98 WebWidgetHost* host = GetWidgetHost(); |
| 100 GtkWidget* drawing_area = host->view_handle(); | 99 GtkWidget* drawing_area = host->view_handle(); |
| 101 GtkWidget* window = | 100 GtkWidget* window = |
| 102 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); | 101 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); |
| 103 gtk_widget_show_all(window); | 102 gtk_widget_show_all(window); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 &num_targets); | 253 &num_targets); |
| 255 gtk_clipboard_set_with_data(clipboard, targets, num_targets, | 254 gtk_clipboard_set_with_data(clipboard, targets, num_targets, |
| 256 SelectionClipboardGetContents, NULL, | 255 SelectionClipboardGetContents, NULL, |
| 257 shell_->webView()); | 256 shell_->webView()); |
| 258 gtk_target_list_unref(target_list); | 257 gtk_target_list_unref(target_list); |
| 259 gtk_target_table_free(targets, num_targets); | 258 gtk_target_table_free(targets, num_targets); |
| 260 } | 259 } |
| 261 | 260 |
| 262 // Private methods ------------------------------------------------------------ | 261 // Private methods ------------------------------------------------------------ |
| 263 | 262 |
| 263 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { |
| 264 GtkWidget* dialog = gtk_message_dialog_new( |
| 265 shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, |
| 266 GTK_BUTTONS_OK, "%s", WideToUTF8(message).c_str()); |
| 267 gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert"); |
| 268 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. |
| 269 gtk_widget_destroy(dialog); |
| 270 } |
| 271 |
| 264 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { | 272 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { |
| 265 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), | 273 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), |
| 266 ("Test Shell - " + WideToUTF8(title)).c_str()); | 274 ("Test Shell - " + WideToUTF8(title)).c_str()); |
| 267 } | 275 } |
| 268 | 276 |
| 269 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { | 277 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { |
| 270 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); | 278 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); |
| 271 } | 279 } |
| OLD | NEW |