Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1159)

Side by Side Diff: webkit/tools/test_shell/test_webview_delegate_gtk.cc

Issue 181014: Eliminate remaining WebCore dependencies from webplugin_impl.cc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 reinterpret_cast<const guchar*>(selection.data()), 75 reinterpret_cast<const guchar*>(selection.data()),
76 selection.length()); 76 selection.length());
77 } else { 77 } else {
78 gtk_selection_data_set_text(selection_data, selection.data(), 78 gtk_selection_data_set_text(selection_data, selection.data(),
79 selection.length()); 79 selection.length());
80 } 80 }
81 } 81 }
82 82
83 } // namespace 83 } // namespace
84 84
85 // WebViewDelegate ----------------------------------------------------------- 85 // WebViewDelegate ------------------------------------------------------------
86
87 WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
88 WebView* webview,
89 const GURL& url,
90 const std::string& mime_type,
91 const std::string& clsid,
92 std::string* actual_mime_type) {
93 bool allow_wildcard = true;
94 WebPluginInfo info;
95 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
96 allow_wildcard, &info,
97 actual_mime_type))
98 return NULL;
99
100 const std::string& mtype =
101 (actual_mime_type && !actual_mime_type->empty()) ? *actual_mime_type
102 : mime_type;
103 // TODO(evanm): we probably shouldn't be doing this mapping to X ids at
104 // this level.
105 GdkNativeWindow plugin_parent =
106 GDK_WINDOW_XWINDOW(shell_->webViewHost()->view_handle()->window);
107
108 return WebPluginDelegateImpl::Create(info.path, mtype, plugin_parent);
109 }
110
111 void TestWebViewDelegate::CreatedPluginWindow(gfx::PluginWindowHandle id) {
112 shell_->webViewHost()->CreatePluginContainer(id);
113 }
114
115 void TestWebViewDelegate::WillDestroyPluginWindow(gfx::PluginWindowHandle id) {
116 shell_->webViewHost()->DestroyPluginContainer(id);
117 }
118 86
119 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { 87 void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
120 GtkWidget* dialog = gtk_message_dialog_new( 88 GtkWidget* dialog = gtk_message_dialog_new(
121 shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, 89 shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
122 GTK_BUTTONS_OK, "%s", WideToUTF8(message).c_str()); 90 GTK_BUTTONS_OK, "%s", WideToUTF8(message).c_str());
123 gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert"); 91 gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert");
124 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. 92 gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop.
125 gtk_widget_destroy(dialog); 93 gtk_widget_destroy(dialog);
126 } 94 }
127 95
96 // WebWidgetClient ------------------------------------------------------------
97
128 void TestWebViewDelegate::show(WebNavigationPolicy policy) { 98 void TestWebViewDelegate::show(WebNavigationPolicy policy) {
129 WebWidgetHost* host = GetWidgetHost(); 99 WebWidgetHost* host = GetWidgetHost();
130 GtkWidget* drawing_area = host->view_handle(); 100 GtkWidget* drawing_area = host->view_handle();
131 GtkWidget* window = 101 GtkWidget* window =
132 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); 102 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area));
133 gtk_widget_show_all(window); 103 gtk_widget_show_all(window);
134 } 104 }
135 105
136 void TestWebViewDelegate::closeWidgetSoon() { 106 void TestWebViewDelegate::closeWidgetSoon() {
137 if (this == shell_->delegate()) { 107 if (this == shell_->delegate()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return WebRect(x, y, width, height); 183 return WebRect(x, y, width, height);
214 } 184 }
215 return WebRect(); 185 return WebRect();
216 } 186 }
217 187
218 WebRect TestWebViewDelegate::windowResizerRect() { 188 WebRect TestWebViewDelegate::windowResizerRect() {
219 // Not necessary on Linux. 189 // Not necessary on Linux.
220 return WebRect(); 190 return WebRect();
221 } 191 }
222 192
223 void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) { 193 void TestWebViewDelegate::runModal() {
194 NOTIMPLEMENTED();
195 }
196
197 // WebPluginPageDelegate ------------------------------------------------------
198
199 webkit_glue::WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
200 const GURL& url,
201 const std::string& mime_type,
202 const std::string& clsid,
203 std::string* actual_mime_type) {
204 bool allow_wildcard = true;
205 WebPluginInfo info;
206 if (!NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
207 allow_wildcard, &info,
208 actual_mime_type))
209 return NULL;
210
211 const std::string& mtype =
212 (actual_mime_type && !actual_mime_type->empty()) ? *actual_mime_type
213 : mime_type;
214 // TODO(evanm): we probably shouldn't be doing this mapping to X ids at
215 // this level.
216 GdkNativeWindow plugin_parent =
217 GDK_WINDOW_XWINDOW(shell_->webViewHost()->view_handle()->window);
218
219 return WebPluginDelegateImpl::Create(info.path, mtype, plugin_parent);
220 }
221
222 void TestWebViewDelegate::CreatedPluginWindow(
223 gfx::PluginWindowHandle id) {
224 shell_->webViewHost()->CreatePluginContainer(id);
225 }
226
227 void TestWebViewDelegate::WillDestroyPluginWindow(
228 gfx::PluginWindowHandle id) {
229 shell_->webViewHost()->DestroyPluginContainer(id);
230 }
231
232 void TestWebViewDelegate::DidMovePlugin(
233 const webkit_glue::WebPluginGeometry& move) {
224 WebWidgetHost* host = GetWidgetHost(); 234 WebWidgetHost* host = GetWidgetHost();
225 GtkPluginContainerManager* plugin_container_manager = 235 GtkPluginContainerManager* plugin_container_manager =
226 static_cast<WebViewHost*>(host)->plugin_container_manager(); 236 static_cast<WebViewHost*>(host)->plugin_container_manager();
227 plugin_container_manager->MovePluginContainer(move); 237 plugin_container_manager->MovePluginContainer(move);
228 } 238 }
229 239
230 void TestWebViewDelegate::runModal() { 240 // Public methods -------------------------------------------------------------
231 NOTIMPLEMENTED();
232 }
233 241
234 void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) { 242 void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) {
235 if (is_empty_selection) 243 if (is_empty_selection)
236 return; 244 return;
237 245
238 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); 246 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
239 // Put data on the X clipboard. This doesn't actually grab the text from 247 // Put data on the X clipboard. This doesn't actually grab the text from
240 // the HTML, it just registers a callback for when someone tries to paste. 248 // the HTML, it just registers a callback for when someone tries to paste.
241 GtkTargetList* target_list = gtk_target_list_new(NULL, 0); 249 GtkTargetList* target_list = gtk_target_list_new(NULL, 0);
242 gtk_target_list_add(target_list, GetTextHtmlAtom(), 0, TEXT_HTML); 250 gtk_target_list_add(target_list, GetTextHtmlAtom(), 0, TEXT_HTML);
243 gtk_target_list_add_text_targets(target_list, PLAIN_TEXT); 251 gtk_target_list_add_text_targets(target_list, PLAIN_TEXT);
244 252
245 gint num_targets = 0; 253 gint num_targets = 0;
246 GtkTargetEntry* targets = gtk_target_table_new_from_list(target_list, 254 GtkTargetEntry* targets = gtk_target_table_new_from_list(target_list,
247 &num_targets); 255 &num_targets);
248 gtk_clipboard_set_with_data(clipboard, targets, num_targets, 256 gtk_clipboard_set_with_data(clipboard, targets, num_targets,
249 SelectionClipboardGetContents, NULL, 257 SelectionClipboardGetContents, NULL,
250 shell_->webView()); 258 shell_->webView());
251 gtk_target_list_unref(target_list); 259 gtk_target_list_unref(target_list);
252 gtk_target_table_free(targets, num_targets); 260 gtk_target_table_free(targets, num_targets);
253 } 261 }
254 262
255 // Private methods ----------------------------------------------------------- 263 // Private methods ------------------------------------------------------------
256 264
257 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { 265 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) {
258 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), 266 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()),
259 ("Test Shell - " + WideToUTF8(title)).c_str()); 267 ("Test Shell - " + WideToUTF8(title)).c_str());
260 } 268 }
261 269
262 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { 270 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) {
263 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); 271 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str());
264 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698