d4ab7abd25fe20f2da34ed59a0cbeb851958a1c0
[WebKit-https.git] / WebKit / gtk / WebCoreSupport / ChromeClientGtk.cpp
1 /*
2  * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
3  * Copyright (C) 2007, 2008 Christian Dywan <christian@imendio.com>
4  * Copyright (C) 2008 Nuanti Ltd.
5  * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6  * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
7  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public
11  *  License as published by the Free Software Foundation; either
12  *  version 2 of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22  */
23
24 #include "config.h"
25 #include "ChromeClientGtk.h"
26
27 #include "Console.h"
28 #include "DumpRenderTreeSupportGtk.h"
29 #include "FileSystem.h"
30 #include "FileChooser.h"
31 #include "FloatRect.h"
32 #include "FrameLoadRequest.h"
33 #include "GtkVersioning.h"
34 #include "HTMLNames.h"
35 #include "IntRect.h"
36 #include "HitTestResult.h"
37 #include "Icon.h"
38 #include "KURL.h"
39 #include "NavigationAction.h"
40 #include "PlatformString.h"
41 #include "PopupMenuClient.h"
42 #include "PopupMenuGtk.h"
43 #include "SearchPopupMenuGtk.h"
44 #include "SecurityOrigin.h"
45 #include "webkitgeolocationpolicydecision.h"
46 #include "webkitwebview.h"
47 #include "webkitnetworkrequest.h"
48 #include "webkitprivate.h"
49 #include "NotImplemented.h"
50 #include "WindowFeatures.h"
51 #if ENABLE(DATABASE)
52 #include "DatabaseTracker.h"
53 #endif
54 #include <wtf/text/CString.h>
55
56 #include <glib.h>
57 #include <glib/gi18n-lib.h>
58 #include <gtk/gtk.h>
59
60 using namespace WebCore;
61
62 namespace WebKit {
63
64 ChromeClient::ChromeClient(WebKitWebView* webView)
65     : m_webView(webView)
66 {
67     ASSERT(m_webView);
68 }
69
70 void ChromeClient::chromeDestroyed()
71 {
72     delete this;
73 }
74
75 FloatRect ChromeClient::windowRect()
76 {
77     GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
78     if (gtk_widget_is_toplevel(window)) {
79         gint left, top, width, height;
80         gtk_window_get_position(GTK_WINDOW(window), &left, &top);
81         gtk_window_get_size(GTK_WINDOW(window), &width, &height);
82         return IntRect(left, top, width, height);
83     }
84     return FloatRect();
85 }
86
87 void ChromeClient::setWindowRect(const FloatRect& rect)
88 {
89     IntRect intrect = IntRect(rect);
90     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
91
92     g_object_set(webWindowFeatures,
93                  "x", intrect.x(),
94                  "y", intrect.y(),
95                  "width", intrect.width(),
96                  "height", intrect.height(),
97                  NULL);
98
99     gboolean autoResizeWindow;
100     WebKitWebSettings* settings = webkit_web_view_get_settings(m_webView);
101     g_object_get(settings, "auto-resize-window", &autoResizeWindow, NULL);
102
103     if (!autoResizeWindow)
104         return;
105
106     GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
107     if (gtk_widget_is_toplevel(window)) {
108         gtk_window_move(GTK_WINDOW(window), intrect.x(), intrect.y());
109         gtk_window_resize(GTK_WINDOW(window), intrect.width(), intrect.height());
110     }
111 }
112
113 FloatRect ChromeClient::pageRect()
114 {
115     GtkAllocation allocation;
116 #if GTK_CHECK_VERSION(2, 18, 0)
117     gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation);
118 #else
119     allocation = GTK_WIDGET(m_webView)->allocation;
120 #endif
121     return IntRect(allocation.x, allocation.y, allocation.width, allocation.height);
122 }
123
124 float ChromeClient::scaleFactor()
125 {
126     // Not implementable
127     return 1.0;
128 }
129
130 void ChromeClient::focus()
131 {
132     gtk_widget_grab_focus(GTK_WIDGET(m_webView));
133 }
134
135 void ChromeClient::unfocus()
136 {
137     GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
138     if (gtk_widget_is_toplevel(window))
139         gtk_window_set_focus(GTK_WINDOW(window), NULL);
140 }
141
142 Page* ChromeClient::createWindow(Frame* frame, const FrameLoadRequest& frameLoadRequest, const WindowFeatures& coreFeatures, const NavigationAction&)
143 {
144     WebKitWebView* webView = 0;
145
146     g_signal_emit_by_name(m_webView, "create-web-view", kit(frame), &webView);
147
148     if (!webView)
149         return 0;
150
151     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_window_features_new_from_core_features(coreFeatures);
152     g_object_set(webView, "window-features", webWindowFeatures, NULL);
153     g_object_unref(webWindowFeatures);
154
155     if (!frameLoadRequest.isEmpty())
156         webkit_web_view_open(webView, frameLoadRequest.resourceRequest().url().string().utf8().data());
157
158     return core(webView);
159 }
160
161 void ChromeClient::show()
162 {
163     webkit_web_view_notify_ready(m_webView);
164 }
165
166 bool ChromeClient::canRunModal()
167 {
168     notImplemented();
169     return false;
170 }
171
172 void ChromeClient::runModal()
173 {
174     notImplemented();
175 }
176
177 void ChromeClient::setToolbarsVisible(bool visible)
178 {
179     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
180
181     g_object_set(webWindowFeatures, "toolbar-visible", visible, NULL);
182 }
183
184 bool ChromeClient::toolbarsVisible()
185 {
186     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
187     gboolean visible;
188
189     g_object_get(webWindowFeatures, "toolbar-visible", &visible, NULL);
190     return visible;
191 }
192
193 void ChromeClient::setStatusbarVisible(bool visible)
194 {
195     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
196
197     g_object_set(webWindowFeatures, "statusbar-visible", visible, NULL);
198 }
199
200 bool ChromeClient::statusbarVisible()
201 {
202     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
203     gboolean visible;
204
205     g_object_get(webWindowFeatures, "statusbar-visible", &visible, NULL);
206     return visible;
207 }
208
209 void ChromeClient::setScrollbarsVisible(bool visible)
210 {
211     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
212
213     g_object_set(webWindowFeatures, "scrollbar-visible", visible, NULL);
214 }
215
216 bool ChromeClient::scrollbarsVisible() {
217     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
218     gboolean visible;
219
220     g_object_get(webWindowFeatures, "scrollbar-visible", &visible, NULL);
221     return visible;
222 }
223
224 void ChromeClient::setMenubarVisible(bool visible)
225 {
226     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
227
228     g_object_set(webWindowFeatures, "menubar-visible", visible, NULL);
229 }
230
231 bool ChromeClient::menubarVisible()
232 {
233     WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView);
234     gboolean visible;
235
236     g_object_get(webWindowFeatures, "menubar-visible", &visible, NULL);
237     return visible;
238 }
239
240 void ChromeClient::setResizable(bool)
241 {
242     // Ignored for now
243 }
244
245 void ChromeClient::closeWindowSoon()
246 {
247     // We may not have a WebView as create-web-view can return NULL.
248     if (!m_webView)
249         return;
250
251     webkit_web_view_stop_loading(m_webView);
252
253     gboolean isHandled = false;
254     g_signal_emit_by_name(m_webView, "close-web-view", &isHandled);
255
256     if (isHandled)
257         return;
258
259     // FIXME: should we clear the frame group name here explicitly? Mac does it.
260     // But this gets cleared in Page's destructor anyway.
261     // webkit_web_view_set_group_name(m_webView, "");
262 }
263
264 bool ChromeClient::canTakeFocus(FocusDirection)
265 {
266     return gtk_widget_get_can_focus(GTK_WIDGET(m_webView));
267 }
268
269 void ChromeClient::takeFocus(FocusDirection)
270 {
271     unfocus();
272 }
273
274 void ChromeClient::focusedNodeChanged(Node*)
275 {
276 }
277
278 void ChromeClient::focusedFrameChanged(Frame*)
279 {
280 }
281
282 bool ChromeClient::canRunBeforeUnloadConfirmPanel()
283 {
284     return true;
285 }
286
287 bool ChromeClient::runBeforeUnloadConfirmPanel(const WTF::String& message, WebCore::Frame* frame)
288 {
289     return runJavaScriptConfirm(frame, message);
290 }
291
292 void ChromeClient::addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceId)
293 {
294     gboolean retval;
295     g_signal_emit_by_name(m_webView, "console-message", message.utf8().data(), lineNumber, sourceId.utf8().data(), &retval);
296 }
297
298 void ChromeClient::runJavaScriptAlert(Frame* frame, const String& message)
299 {
300     gboolean retval;
301     g_signal_emit_by_name(m_webView, "script-alert", kit(frame), message.utf8().data(), &retval);
302 }
303
304 bool ChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
305 {
306     gboolean retval;
307     gboolean didConfirm;
308     g_signal_emit_by_name(m_webView, "script-confirm", kit(frame), message.utf8().data(), &didConfirm, &retval);
309     return didConfirm == TRUE;
310 }
311
312 bool ChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
313 {
314     gboolean retval;
315     gchar* value = 0;
316     g_signal_emit_by_name(m_webView, "script-prompt", kit(frame), message.utf8().data(), defaultValue.utf8().data(), &value, &retval);
317     if (value) {
318         result = String::fromUTF8(value);
319         g_free(value);
320         return true;
321     }
322     return false;
323 }
324
325 void ChromeClient::setStatusbarText(const String& string)
326 {
327     CString stringMessage = string.utf8();
328     g_signal_emit_by_name(m_webView, "status-bar-text-changed", stringMessage.data());
329 }
330
331 bool ChromeClient::shouldInterruptJavaScript()
332 {
333     notImplemented();
334     return false;
335 }
336
337 bool ChromeClient::tabsToLinks() const
338 {
339     if (DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled())
340         return DumpRenderTreeSupportGtk::linksIncludedInFocusChain();
341
342     return true;
343 }
344
345 IntRect ChromeClient::windowResizerRect() const
346 {
347     notImplemented();
348     return IntRect();
349 }
350
351 void ChromeClient::invalidateWindow(const IntRect&, bool)
352 {
353     notImplemented();
354 }
355
356 void ChromeClient::invalidateContentsAndWindow(const IntRect& updateRect, bool immediate)
357 {
358     GdkRectangle rect = updateRect;
359     GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(m_webView));
360
361     if (window) {
362         gdk_window_invalidate_rect(window, &rect, FALSE);
363         // We don't currently do immediate updates since they delay other UI elements.
364         //if (immediate)
365         //    gdk_window_process_updates(window, FALSE);
366     }
367 }
368
369 void ChromeClient::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate)
370 {
371     invalidateContentsAndWindow(updateRect, immediate);
372 }
373
374 void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, const IntRect& clipRect)
375 {
376     GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(m_webView));
377     if (!window)
378         return;
379
380     // We cannot use gdk_window_scroll here because it is only able to
381     // scroll the whole window at once, and we often need to scroll
382     // portions of the window only (think frames).
383     GdkRectangle area = clipRect;
384     GdkRectangle moveRect;
385
386     GdkRectangle sourceRect = area;
387     sourceRect.x -= delta.width();
388     sourceRect.y -= delta.height();
389
390 #ifdef GTK_API_VERSION_2
391     GdkRegion* invalidRegion = gdk_region_rectangle(&area);
392
393     if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) {
394         GdkRegion* moveRegion = gdk_region_rectangle(&moveRect);
395         gdk_window_move_region(window, moveRegion, delta.width(), delta.height());
396         gdk_region_offset(moveRegion, delta.width(), delta.height());
397         gdk_region_subtract(invalidRegion, moveRegion);
398         gdk_region_destroy(moveRegion);
399     }
400
401     gdk_window_invalidate_region(window, invalidRegion, FALSE);
402     gdk_region_destroy(invalidRegion);
403 #else
404     cairo_region_t* invalidRegion = cairo_region_create_rectangle(&area);
405
406     if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) {
407         cairo_region_t* moveRegion = cairo_region_create_rectangle(&moveRect);
408         gdk_window_move_region(window, moveRegion, delta.width(), delta.height());
409         cairo_region_translate(moveRegion, delta.width(), delta.height());
410         cairo_region_subtract(invalidRegion, moveRegion);
411         cairo_region_destroy(moveRegion);
412     }
413
414     gdk_window_invalidate_region(window, invalidRegion, FALSE);
415     cairo_region_destroy(invalidRegion);
416 #endif
417
418 }
419
420 // FIXME: this does not take into account the WM decorations
421 static IntPoint widgetScreenPosition(GtkWidget* widget)
422 {
423     GtkWidget* window = gtk_widget_get_toplevel(widget);
424     int widgetX = 0, widgetY = 0;
425
426     gtk_widget_translate_coordinates(widget, window, 0, 0, &widgetX, &widgetY);
427
428     IntPoint result(widgetX, widgetY);
429     int originX, originY;
430     gdk_window_get_origin(gtk_widget_get_window(window), &originX, &originY);
431     result.move(originX, originY);
432
433     return result;
434 }
435
436 IntRect ChromeClient::windowToScreen(const IntRect& rect) const
437 {
438     IntRect result(rect);
439     IntPoint screenPosition = widgetScreenPosition(GTK_WIDGET(m_webView));
440     result.move(screenPosition.x(), screenPosition.y());
441
442     return result;
443 }
444
445 IntPoint ChromeClient::screenToWindow(const IntPoint& point) const
446 {
447     IntPoint result(point);
448     IntPoint screenPosition = widgetScreenPosition(GTK_WIDGET(m_webView));
449     result.move(-screenPosition.x(), -screenPosition.y());
450
451     return result;
452 }
453
454 PlatformPageClient ChromeClient::platformPageClient() const
455 {
456     return GTK_WIDGET(m_webView);
457 }
458
459 void ChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
460 {
461     // We need to queue a resize request only if the size changed,
462     // otherwise we get into an infinite loop!
463     GtkWidget* widget = GTK_WIDGET(m_webView);
464     GtkRequisition requisition;
465 #if GTK_CHECK_VERSION(2, 20, 0)
466     gtk_widget_get_requisition(widget, &requisition);
467 #else
468     requisition = widget->requisition;
469 #endif
470     if (gtk_widget_get_realized(widget)
471         && (requisition.height != size.height())
472         || (requisition.width != size.width()))
473         gtk_widget_queue_resize_no_redraw(widget);
474 }
475
476 void ChromeClient::scrollbarsModeDidChange() const
477 {
478     WebKitWebFrame* webFrame = webkit_web_view_get_main_frame(m_webView);
479
480     g_object_notify(G_OBJECT(webFrame), "horizontal-scrollbar-policy");
481     g_object_notify(G_OBJECT(webFrame), "vertical-scrollbar-policy");
482
483     gboolean isHandled;
484     g_signal_emit_by_name(webFrame, "scrollbars-policy-changed", &isHandled);
485
486     if (isHandled)
487         return;
488
489     GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(m_webView));
490     if (!parent || !GTK_IS_SCROLLED_WINDOW(parent))
491         return;
492
493     GtkPolicyType horizontalPolicy = webkit_web_frame_get_horizontal_scrollbar_policy(webFrame);
494     GtkPolicyType verticalPolicy = webkit_web_frame_get_vertical_scrollbar_policy(webFrame);
495
496     // ScrolledWindow doesn't like to display only part of a widget if
497     // the scrollbars are completely disabled; We have a disparity
498     // here on what the policy requested by the web app is and what we
499     // can represent; the idea is not to show scrollbars, only.
500     if (horizontalPolicy == GTK_POLICY_NEVER)
501         horizontalPolicy = GTK_POLICY_AUTOMATIC;
502
503     if (verticalPolicy == GTK_POLICY_NEVER)
504         verticalPolicy = GTK_POLICY_AUTOMATIC;
505
506     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(parent),
507                                    horizontalPolicy, verticalPolicy);
508 }
509
510 void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags)
511 {
512     // check if the element is a link...
513     bool isLink = hit.isLiveLink();
514     if (isLink) {
515         KURL url = hit.absoluteLinkURL();
516         if (!url.isEmpty() && url != m_hoveredLinkURL) {
517             TextDirection dir;
518             CString titleString = hit.title(dir).utf8();
519             CString urlString = url.prettyURL().utf8();
520             g_signal_emit_by_name(m_webView, "hovering-over-link", titleString.data(), urlString.data());
521             m_hoveredLinkURL = url;
522         }
523     } else if (!isLink && !m_hoveredLinkURL.isEmpty()) {
524         g_signal_emit_by_name(m_webView, "hovering-over-link", 0, 0);
525         m_hoveredLinkURL = KURL();
526     }
527 }
528
529 void ChromeClient::setToolTip(const String& toolTip, TextDirection)
530 {
531     webkit_web_view_set_tooltip_text(m_webView, toolTip.utf8().data());
532 }
533
534 void ChromeClient::print(Frame* frame)
535 {
536     WebKitWebFrame* webFrame = kit(frame);
537     gboolean isHandled = false;
538     g_signal_emit_by_name(m_webView, "print-requested", webFrame, &isHandled);
539
540     if (isHandled)
541         return;
542
543     webkit_web_frame_print(webFrame);
544 }
545
546 #if ENABLE(DATABASE)
547 void ChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
548 {
549     guint64 defaultQuota = webkit_get_default_web_database_quota();
550     DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), defaultQuota);
551
552     WebKitWebFrame* webFrame = kit(frame);
553     WebKitWebView* webView = getViewFromFrame(webFrame);
554
555     WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(webFrame);
556     WebKitWebDatabase* webDatabase = webkit_security_origin_get_web_database(origin, databaseName.utf8().data());
557     g_signal_emit_by_name(webView, "database-quota-exceeded", webFrame, webDatabase);
558 }
559 #endif
560
561 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
562 void ChromeClient::reachedMaxAppCacheSize(int64_t spaceNeeded)
563 {
564     // FIXME: Free some space.
565     notImplemented();
566 }
567
568 void ChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*)
569 {
570     notImplemented();
571 }
572 #endif
573
574 void ChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser)
575 {
576     RefPtr<FileChooser> chooser = prpFileChooser;
577
578     GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
579                                                     GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(platformPageClient()))),
580                                                     GTK_FILE_CHOOSER_ACTION_OPEN,
581                                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
582                                                     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
583                                                     NULL);
584
585     gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), chooser->allowsMultipleFiles());
586
587     if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
588         if (gtk_file_chooser_get_select_multiple(GTK_FILE_CHOOSER(dialog))) {
589             GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
590             Vector<String> names;
591             for (GSList* item = filenames ; item ; item = item->next) {
592                 if (!item->data)
593                     continue;
594                 names.append(filenameToString(static_cast<char*>(item->data)));
595                 g_free(item->data);
596             }
597             g_slist_free(filenames);
598             chooser->chooseFiles(names);
599         } else {
600             gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
601             if (filename)
602                 chooser->chooseFile(filenameToString(filename));
603             g_free(filename);
604         }
605     }
606     gtk_widget_destroy(dialog);
607 }
608
609 void ChromeClient::chooseIconForFiles(const Vector<WTF::String>& filenames, WebCore::FileChooser* chooser)
610 {
611     chooser->iconLoaded(Icon::createIconForFiles(filenames));
612 }
613
614 void ChromeClient::setCursor(const Cursor&)
615 {
616     notImplemented();
617 }
618
619 void ChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
620 {
621     WebKitWebFrame* webFrame = kit(frame);
622     WebKitWebView* webView = getViewFromFrame(webFrame);
623
624     PlatformRefPtr<WebKitGeolocationPolicyDecision> policyDecision(adoptPlatformRef(webkit_geolocation_policy_decision_new(webFrame, geolocation)));
625
626     gboolean isHandled = FALSE;
627     g_signal_emit_by_name(webView, "geolocation-policy-decision-requested", webFrame, policyDecision.get(), &isHandled);
628     if (!isHandled)
629         webkit_geolocation_policy_deny(policyDecision.get());
630 }
631
632 void ChromeClient::cancelGeolocationPermissionRequestForFrame(WebCore::Frame* frame, WebCore::Geolocation*)
633 {
634     WebKitWebFrame* webFrame = kit(frame);
635     WebKitWebView* webView = getViewFromFrame(webFrame);
636     g_signal_emit_by_name(webView, "geolocation-policy-decision-cancelled", webFrame);
637 }
638
639 bool ChromeClient::selectItemWritingDirectionIsNatural()
640 {
641     return true;
642 }
643
644 PassRefPtr<WebCore::PopupMenu> ChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
645 {
646     return adoptRef(new PopupMenuGtk(client));
647 }
648
649 PassRefPtr<WebCore::SearchPopupMenu> ChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
650 {
651     return adoptRef(new SearchPopupMenuGtk(client));
652 }
653
654 #if ENABLE(VIDEO)
655
656 bool ChromeClient::supportsFullscreenForNode(const Node* node)
657 {
658     return node->hasTagName(HTMLNames::videoTag);
659 }
660
661 void ChromeClient::enterFullscreenForNode(Node* node)
662 {
663     WebCore::Frame* frame = node->document()->frame();
664     WebKitWebFrame* webFrame = kit(frame);
665     WebKitWebView* webView = getViewFromFrame(webFrame);
666     webkitWebViewEnterFullscreen(webView, node);
667 }
668
669 void ChromeClient::exitFullscreenForNode(Node* node)
670 {
671     WebCore::Frame* frame = node->document()->frame();
672     WebKitWebFrame* webFrame = kit(frame);
673     WebKitWebView* webView = getViewFromFrame(webFrame);
674     webkitWebViewExitFullscreen(webView);
675 }
676 #endif
677
678 }