1/*
2 * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008 Collabora Ltd. All rights reserved.
5 * Copyright (C) 2010 Apple Inc. All rights reserved.
6 * Copyright (C) 2010 INdT - Instituto Nokia de Tecnologia
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 INC. AND ITS CONTRIBUTORS ``AS IS''
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include "config.h"
31#include "WebPlatformStrategies.h"
32
33#include "Chrome.h"
34#include "ChromeClientQt.h"
35#include <IntSize.h>
36#include "NotImplemented.h"
37#include <Page.h>
38#include <PageGroup.h>
39#include <PluginDatabase.h>
40#include <QCoreApplication>
41#include <QLocale>
42#include <qwebpage.h>
43#include <qwebpluginfactory.h>
44#include <wtf/MathExtras.h>
45
46using namespace WebCore;
47
48void WebPlatformStrategies::initialize()
49{
50    DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ());
51    Q_UNUSED(platformStrategies);
52}
53
54WebPlatformStrategies::WebPlatformStrategies()
55{
56    setPlatformStrategies(this);
57}
58
59
60CookiesStrategy* WebPlatformStrategies::createCookiesStrategy()
61{
62    return this;
63}
64
65PluginStrategy* WebPlatformStrategies::createPluginStrategy()
66{
67    return this;
68}
69
70LocalizationStrategy* WebPlatformStrategies::createLocalizationStrategy()
71{
72    return this;
73}
74
75VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy()
76{
77    return this;
78}
79
80void WebPlatformStrategies::notifyCookiesChanged()
81{
82}
83
84void WebPlatformStrategies::refreshPlugins()
85{
86    PluginDatabase::installedPlugins()->refresh();
87}
88
89void WebPlatformStrategies::getPluginInfo(const WebCore::Page* page, Vector<WebCore::PluginInfo>& outPlugins)
90{
91    QWebPage* qPage = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage;
92    QWebPluginFactory* factory;
93    if (qPage && (factory = qPage->pluginFactory())) {
94
95        QList<QWebPluginFactory::Plugin> qplugins = factory->plugins();
96        for (int i = 0; i < qplugins.count(); ++i) {
97            const QWebPluginFactory::Plugin& qplugin = qplugins.at(i);
98            PluginInfo info;
99            info.name = qplugin.name;
100            info.desc = qplugin.description;
101
102            for (int j = 0; j < qplugin.mimeTypes.count(); ++j) {
103                const QWebPluginFactory::MimeType& mimeType = qplugin.mimeTypes.at(j);
104
105                MimeClassInfo mimeInfo;
106                mimeInfo.type = mimeType.name;
107                mimeInfo.desc = mimeType.description;
108                for (int k = 0; k < mimeType.fileExtensions.count(); ++k)
109                  mimeInfo.extensions.append(mimeType.fileExtensions.at(k));
110
111                info.mimes.append(mimeInfo);
112            }
113            outPlugins.append(info);
114        }
115    }
116
117    PluginDatabase* db = PluginDatabase::installedPlugins();
118    const Vector<PluginPackage*> &plugins = db->plugins();
119
120    outPlugins.resize(plugins.size());
121
122    for (unsigned int i = 0; i < plugins.size(); ++i) {
123        PluginInfo info;
124        PluginPackage* package = plugins[i];
125
126        info.name = package->name();
127        info.file = package->fileName();
128        info.desc = package->description();
129
130        const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions();
131        MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
132        for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
133            MimeClassInfo mime;
134
135            mime.type = it->first;
136            mime.desc = it->second;
137            mime.extensions = package->mimeToExtensions().get(mime.type);
138
139            info.mimes.append(mime);
140        }
141
142        outPlugins.append(info);
143    }
144
145}
146
147
148// LocalizationStrategy
149
150String WebPlatformStrategies::inputElementAltText()
151{
152    return QCoreApplication::translate("QWebPage", "Submit", "Submit (input element) alt text for <input> elements with no alt, title, or value");
153}
154
155String WebPlatformStrategies::resetButtonDefaultLabel()
156{
157    return QCoreApplication::translate("QWebPage", "Reset", "default label for Reset buttons in forms on web pages");
158}
159
160String WebPlatformStrategies::searchableIndexIntroduction()
161{
162    return QCoreApplication::translate("QWebPage", "This is a searchable index. Enter search keywords: ", "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'");
163}
164
165String WebPlatformStrategies::submitButtonDefaultLabel()
166{
167    return QCoreApplication::translate("QWebPage", "Submit", "default label for Submit buttons in forms on web pages");
168}
169
170String WebPlatformStrategies::fileButtonChooseFileLabel()
171{
172    return QCoreApplication::translate("QWebPage", "Choose File", "title for file button used in HTML forms");
173}
174
175String WebPlatformStrategies::fileButtonNoFileSelectedLabel()
176{
177    return QCoreApplication::translate("QWebPage", "No file selected", "text to display in file button used in HTML forms when no file is selected");
178}
179
180String WebPlatformStrategies::defaultDetailsSummaryText()
181{
182    return QCoreApplication::translate("QWebPage", "Details", "text to display in <details> tag when it has no <summary> child");
183}
184
185String WebPlatformStrategies::contextMenuItemTagOpenLinkInNewWindow()
186{
187    return QCoreApplication::translate("QWebPage", "Open in New Window", "Open in New Window context menu item");
188}
189
190String WebPlatformStrategies::contextMenuItemTagDownloadLinkToDisk()
191{
192    return QCoreApplication::translate("QWebPage", "Save Link...", "Download Linked File context menu item");
193}
194
195String WebPlatformStrategies::contextMenuItemTagCopyLinkToClipboard()
196{
197    return QCoreApplication::translate("QWebPage", "Copy Link", "Copy Link context menu item");
198}
199
200String WebPlatformStrategies::contextMenuItemTagOpenImageInNewWindow()
201{
202    return QCoreApplication::translate("QWebPage", "Open Image", "Open Image in New Window context menu item");
203}
204
205String WebPlatformStrategies::contextMenuItemTagDownloadImageToDisk()
206{
207    return QCoreApplication::translate("QWebPage", "Save Image", "Download Image context menu item");
208}
209
210String WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard()
211{
212    return QCoreApplication::translate("QWebPage", "Copy Image", "Copy Link context menu item");
213}
214
215String WebPlatformStrategies::contextMenuItemTagCopyImageUrlToClipboard()
216{
217    return QCoreApplication::translate("QWebPage", "Copy Image Address", "Copy Image Address menu item");
218}
219
220String WebPlatformStrategies::contextMenuItemTagOpenVideoInNewWindow()
221{
222    return QCoreApplication::translate("QWebPage", "Open Video", "Open Video in New Window");
223}
224
225String WebPlatformStrategies::contextMenuItemTagOpenAudioInNewWindow()
226{
227    return QCoreApplication::translate("QWebPage", "Open Audio", "Open Audio in New Window");
228}
229
230String WebPlatformStrategies::contextMenuItemTagCopyVideoLinkToClipboard()
231{
232    return QCoreApplication::translate("QWebPage", "Copy Video", "Copy Video Link Location");
233}
234
235String WebPlatformStrategies::contextMenuItemTagCopyAudioLinkToClipboard()
236{
237    return QCoreApplication::translate("QWebPage", "Copy Audio", "Copy Audio Link Location");
238}
239
240String WebPlatformStrategies::contextMenuItemTagToggleMediaControls()
241{
242    return QCoreApplication::translate("QWebPage", "Toggle Controls", "Toggle Media Controls");
243}
244
245String WebPlatformStrategies::contextMenuItemTagToggleMediaLoop()
246{
247    return QCoreApplication::translate("QWebPage", "Toggle Loop", "Toggle Media Loop Playback");
248}
249
250String WebPlatformStrategies::contextMenuItemTagEnterVideoFullscreen()
251{
252    return QCoreApplication::translate("QWebPage", "Enter Fullscreen", "Switch Video to Fullscreen");
253}
254
255String WebPlatformStrategies::contextMenuItemTagMediaPlay()
256{
257    return QCoreApplication::translate("QWebPage", "Play", "Play");
258}
259
260String WebPlatformStrategies::contextMenuItemTagMediaPause()
261{
262    return QCoreApplication::translate("QWebPage", "Pause", "Pause");
263}
264
265String WebPlatformStrategies::contextMenuItemTagMediaMute()
266{
267    return QCoreApplication::translate("QWebPage", "Mute", "Mute");
268}
269
270String WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow()
271{
272    return QCoreApplication::translate("QWebPage", "Open Frame", "Open Frame in New Window context menu item");
273}
274
275String WebPlatformStrategies::contextMenuItemTagCopy()
276{
277    return QCoreApplication::translate("QWebPage", "Copy", "Copy context menu item");
278}
279
280String WebPlatformStrategies::contextMenuItemTagGoBack()
281{
282    return QCoreApplication::translate("QWebPage", "Go Back", "Back context menu item");
283}
284
285String WebPlatformStrategies::contextMenuItemTagGoForward()
286{
287    return QCoreApplication::translate("QWebPage", "Go Forward", "Forward context menu item");
288}
289
290String WebPlatformStrategies::contextMenuItemTagStop()
291{
292    return QCoreApplication::translate("QWebPage", "Stop", "Stop context menu item");
293}
294
295String WebPlatformStrategies::contextMenuItemTagReload()
296{
297    return QCoreApplication::translate("QWebPage", "Reload", "Reload context menu item");
298}
299
300String WebPlatformStrategies::contextMenuItemTagCut()
301{
302    return QCoreApplication::translate("QWebPage", "Cut", "Cut context menu item");
303}
304
305String WebPlatformStrategies::contextMenuItemTagPaste()
306{
307    return QCoreApplication::translate("QWebPage", "Paste", "Paste context menu item");
308}
309
310String WebPlatformStrategies::contextMenuItemTagSelectAll()
311{
312    return QCoreApplication::translate("QWebPage", "Select All", "Select All context menu item");
313}
314
315String WebPlatformStrategies::contextMenuItemTagNoGuessesFound()
316{
317    return QCoreApplication::translate("QWebPage", "No Guesses Found", "No Guesses Found context menu item");
318}
319
320String WebPlatformStrategies::contextMenuItemTagIgnoreSpelling()
321{
322    return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Spelling context menu item");
323}
324
325String WebPlatformStrategies::contextMenuItemTagLearnSpelling()
326{
327    return QCoreApplication::translate("QWebPage", "Add To Dictionary", "Learn Spelling context menu item");
328}
329
330String WebPlatformStrategies::contextMenuItemTagSearchWeb()
331{
332    return QCoreApplication::translate("QWebPage", "Search The Web", "Search The Web context menu item");
333}
334
335String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary(const String&)
336{
337    return QCoreApplication::translate("QWebPage", "Look Up In Dictionary", "Look Up in Dictionary context menu item");
338}
339
340String WebPlatformStrategies::contextMenuItemTagOpenLink()
341{
342    return QCoreApplication::translate("QWebPage", "Open Link", "Open Link context menu item");
343}
344
345String WebPlatformStrategies::contextMenuItemTagIgnoreGrammar()
346{
347    return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Grammar context menu item");
348}
349
350String WebPlatformStrategies::contextMenuItemTagSpellingMenu()
351{
352    return QCoreApplication::translate("QWebPage", "Spelling", "Spelling and Grammar context sub-menu item");
353}
354
355String WebPlatformStrategies::contextMenuItemTagShowSpellingPanel(bool show)
356{
357    return show ? QCoreApplication::translate("QWebPage", "Show Spelling and Grammar", "menu item title") :
358                  QCoreApplication::translate("QWebPage", "Hide Spelling and Grammar", "menu item title");
359}
360
361String WebPlatformStrategies::contextMenuItemTagCheckSpelling()
362{
363    return QCoreApplication::translate("QWebPage", "Check Spelling", "Check spelling context menu item");
364}
365
366String WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping()
367{
368    return QCoreApplication::translate("QWebPage", "Check Spelling While Typing", "Check spelling while typing context menu item");
369}
370
371String WebPlatformStrategies::contextMenuItemTagCheckGrammarWithSpelling()
372{
373    return QCoreApplication::translate("QWebPage", "Check Grammar With Spelling", "Check grammar with spelling context menu item");
374}
375
376String WebPlatformStrategies::contextMenuItemTagFontMenu()
377{
378    return QCoreApplication::translate("QWebPage", "Fonts", "Font context sub-menu item");
379}
380
381String WebPlatformStrategies::contextMenuItemTagBold()
382{
383    return QCoreApplication::translate("QWebPage", "Bold", "Bold context menu item");
384}
385
386String WebPlatformStrategies::contextMenuItemTagItalic()
387{
388    return QCoreApplication::translate("QWebPage", "Italic", "Italic context menu item");
389}
390
391String WebPlatformStrategies::contextMenuItemTagUnderline()
392{
393    return QCoreApplication::translate("QWebPage", "Underline", "Underline context menu item");
394}
395
396String WebPlatformStrategies::contextMenuItemTagOutline()
397{
398    return QCoreApplication::translate("QWebPage", "Outline", "Outline context menu item");
399}
400
401String WebPlatformStrategies::contextMenuItemTagWritingDirectionMenu()
402{
403    return QCoreApplication::translate("QWebPage", "Direction", "Writing direction context sub-menu item");
404}
405
406String WebPlatformStrategies::contextMenuItemTagTextDirectionMenu()
407{
408    return QCoreApplication::translate("QWebPage", "Text Direction", "Text direction context sub-menu item");
409}
410
411String WebPlatformStrategies::contextMenuItemTagDefaultDirection()
412{
413    return QCoreApplication::translate("QWebPage", "Default", "Default writing direction context menu item");
414}
415
416String WebPlatformStrategies::contextMenuItemTagLeftToRight()
417{
418    return QCoreApplication::translate("QWebPage", "Left to Right", "Left to Right context menu item");
419}
420
421String WebPlatformStrategies::contextMenuItemTagRightToLeft()
422{
423    return QCoreApplication::translate("QWebPage", "Right to Left", "Right to Left context menu item");
424}
425
426String WebPlatformStrategies::contextMenuItemTagInspectElement()
427{
428    return QCoreApplication::translate("QWebPage", "Inspect", "Inspect Element context menu item");
429}
430
431String WebPlatformStrategies::searchMenuNoRecentSearchesText()
432{
433    return QCoreApplication::translate("QWebPage", "No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed");
434}
435
436String WebPlatformStrategies::searchMenuRecentSearchesText()
437{
438    return QCoreApplication::translate("QWebPage", "Recent searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title");
439}
440
441String WebPlatformStrategies::searchMenuClearRecentSearchesText()
442{
443    return QCoreApplication::translate("QWebPage", "Clear recent searches", "menu item in Recent Searches menu that empties menu's contents");
444}
445
446String WebPlatformStrategies::AXWebAreaText()
447{
448    notImplemented();
449    return String();
450}
451
452String WebPlatformStrategies::AXLinkText()
453{
454    notImplemented();
455    return String();
456}
457
458String WebPlatformStrategies::AXListMarkerText()
459{
460    notImplemented();
461    return String();
462}
463
464String WebPlatformStrategies::AXImageMapText()
465{
466    notImplemented();
467    return String();
468}
469
470String WebPlatformStrategies::AXHeadingText()
471{
472    notImplemented();
473    return String();
474}
475
476String WebPlatformStrategies::AXDefinitionListTermText()
477{
478    notImplemented();
479    return String();
480}
481
482String WebPlatformStrategies::AXDefinitionListDefinitionText()
483{
484    notImplemented();
485    return String();
486}
487
488String WebPlatformStrategies::AXButtonActionVerb()
489{
490    notImplemented();
491    return String();
492}
493
494String WebPlatformStrategies::AXRadioButtonActionVerb()
495{
496    notImplemented();
497    return String();
498}
499
500String WebPlatformStrategies::AXTextFieldActionVerb()
501{
502    notImplemented();
503    return String();
504}
505
506String WebPlatformStrategies::AXCheckedCheckBoxActionVerb()
507{
508    notImplemented();
509    return String();
510}
511
512String WebPlatformStrategies::AXUncheckedCheckBoxActionVerb()
513{
514    notImplemented();
515    return String();
516}
517
518String WebPlatformStrategies::AXMenuListActionVerb()
519{
520    notImplemented();
521    return String();
522}
523
524String WebPlatformStrategies::AXMenuListPopupActionVerb()
525{
526    notImplemented();
527    return String();
528}
529
530String WebPlatformStrategies::AXLinkActionVerb()
531{
532    notImplemented();
533    return String();
534}
535
536String WebPlatformStrategies::missingPluginText()
537{
538    return QCoreApplication::translate("QWebPage", "Missing Plug-in", "Label text to be used when a plug-in is missing");
539}
540
541String WebPlatformStrategies::crashedPluginText()
542{
543    notImplemented();
544    return String();
545}
546
547String WebPlatformStrategies::multipleFileUploadText(unsigned)
548{
549    notImplemented();
550    return String();
551}
552
553String WebPlatformStrategies::unknownFileSizeText()
554{
555    return QCoreApplication::translate("QWebPage", "Unknown", "Unknown filesize FTP directory listing item");
556}
557
558String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size)
559{
560    return QCoreApplication::translate("QWebPage", "%1 (%2x%3 pixels)", "Title string for images").arg(filename).arg(size.width()).arg(size.height());
561}
562
563String WebPlatformStrategies::mediaElementLoadingStateText()
564{
565    return QCoreApplication::translate("QWebPage", "Loading...", "Media controller status message when the media is loading");
566}
567
568String WebPlatformStrategies::mediaElementLiveBroadcastStateText()
569{
570    return QCoreApplication::translate("QWebPage", "Live Broadcast", "Media controller status message when watching a live broadcast");
571}
572
573#if ENABLE(VIDEO)
574
575String WebPlatformStrategies::localizedMediaControlElementString(const String& name)
576{
577    if (name == "AudioElement")
578        return QCoreApplication::translate("QWebPage", "Audio Element", "Media controller element");
579    if (name == "VideoElement")
580        return QCoreApplication::translate("QWebPage", "Video Element", "Media controller element");
581    if (name == "MuteButton")
582        return QCoreApplication::translate("QWebPage", "Mute Button", "Media controller element");
583    if (name == "UnMuteButton")
584        return QCoreApplication::translate("QWebPage", "Unmute Button", "Media controller element");
585    if (name == "PlayButton")
586        return QCoreApplication::translate("QWebPage", "Play Button", "Media controller element");
587    if (name == "PauseButton")
588        return QCoreApplication::translate("QWebPage", "Pause Button", "Media controller element");
589    if (name == "Slider")
590        return QCoreApplication::translate("QWebPage", "Slider", "Media controller element");
591    if (name == "SliderThumb")
592        return QCoreApplication::translate("QWebPage", "Slider Thumb", "Media controller element");
593    if (name == "RewindButton")
594        return QCoreApplication::translate("QWebPage", "Rewind Button", "Media controller element");
595    if (name == "ReturnToRealtimeButton")
596        return QCoreApplication::translate("QWebPage", "Return to Real-time Button", "Media controller element");
597    if (name == "CurrentTimeDisplay")
598        return QCoreApplication::translate("QWebPage", "Elapsed Time", "Media controller element");
599    if (name == "TimeRemainingDisplay")
600        return QCoreApplication::translate("QWebPage", "Remaining Time", "Media controller element");
601    if (name == "StatusDisplay")
602        return QCoreApplication::translate("QWebPage", "Status Display", "Media controller element");
603    if (name == "FullscreenButton")
604        return QCoreApplication::translate("QWebPage", "Fullscreen Button", "Media controller element");
605    if (name == "SeekForwardButton")
606        return QCoreApplication::translate("QWebPage", "Seek Forward Button", "Media controller element");
607    if (name == "SeekBackButton")
608        return QCoreApplication::translate("QWebPage", "Seek Back Button", "Media controller element");
609
610    return String();
611}
612
613String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name)
614{
615    if (name == "AudioElement")
616        return QCoreApplication::translate("QWebPage", "Audio element playback controls and status display", "Media controller element");
617    if (name == "VideoElement")
618        return QCoreApplication::translate("QWebPage", "Video element playback controls and status display", "Media controller element");
619    if (name == "MuteButton")
620        return QCoreApplication::translate("QWebPage", "Mute audio tracks", "Media controller element");
621    if (name == "UnMuteButton")
622        return QCoreApplication::translate("QWebPage", "Unmute audio tracks", "Media controller element");
623    if (name == "PlayButton")
624        return QCoreApplication::translate("QWebPage", "Begin playback", "Media controller element");
625    if (name == "PauseButton")
626        return QCoreApplication::translate("QWebPage", "Pause playback", "Media controller element");
627    if (name == "Slider")
628        return QCoreApplication::translate("QWebPage", "Movie time scrubber", "Media controller element");
629    if (name == "SliderThumb")
630        return QCoreApplication::translate("QWebPage", "Movie time scrubber thumb", "Media controller element");
631    if (name == "RewindButton")
632        return QCoreApplication::translate("QWebPage", "Rewind movie", "Media controller element");
633    if (name == "ReturnToRealtimeButton")
634        return QCoreApplication::translate("QWebPage", "Return streaming movie to real-time", "Media controller element");
635    if (name == "CurrentTimeDisplay")
636        return QCoreApplication::translate("QWebPage", "Current movie time", "Media controller element");
637    if (name == "TimeRemainingDisplay")
638        return QCoreApplication::translate("QWebPage", "Remaining movie time", "Media controller element");
639    if (name == "StatusDisplay")
640        return QCoreApplication::translate("QWebPage", "Current movie status", "Media controller element");
641    if (name == "FullscreenButton")
642        return QCoreApplication::translate("QWebPage", "Play movie in full-screen mode", "Media controller element");
643    if (name == "SeekForwardButton")
644        return QCoreApplication::translate("QWebPage", "Seek quickly back", "Media controller element");
645    if (name == "SeekBackButton")
646        return QCoreApplication::translate("QWebPage", "Seek quickly forward", "Media controller element");
647
648    ASSERT_NOT_REACHED();
649    return String();
650}
651
652String WebPlatformStrategies::localizedMediaTimeDescription(float time)
653{
654    if (!isfinite(time))
655        return QCoreApplication::translate("QWebPage", "Indefinite time", "Media time description");
656
657    int seconds = (int)fabsf(time);
658    int days = seconds / (60 * 60 * 24);
659    int hours = seconds / (60 * 60);
660    int minutes = (seconds / 60) % 60;
661    seconds %= 60;
662
663    if (days)
664        return QCoreApplication::translate("QWebPage", "%1 days %2 hours %3 minutes %4 seconds", "Media time description").arg(days).arg(hours).arg(minutes).arg(seconds);
665
666    if (hours)
667        return QCoreApplication::translate("QWebPage", "%1 hours %2 minutes %3 seconds", "Media time description").arg(hours).arg(minutes).arg(seconds);
668
669    if (minutes)
670        return QCoreApplication::translate("QWebPage", "%1 minutes %2 seconds", "Media time description").arg(minutes).arg(seconds);
671
672    return QCoreApplication::translate("QWebPage", "%1 seconds", "Media time description").arg(seconds);
673}
674
675#else // ENABLE(VIDEO)
676// FIXME: #if ENABLE(VIDEO) should be in the base class
677
678String WebPlatformStrategies::localizedMediaControlElementString(const String& name)
679{
680    return String();
681}
682
683String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name)
684{
685    return String();
686}
687
688String WebPlatformStrategies::localizedMediaTimeDescription(float time)
689{
690    return String();
691}
692
693#endif // ENABLE(VIDEO)
694
695
696String WebPlatformStrategies::validationMessageValueMissingText()
697{
698    notImplemented();
699    return String();
700}
701
702String WebPlatformStrategies::validationMessageTypeMismatchText()
703{
704    notImplemented();
705    return String();
706}
707
708String WebPlatformStrategies::validationMessagePatternMismatchText()
709{
710    notImplemented();
711    return String();
712}
713
714String WebPlatformStrategies::validationMessageTooLongText()
715{
716    notImplemented();
717    return String();
718}
719
720String WebPlatformStrategies::validationMessageRangeUnderflowText()
721{
722    notImplemented();
723    return String();
724}
725
726String WebPlatformStrategies::validationMessageRangeOverflowText()
727{
728    notImplemented();
729    return String();
730}
731
732String WebPlatformStrategies::validationMessageStepMismatchText()
733{
734    notImplemented();
735    return String();
736}
737
738
739// VisitedLinkStrategy
740
741bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash hash)
742{
743    return page->group().isLinkVisited(hash);
744}
745
746void WebPlatformStrategies::addVisitedLink(Page* page, LinkHash hash)
747{
748    page->group().addVisitedLinkHash(hash);
749}
750