Reviewed by Darin Adler.
[WebKit-https.git] / Source / WebKit / qt / WebCoreSupport / ChromeClientQt.cpp
1 /*
2  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
3  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "config.h"
31 #include "ChromeClientQt.h"
32
33 #include "ApplicationCacheStorage.h"
34 #include "DatabaseTracker.h"
35 #include "FileChooser.h"
36 #include "Frame.h"
37 #include "FrameLoadRequest.h"
38 #include "FrameLoader.h"
39 #include "FrameLoaderClientQt.h"
40 #include "FrameView.h"
41 #include "Geolocation.h"
42 #if USE(ACCELERATED_COMPOSITING)
43 #include "GraphicsLayer.h"
44 #endif
45 #include "HitTestResult.h"
46 #include "Icon.h"
47 #include "NavigationAction.h"
48 #include "NetworkingContext.h"
49 #include "NotImplemented.h"
50 #include "NotificationPresenterClientQt.h"
51 #include "PageClientQt.h"
52 #include "PopupMenuQt.h"
53 #if defined(Q_WS_MAEMO_5)
54 #include "QtMaemoWebPopup.h"
55 #else
56 #include "QtFallbackWebPopup.h"
57 #endif
58 #include "QWebPageClient.h"
59 #include "ScrollbarTheme.h"
60 #include "SearchPopupMenuQt.h"
61 #include "SecurityOrigin.h"
62 #include "ViewportArguments.h"
63 #include "WindowFeatures.h"
64
65 #include "qgraphicswebview.h"
66 #include "qwebframe_p.h"
67 #include "qwebpage.h"
68 #include "qwebpage_p.h"
69 #include "qwebsecurityorigin.h"
70 #include "qwebsecurityorigin_p.h"
71 #include "qwebview.h"
72 #include <qdebug.h>
73 #include <qeventloop.h>
74 #include <qtextdocument.h>
75 #include <qtooltip.h>
76 #include <wtf/OwnPtr.h>
77
78 #if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
79 #include "FullScreenVideoQt.h"
80 #include "HTMLMediaElement.h"
81 #include "HTMLNames.h"
82 #include "HTMLVideoElement.h"
83 #include "MediaPlayerPrivateQt.h"
84 #endif
85
86 namespace WebCore {
87
88 bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
89
90 ChromeClientQt::ChromeClientQt(QWebPage* webPage)
91     : m_webPage(webPage)
92     , m_eventLoop(0)
93 #if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
94     , m_fullScreenVideo(0)
95 #endif
96 {
97     toolBarsVisible = statusBarVisible = menuBarVisible = true;
98 }
99
100 ChromeClientQt::~ChromeClientQt()
101 {
102     if (m_eventLoop)
103         m_eventLoop->exit();
104
105 #if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
106     delete m_fullScreenVideo;
107 #endif
108 }
109
110 void ChromeClientQt::setWindowRect(const FloatRect& rect)
111 {
112     if (!m_webPage)
113         return;
114     emit m_webPage->geometryChangeRequested(QRect(qRound(rect.x()), qRound(rect.y()),
115                             qRound(rect.width()), qRound(rect.height())));
116 }
117
118 /*!
119     windowRect represents the rect of the Window, including all interface elements
120     like toolbars/scrollbars etc. It is used by the viewport meta tag as well as
121     by the DOM Window object: outerHeight(), outerWidth(), screenX(), screenY().
122 */
123 FloatRect ChromeClientQt::windowRect()
124 {
125     if (!platformPageClient())
126         return FloatRect();
127     return platformPageClient()->windowRect();
128 }
129
130 FloatRect ChromeClientQt::pageRect()
131 {
132     if (!m_webPage)
133         return FloatRect();
134     return FloatRect(QRectF(QPointF(0, 0), m_webPage->viewportSize()));
135 }
136
137 float ChromeClientQt::scaleFactor()
138 {
139     if (!m_webPage)
140         return 1;
141     return m_webPage->d->pixelRatio;
142 }
143
144 void ChromeClientQt::focus()
145 {
146     if (!m_webPage)
147         return;
148     QWidget* view = m_webPage->view();
149     if (!view)
150         return;
151
152     view->setFocus();
153 }
154
155
156 void ChromeClientQt::unfocus()
157 {
158     if (!m_webPage)
159         return;
160     QWidget* view = m_webPage->view();
161     if (!view)
162         return;
163     view->clearFocus();
164 }
165
166 bool ChromeClientQt::canTakeFocus(FocusDirection)
167 {
168     // This is called when cycling through links/focusable objects and we
169     // reach the last focusable object. Then we want to claim that we can
170     // take the focus to avoid wrapping.
171     return true;
172 }
173
174 void ChromeClientQt::takeFocus(FocusDirection)
175 {
176     // don't do anything. This is only called when cycling to links/focusable objects,
177     // which in turn is called from focusNextPrevChild. We let focusNextPrevChild
178     // call QWidget::focusNextPrevChild accordingly, so there is no need to do anything
179     // here.
180 }
181
182
183 void ChromeClientQt::focusedNodeChanged(Node*)
184 {
185 }
186
187 void ChromeClientQt::focusedFrameChanged(Frame*)
188 {
189 }
190
191 Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features, const NavigationAction&)
192 {
193     QWebPage* newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow);
194     if (!newPage)
195         return 0;
196
197     // A call to QWebPage::mainFrame() implicitly creates the main frame.
198     // Make sure it exists, as WebCore expects it when returning from this call.
199     newPage->mainFrame();
200     return newPage->d->page;
201 }
202
203 void ChromeClientQt::show()
204 {
205     if (!m_webPage)
206         return;
207     QWidget* view = m_webPage->view();
208     if (!view)
209         return;
210     view->window()->show();
211 }
212
213
214 bool ChromeClientQt::canRunModal()
215 {
216     return true;
217 }
218
219
220 void ChromeClientQt::runModal()
221 {
222     m_eventLoop = new QEventLoop();
223     QEventLoop* eventLoop = m_eventLoop;
224     m_eventLoop->exec();
225     delete eventLoop;
226 }
227
228
229 void ChromeClientQt::setToolbarsVisible(bool visible)
230 {
231     toolBarsVisible = visible;
232     emit m_webPage->toolBarVisibilityChangeRequested(visible);
233 }
234
235
236 bool ChromeClientQt::toolbarsVisible()
237 {
238     return toolBarsVisible;
239 }
240
241
242 void ChromeClientQt::setStatusbarVisible(bool visible)
243 {
244     emit m_webPage->statusBarVisibilityChangeRequested(visible);
245     statusBarVisible = visible;
246 }
247
248
249 bool ChromeClientQt::statusbarVisible()
250 {
251     return statusBarVisible;
252 }
253
254
255 void ChromeClientQt::setScrollbarsVisible(bool)
256 {
257     notImplemented();
258 }
259
260
261 bool ChromeClientQt::scrollbarsVisible()
262 {
263     notImplemented();
264     return true;
265 }
266
267
268 void ChromeClientQt::setMenubarVisible(bool visible)
269 {
270     menuBarVisible = visible;
271     emit m_webPage->menuBarVisibilityChangeRequested(visible);
272 }
273
274 bool ChromeClientQt::menubarVisible()
275 {
276     return menuBarVisible;
277 }
278
279 void ChromeClientQt::setResizable(bool)
280 {
281     notImplemented();
282 }
283
284 void ChromeClientQt::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message,
285                                          unsigned int lineNumber, const String& sourceID)
286 {
287     QString x = message;
288     QString y = sourceID;
289     m_webPage->javaScriptConsoleMessage(x, lineNumber, y);
290 }
291
292 void ChromeClientQt::chromeDestroyed()
293 {
294     delete this;
295 }
296
297 bool ChromeClientQt::canRunBeforeUnloadConfirmPanel()
298 {
299     return true;
300 }
301
302 bool ChromeClientQt::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
303 {
304     return runJavaScriptConfirm(frame, message);
305 }
306
307 void ChromeClientQt::closeWindowSoon()
308 {
309     m_webPage->d->page->setGroupName(String());
310     m_webPage->mainFrame()->d->frame->loader()->stopAllLoaders();
311     emit m_webPage->windowCloseRequested();
312 }
313
314 void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg)
315 {
316     QString x = msg;
317     QWebFrame* webFrame = qobject_cast<QWebFrame*>(f->loader()->networkingContext()->originatingObject());
318     m_webPage->javaScriptAlert(webFrame, x);
319 }
320
321 bool ChromeClientQt::runJavaScriptConfirm(Frame* f, const String& msg)
322 {
323     QString x = msg;
324     QWebFrame* webFrame = qobject_cast<QWebFrame*>(f->loader()->networkingContext()->originatingObject());
325     return m_webPage->javaScriptConfirm(webFrame, x);
326 }
327
328 bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result)
329 {
330     QString x = result;
331     QWebFrame* webFrame = qobject_cast<QWebFrame*>(f->loader()->networkingContext()->originatingObject());
332     bool rc = m_webPage->javaScriptPrompt(webFrame, (QString)message, (QString)defaultValue, &x);
333
334     // Fix up a quirk in the QInputDialog class. If no input happened the string should be empty
335     // but it is null. See https://bugs.webkit.org/show_bug.cgi?id=30914.
336     if (rc && x.isNull())
337         result = String("");
338     else
339         result = x;
340
341     return rc;
342 }
343
344 void ChromeClientQt::setStatusbarText(const String& msg)
345 {
346     QString x = msg;
347     emit m_webPage->statusBarMessage(x);
348 }
349
350 bool ChromeClientQt::shouldInterruptJavaScript()
351 {
352     bool shouldInterrupt = false;
353     QMetaObject::invokeMethod(m_webPage, "shouldInterruptJavaScript", Qt::DirectConnection, Q_RETURN_ARG(bool, shouldInterrupt));
354     return shouldInterrupt;
355 }
356
357 KeyboardUIMode ChromeClientQt::keyboardUIMode()
358 {
359     return m_webPage->settings()->testAttribute(QWebSettings::LinksIncludedInFocusChain)
360         ? KeyboardAccessTabsToLinks : KeyboardAccessDefault;
361 }
362
363 IntRect ChromeClientQt::windowResizerRect() const
364 {
365 #if defined(Q_WS_MAC)
366     if (!m_webPage)
367         return IntRect();
368
369     QWebPageClient* pageClient = platformPageClient();
370     if (!pageClient)
371         return IntRect();
372
373     QWidget* ownerWidget = pageClient->ownerWidget();
374     if (!ownerWidget)
375         return IntRect();
376
377     QWidget* topLevelWidget = ownerWidget->window();
378     QRect topLevelGeometry(topLevelWidget->geometry());
379
380     // There's no API in Qt to query for the size of the resizer, so we assume
381     // it has the same width and height as the scrollbar thickness.
382     int scollbarThickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
383
384     // There's no API in Qt to query for the position of the resizer. Sometimes
385     // it's drawn by the system, and sometimes it's a QSizeGrip. For RTL locales
386     // it might even be on the lower left side of the window, but in WebKit we
387     // always draw scrollbars on the right hand side, so we assume this to be the
388     // location when computing the resize rect to reserve for WebKit.
389     QPoint resizeCornerTopLeft = ownerWidget->mapFrom(topLevelWidget,
390             QPoint(topLevelGeometry.width(), topLevelGeometry.height())
391             - QPoint(scollbarThickness, scollbarThickness));
392
393     QRect resizeCornerRect = QRect(resizeCornerTopLeft, QSize(scollbarThickness, scollbarThickness));
394     return resizeCornerRect.intersected(pageClient->geometryRelativeToOwnerWidget());
395 #else
396     return IntRect();
397 #endif
398 }
399
400 void ChromeClientQt::invalidateWindow(const IntRect&, bool)
401 {
402     notImplemented();
403 }
404
405 void ChromeClientQt::invalidateContentsAndWindow(const IntRect& windowRect, bool immediate)
406 {
407     // No double buffer, so only update the QWidget if content changed.
408     if (platformPageClient()) {
409         QRect rect(windowRect);
410         rect = rect.intersected(QRect(QPoint(0, 0), m_webPage->viewportSize()));
411         if (!rect.isEmpty())
412             platformPageClient()->update(rect);
413     }
414     emit m_webPage->repaintRequested(windowRect);
415
416     // FIXME: There is no "immediate" support for window painting.  This should be done always whenever the flag
417     // is set.
418 }
419
420 void ChromeClientQt::invalidateContentsForSlowScroll(const IntRect& windowRect, bool immediate)
421 {
422     invalidateContentsAndWindow(windowRect, immediate);
423 }
424
425 void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect, const IntRect&)
426 {
427     if (platformPageClient())
428         platformPageClient()->scroll(delta.width(), delta.height(), scrollViewRect);
429     emit m_webPage->scrollRequested(delta.width(), delta.height(), scrollViewRect);
430 }
431
432 #if ENABLE(TILED_BACKING_STORE)
433 void ChromeClientQt::delegatedScrollRequested(const IntSize& delta)
434 {
435     emit m_webPage->scrollRequested(delta.width(), delta.height(), QRect(QPoint(0, 0), m_webPage->viewportSize()));
436 }
437 #endif
438
439 IntRect ChromeClientQt::windowToScreen(const IntRect& rect) const
440 {
441     QWebPageClient* pageClient = platformPageClient();
442     if (!pageClient)
443         return rect;
444
445     QWidget* ownerWidget = pageClient->ownerWidget();
446     if (!ownerWidget)
447        return rect;
448
449     QRect screenRect(rect);
450     screenRect.translate(ownerWidget->mapToGlobal(QPoint(0, 0)));
451
452     return screenRect;
453 }
454
455 IntPoint ChromeClientQt::screenToWindow(const IntPoint& point) const
456 {
457     QWebPageClient* pageClient = platformPageClient();
458     if (!pageClient)
459         return point;
460
461     QWidget* ownerWidget = pageClient->ownerWidget();
462     if (!ownerWidget)
463         return point;
464
465     return ownerWidget->mapFromGlobal(point);
466 }
467
468 PlatformPageClient ChromeClientQt::platformPageClient() const
469 {
470     return m_webPage->d->client.get();
471 }
472
473 void ChromeClientQt::contentsSizeChanged(Frame* frame, const IntSize& size) const
474 {
475     if (frame->loader()->networkingContext())
476         QWebFramePrivate::kit(frame)->contentsSizeChanged(size);
477 }
478
479 void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
480 {
481     TextDirection dir;
482     if (result.absoluteLinkURL() != lastHoverURL
483         || result.title(dir) != lastHoverTitle
484         || result.textContent() != lastHoverContent) {
485         lastHoverURL = result.absoluteLinkURL();
486         lastHoverTitle = result.title(dir);
487         lastHoverContent = result.textContent();
488         emit m_webPage->linkHovered(lastHoverURL.prettyURL(),
489                 lastHoverTitle, lastHoverContent);
490     }
491 }
492
493 void ChromeClientQt::setToolTip(const String &tip, TextDirection)
494 {
495 #ifndef QT_NO_TOOLTIP
496     QWidget* view = m_webPage->view();
497     if (!view)
498         return;
499
500     if (tip.isEmpty()) {
501         view->setToolTip(QString());
502         QToolTip::hideText();
503     } else {
504         QString dtip = QLatin1String("<p>") + Qt::escape(tip) + QLatin1String("</p>");
505         view->setToolTip(dtip);
506     }
507 #else
508     Q_UNUSED(tip);
509 #endif
510 }
511
512 void ChromeClientQt::print(Frame* frame)
513 {
514     emit m_webPage->printRequested(QWebFramePrivate::kit(frame));
515 }
516
517 #if ENABLE(DATABASE)
518 void ChromeClientQt::exceededDatabaseQuota(Frame* frame, const String& databaseName)
519 {
520     quint64 quota = QWebSettings::offlineStorageDefaultQuota();
521
522     if (!DatabaseTracker::tracker().hasEntryForOrigin(frame->document()->securityOrigin()))
523         DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), quota);
524
525     emit m_webPage->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName);
526 }
527 #endif
528
529 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
530 void ChromeClientQt::reachedMaxAppCacheSize(int64_t)
531 {
532     // FIXME: Free some space.
533     notImplemented();
534 }
535
536 void ChromeClientQt::reachedApplicationCacheOriginQuota(SecurityOrigin* origin)
537 {
538     int64_t quota;
539     quint64 defaultOriginQuota = WebCore::cacheStorage().defaultOriginQuota();
540
541     QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(origin);
542     QWebSecurityOrigin* securityOrigin = new QWebSecurityOrigin(priv);
543
544     if (!WebCore::cacheStorage().quotaForOrigin(origin, quota))
545        WebCore::cacheStorage().storeUpdatedQuotaForOrigin(origin, defaultOriginQuota);
546
547     emit m_webPage->applicationCacheQuotaExceeded(securityOrigin, defaultOriginQuota);
548 }
549 #endif
550
551 #if ENABLE(NOTIFICATIONS)
552 NotificationPresenter* ChromeClientQt::notificationPresenter() const
553 {
554     return NotificationPresenterClientQt::notificationPresenter();
555 }
556 #endif
557
558 void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
559 {
560     RefPtr<FileChooser> fileChooser = prpFileChooser;
561     bool supportMulti = m_webPage->supportsExtension(QWebPage::ChooseMultipleFilesExtension);
562
563     if (fileChooser->allowsMultipleFiles() && supportMulti) {
564         QWebPage::ChooseMultipleFilesExtensionOption option;
565         option.parentFrame = QWebFramePrivate::kit(frame);
566
567         if (!fileChooser->filenames().isEmpty())
568             for (unsigned i = 0; i < fileChooser->filenames().size(); ++i)
569                 option.suggestedFileNames += fileChooser->filenames()[i];
570
571         QWebPage::ChooseMultipleFilesExtensionReturn output;
572         m_webPage->extension(QWebPage::ChooseMultipleFilesExtension, &option, &output);
573
574         if (!output.fileNames.isEmpty()) {
575             Vector<String> names;
576             for (int i = 0; i < output.fileNames.count(); ++i)
577                 names.append(output.fileNames.at(i));
578             fileChooser->chooseFiles(names);
579         }
580     } else {
581         QString suggestedFile;
582         if (!fileChooser->filenames().isEmpty())
583             suggestedFile = fileChooser->filenames()[0];
584         QString file = m_webPage->chooseFile(QWebFramePrivate::kit(frame), suggestedFile);
585         if (!file.isEmpty())
586             fileChooser->chooseFile(file);
587     }
588 }
589
590 void ChromeClientQt::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser)
591 {
592     chooser->iconLoaded(Icon::createIconForFiles(filenames));
593 }
594
595 void ChromeClientQt::setCursor(const Cursor& cursor)
596 {
597 #ifndef QT_NO_CURSOR
598     QWebPageClient* pageClient = platformPageClient();
599     if (!pageClient)
600         return;
601     pageClient->setCursor(*cursor.platformCursor());
602 #else
603     UNUSED_PARAM(cursor);
604 #endif
605 }
606
607
608 #if USE(ACCELERATED_COMPOSITING)
609 void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
610 {
611     if (platformPageClient())
612         platformPageClient()->setRootGraphicsLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0);
613 }
614
615 void ChromeClientQt::setNeedsOneShotDrawingSynchronization()
616 {
617     // we want the layers to synchronize next time we update the screen anyway
618     if (platformPageClient())
619         platformPageClient()->markForSync(false);
620 }
621
622 void ChromeClientQt::scheduleCompositingLayerSync()
623 {
624     // we want the layers to synchronize ASAP
625     if (platformPageClient())
626         platformPageClient()->markForSync(true);
627 }
628
629 ChromeClient::CompositingTriggerFlags ChromeClientQt::allowedCompositingTriggers() const
630 {
631     if (platformPageClient() && platformPageClient()->allowsAcceleratedCompositing())
632         return AllTriggers;
633
634     return 0;
635 }
636
637 #endif
638
639 #if ENABLE(TILED_BACKING_STORE)
640 IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
641 {
642     if (!platformPageClient() || !m_webPage)
643         return IntRect();
644
645     if (!platformPageClient()->viewResizesToContentsEnabled())
646         return QRect(m_webPage->mainFrame()->scrollPosition(), m_webPage->mainFrame()->geometry().size());
647
648     return enclosingIntRect(FloatRect(platformPageClient()->graphicsItemVisibleRect()));
649 }
650 #endif
651
652 #if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
653 FullScreenVideoQt* ChromeClientQt::fullScreenVideo()
654 {
655     if (!m_fullScreenVideo)
656         m_fullScreenVideo = new FullScreenVideoQt(this);
657     return m_fullScreenVideo;
658 }
659
660 bool ChromeClientQt::supportsFullscreenForNode(const Node* node)
661 {
662     ASSERT(node);
663     return node->hasTagName(HTMLNames::videoTag) && fullScreenVideo()->isValid();
664 }
665
666 bool ChromeClientQt::requiresFullscreenForVideoPlayback()
667 {
668     return fullScreenVideo()->requiresFullScreenForVideoPlayback();
669 }
670
671 void ChromeClientQt::enterFullscreenForNode(Node* node)
672 {
673     ASSERT(node && node->hasTagName(HTMLNames::videoTag));
674
675     HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
676     PlatformMedia platformMedia = videoElement->platformMedia();
677
678     ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
679     if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
680         return;
681
682     fullScreenVideo()->enterFullScreenForNode(node);
683 }
684
685 void ChromeClientQt::exitFullscreenForNode(Node* node)
686 {
687     ASSERT(node && node->hasTagName(HTMLNames::videoTag));
688
689     HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
690     PlatformMedia platformMedia = videoElement->platformMedia();
691
692     ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
693     if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
694         return;
695
696     fullScreenVideo()->exitFullScreenForNode(node);
697
698 #endif
699
700 QWebSelectMethod* ChromeClientQt::createSelectPopup() const
701 {
702     QWebSelectMethod* result = m_platformPlugin.createSelectInputMethod();
703     if (result)
704         return result;
705
706 #if defined(Q_WS_MAEMO_5)
707     return new QtMaemoWebPopup;
708 #elif !defined(QT_NO_COMBOBOX)
709     return new QtFallbackWebPopup(this);
710 #else
711     return 0;
712 #endif
713 }
714
715 void ChromeClientQt::dispatchViewportDataDidChange(const ViewportArguments&) const
716 {
717     emit m_webPage->viewportChangeRequested();
718 }
719
720 bool ChromeClientQt::selectItemWritingDirectionIsNatural()
721 {
722     return false;
723 }
724
725 bool ChromeClientQt::selectItemAlignmentFollowsMenuWritingDirection()
726 {
727     return false;
728 }
729
730 PassRefPtr<PopupMenu> ChromeClientQt::createPopupMenu(PopupMenuClient* client) const
731 {
732     return adoptRef(new PopupMenuQt(client, this));
733 }
734
735 PassRefPtr<SearchPopupMenu> ChromeClientQt::createSearchPopupMenu(PopupMenuClient* client) const
736 {
737     return adoptRef(new SearchPopupMenuQt(createPopupMenu(client)));
738 }
739
740 void ChromeClientQt::populateVisitedLinks()
741 {
742     // We don't need to do anything here because history is tied to QWebPage rather than stored
743     // in a separate database
744     if (dumpVisitedLinksCallbacks) {
745         printf("Asked to populate visited links for WebView \"%s\"\n",
746                 qPrintable(m_webPage->mainFrame()->url().toString()));
747     }
748 }
749
750 } // namespace WebCore