2011-03-10 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
[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 IntPoint& point)
434 {
435     QPoint currentPosition(m_webPage->mainFrame()->scrollPosition());
436     emit m_webPage->scrollRequested(point.x() - currentPosition.x(), point.y() - currentPosition.y(), QRect(QPoint(0, 0), m_webPage->viewportSize()));
437 }
438 #endif
439
440 IntRect ChromeClientQt::windowToScreen(const IntRect& rect) const
441 {
442     QWebPageClient* pageClient = platformPageClient();
443     if (!pageClient)
444         return rect;
445
446     QWidget* ownerWidget = pageClient->ownerWidget();
447     if (!ownerWidget)
448        return rect;
449
450     QRect screenRect(rect);
451     screenRect.translate(ownerWidget->mapToGlobal(QPoint(0, 0)));
452
453     return screenRect;
454 }
455
456 IntPoint ChromeClientQt::screenToWindow(const IntPoint& point) const
457 {
458     QWebPageClient* pageClient = platformPageClient();
459     if (!pageClient)
460         return point;
461
462     QWidget* ownerWidget = pageClient->ownerWidget();
463     if (!ownerWidget)
464         return point;
465
466     return ownerWidget->mapFromGlobal(point);
467 }
468
469 PlatformPageClient ChromeClientQt::platformPageClient() const
470 {
471     return m_webPage->d->client.get();
472 }
473
474 void ChromeClientQt::contentsSizeChanged(Frame* frame, const IntSize& size) const
475 {
476     if (frame->loader()->networkingContext())
477         QWebFramePrivate::kit(frame)->contentsSizeChanged(size);
478 }
479
480 void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
481 {
482     TextDirection dir;
483     if (result.absoluteLinkURL() != lastHoverURL
484         || result.title(dir) != lastHoverTitle
485         || result.textContent() != lastHoverContent) {
486         lastHoverURL = result.absoluteLinkURL();
487         lastHoverTitle = result.title(dir);
488         lastHoverContent = result.textContent();
489         emit m_webPage->linkHovered(lastHoverURL.prettyURL(),
490                 lastHoverTitle, lastHoverContent);
491     }
492 }
493
494 void ChromeClientQt::setToolTip(const String &tip, TextDirection)
495 {
496 #ifndef QT_NO_TOOLTIP
497     QWidget* view = m_webPage->view();
498     if (!view)
499         return;
500
501     if (tip.isEmpty()) {
502         view->setToolTip(QString());
503         QToolTip::hideText();
504     } else {
505         QString dtip = QLatin1String("<p>") + Qt::escape(tip) + QLatin1String("</p>");
506         view->setToolTip(dtip);
507     }
508 #else
509     Q_UNUSED(tip);
510 #endif
511 }
512
513 void ChromeClientQt::print(Frame* frame)
514 {
515     emit m_webPage->printRequested(QWebFramePrivate::kit(frame));
516 }
517
518 #if ENABLE(DATABASE)
519 void ChromeClientQt::exceededDatabaseQuota(Frame* frame, const String& databaseName)
520 {
521     quint64 quota = QWebSettings::offlineStorageDefaultQuota();
522
523     if (!DatabaseTracker::tracker().hasEntryForOrigin(frame->document()->securityOrigin()))
524         DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), quota);
525
526     emit m_webPage->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName);
527 }
528 #endif
529
530 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
531 void ChromeClientQt::reachedMaxAppCacheSize(int64_t)
532 {
533     // FIXME: Free some space.
534     notImplemented();
535 }
536
537 void ChromeClientQt::reachedApplicationCacheOriginQuota(SecurityOrigin* origin)
538 {
539     int64_t quota;
540     quint64 defaultOriginQuota = WebCore::cacheStorage().defaultOriginQuota();
541
542     QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(origin);
543     QWebSecurityOrigin* securityOrigin = new QWebSecurityOrigin(priv);
544
545     if (!WebCore::cacheStorage().quotaForOrigin(origin, quota))
546        WebCore::cacheStorage().storeUpdatedQuotaForOrigin(origin, defaultOriginQuota);
547
548     emit m_webPage->applicationCacheQuotaExceeded(securityOrigin, defaultOriginQuota);
549 }
550 #endif
551
552 #if ENABLE(NOTIFICATIONS)
553 NotificationPresenter* ChromeClientQt::notificationPresenter() const
554 {
555     return NotificationPresenterClientQt::notificationPresenter();
556 }
557 #endif
558
559 void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
560 {
561     RefPtr<FileChooser> fileChooser = prpFileChooser;
562     bool supportMulti = m_webPage->supportsExtension(QWebPage::ChooseMultipleFilesExtension);
563
564     if (fileChooser->allowsMultipleFiles() && supportMulti) {
565         QWebPage::ChooseMultipleFilesExtensionOption option;
566         option.parentFrame = QWebFramePrivate::kit(frame);
567
568         if (!fileChooser->filenames().isEmpty())
569             for (unsigned i = 0; i < fileChooser->filenames().size(); ++i)
570                 option.suggestedFileNames += fileChooser->filenames()[i];
571
572         QWebPage::ChooseMultipleFilesExtensionReturn output;
573         m_webPage->extension(QWebPage::ChooseMultipleFilesExtension, &option, &output);
574
575         if (!output.fileNames.isEmpty()) {
576             Vector<String> names;
577             for (int i = 0; i < output.fileNames.count(); ++i)
578                 names.append(output.fileNames.at(i));
579             fileChooser->chooseFiles(names);
580         }
581     } else {
582         QString suggestedFile;
583         if (!fileChooser->filenames().isEmpty())
584             suggestedFile = fileChooser->filenames()[0];
585         QString file = m_webPage->chooseFile(QWebFramePrivate::kit(frame), suggestedFile);
586         if (!file.isEmpty())
587             fileChooser->chooseFile(file);
588     }
589 }
590
591 void ChromeClientQt::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser)
592 {
593     chooser->iconLoaded(Icon::createIconForFiles(filenames));
594 }
595
596 void ChromeClientQt::setCursor(const Cursor& cursor)
597 {
598 #ifndef QT_NO_CURSOR
599     QWebPageClient* pageClient = platformPageClient();
600     if (!pageClient)
601         return;
602     pageClient->setCursor(*cursor.platformCursor());
603 #else
604     UNUSED_PARAM(cursor);
605 #endif
606 }
607
608
609 #if USE(ACCELERATED_COMPOSITING)
610 void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
611 {
612     if (platformPageClient())
613         platformPageClient()->setRootGraphicsLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0);
614 }
615
616 void ChromeClientQt::setNeedsOneShotDrawingSynchronization()
617 {
618     // we want the layers to synchronize next time we update the screen anyway
619     if (platformPageClient())
620         platformPageClient()->markForSync(false);
621 }
622
623 void ChromeClientQt::scheduleCompositingLayerSync()
624 {
625     // we want the layers to synchronize ASAP
626     if (platformPageClient())
627         platformPageClient()->markForSync(true);
628 }
629
630 ChromeClient::CompositingTriggerFlags ChromeClientQt::allowedCompositingTriggers() const
631 {
632     if (platformPageClient() && platformPageClient()->allowsAcceleratedCompositing())
633         return AllTriggers;
634
635     return 0;
636 }
637
638 #endif
639
640 #if ENABLE(TILED_BACKING_STORE)
641 IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
642 {
643     if (!platformPageClient() || !m_webPage)
644         return IntRect();
645
646     if (!platformPageClient()->viewResizesToContentsEnabled())
647         return QRect(m_webPage->mainFrame()->scrollPosition(), m_webPage->mainFrame()->geometry().size());
648
649     return enclosingIntRect(FloatRect(platformPageClient()->graphicsItemVisibleRect()));
650 }
651 #endif
652
653 #if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
654 FullScreenVideoQt* ChromeClientQt::fullScreenVideo()
655 {
656     if (!m_fullScreenVideo)
657         m_fullScreenVideo = new FullScreenVideoQt(this);
658     return m_fullScreenVideo;
659 }
660
661 bool ChromeClientQt::supportsFullscreenForNode(const Node* node)
662 {
663     ASSERT(node);
664     return node->hasTagName(HTMLNames::videoTag) && fullScreenVideo()->isValid();
665 }
666
667 bool ChromeClientQt::requiresFullscreenForVideoPlayback()
668 {
669     return fullScreenVideo()->requiresFullScreenForVideoPlayback();
670 }
671
672 void ChromeClientQt::enterFullscreenForNode(Node* node)
673 {
674     ASSERT(node && node->hasTagName(HTMLNames::videoTag));
675
676     HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
677     PlatformMedia platformMedia = videoElement->platformMedia();
678
679     ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
680     if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
681         return;
682
683     fullScreenVideo()->enterFullScreenForNode(node);
684 }
685
686 void ChromeClientQt::exitFullscreenForNode(Node* node)
687 {
688     ASSERT(node && node->hasTagName(HTMLNames::videoTag));
689
690     HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
691     PlatformMedia platformMedia = videoElement->platformMedia();
692
693     ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
694     if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
695         return;
696
697     fullScreenVideo()->exitFullScreenForNode(node);
698
699 #endif
700
701 QWebSelectMethod* ChromeClientQt::createSelectPopup() const
702 {
703     QWebSelectMethod* result = m_platformPlugin.createSelectInputMethod();
704     if (result)
705         return result;
706
707 #if defined(Q_WS_MAEMO_5)
708     return new QtMaemoWebPopup;
709 #elif !defined(QT_NO_COMBOBOX)
710     return new QtFallbackWebPopup(this);
711 #else
712     return 0;
713 #endif
714 }
715
716 void ChromeClientQt::dispatchViewportDataDidChange(const ViewportArguments&) const
717 {
718     emit m_webPage->viewportChangeRequested();
719 }
720
721 bool ChromeClientQt::selectItemWritingDirectionIsNatural()
722 {
723     return false;
724 }
725
726 bool ChromeClientQt::selectItemAlignmentFollowsMenuWritingDirection()
727 {
728     return false;
729 }
730
731 PassRefPtr<PopupMenu> ChromeClientQt::createPopupMenu(PopupMenuClient* client) const
732 {
733     return adoptRef(new PopupMenuQt(client, this));
734 }
735
736 PassRefPtr<SearchPopupMenu> ChromeClientQt::createSearchPopupMenu(PopupMenuClient* client) const
737 {
738     return adoptRef(new SearchPopupMenuQt(createPopupMenu(client)));
739 }
740
741 void ChromeClientQt::populateVisitedLinks()
742 {
743     // We don't need to do anything here because history is tied to QWebPage rather than stored
744     // in a separate database
745     if (dumpVisitedLinksCallbacks) {
746         printf("Asked to populate visited links for WebView \"%s\"\n",
747                 qPrintable(m_webPage->mainFrame()->url().toString()));
748     }
749 }
750
751 } // namespace WebCore