REGRESSION(r198177): Cannot paste an image when the pasteboard format is mime type.
[WebKit-https.git] / Source / WebCore / testing / InternalSettings.cpp
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013 Apple Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "InternalSettings.h"
29
30 #include "CaptionUserPreferences.h"
31 #include "Document.h"
32 #include "ExceptionCode.h"
33 #include "FrameView.h"
34 #include "Language.h"
35 #include "LocaleToScriptMapping.h"
36 #include "MainFrame.h"
37 #include "Page.h"
38 #include "PageGroup.h"
39 #include "RuntimeEnabledFeatures.h"
40 #include "Settings.h"
41 #include "Supplementable.h"
42 #include "TextRun.h"
43
44 #if ENABLE(INPUT_TYPE_COLOR)
45 #include "ColorChooser.h"
46 #endif
47
48 #define InternalSettingsGuardForSettingsReturn(returnValue) \
49     if (!settings()) { \
50         ec = INVALID_ACCESS_ERR; \
51         return returnValue; \
52     }
53
54 #define InternalSettingsGuardForSettings()  \
55     if (!settings()) { \
56         ec = INVALID_ACCESS_ERR; \
57         return; \
58     }
59
60 #define InternalSettingsGuardForPage() \
61     if (!page()) { \
62         ec = INVALID_ACCESS_ERR; \
63         return; \
64     }
65
66 namespace WebCore {
67
68 InternalSettings::Backup::Backup(Settings& settings)
69     : m_originalEditingBehavior(settings.editingBehaviorType())
70 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
71     , m_originalTextAutosizingEnabled(settings.textAutosizingEnabled())
72     , m_originalTextAutosizingWindowSizeOverride(settings.textAutosizingWindowSizeOverride())
73 #endif
74 #if ENABLE(TEXT_AUTOSIZING)
75     , m_originalTextAutosizingFontScaleFactor(settings.textAutosizingFontScaleFactor())
76 #endif
77     , m_originalMediaTypeOverride(settings.mediaTypeOverride())
78     , m_originalCanvasUsesAcceleratedDrawing(settings.canvasUsesAcceleratedDrawing())
79     , m_originalMockScrollbarsEnabled(settings.mockScrollbarsEnabled())
80     , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::sharedFeatures().langAttributeAwareFormControlUIEnabled())
81     , m_imagesEnabled(settings.areImagesEnabled())
82     , m_minimumTimerInterval(settings.minimumDOMTimerInterval())
83 #if ENABLE(VIDEO_TRACK)
84     , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
85     , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
86     , m_shouldDisplayTextDescriptions(settings.shouldDisplayTextDescriptions())
87 #endif
88     , m_defaultVideoPosterURL(settings.defaultVideoPosterURL())
89     , m_forcePendingWebGLPolicy(settings.isForcePendingWebGLPolicy())
90     , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings.timeWithoutMouseMovementBeforeHidingControls())
91     , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
92     , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
93     , m_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
94     , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
95     , m_fontFallbackPrefersPictographs(settings.fontFallbackPrefersPictographs())
96     , m_webFontsAlwaysFallBack(settings.webFontsAlwaysFallBack())
97     , m_backgroundShouldExtendBeyondPage(settings.backgroundShouldExtendBeyondPage())
98     , m_storageBlockingPolicy(settings.storageBlockingPolicy())
99     , m_scrollingTreeIncludesFrames(settings.scrollingTreeIncludesFrames())
100 #if ENABLE(TOUCH_EVENTS)
101     , m_touchEventEmulationEnabled(settings.isTouchEventEmulationEnabled())
102 #endif
103 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
104     , m_allowsAirPlayForMediaPlayback(settings.allowsAirPlayForMediaPlayback())
105 #endif
106     , m_allowsInlineMediaPlayback(settings.allowsInlineMediaPlayback())
107     , m_allowsInlineMediaPlaybackAfterFullscreen(settings.allowsInlineMediaPlaybackAfterFullscreen())
108     , m_inlineMediaPlaybackRequiresPlaysInlineAttribute(settings.inlineMediaPlaybackRequiresPlaysInlineAttribute())
109 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
110     , m_indexedDBWorkersEnabled(RuntimeEnabledFeatures::sharedFeatures().indexedDBWorkersEnabled())
111 #endif
112     , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
113     , m_systemLayoutDirection(settings.systemLayoutDirection())
114 {
115 }
116
117 void InternalSettings::Backup::restoreTo(Settings& settings)
118 {
119     settings.setEditingBehaviorType(m_originalEditingBehavior);
120
121     for (const auto& standardFont : m_standardFontFamilies)
122         settings.setStandardFontFamily(standardFont.value, static_cast<UScriptCode>(standardFont.key));
123     m_standardFontFamilies.clear();
124
125     for (const auto& fixedFont : m_fixedFontFamilies)
126         settings.setFixedFontFamily(fixedFont.value, static_cast<UScriptCode>(fixedFont.key));
127     m_fixedFontFamilies.clear();
128
129     for (const auto& serifFont : m_serifFontFamilies)
130         settings.setSerifFontFamily(serifFont.value, static_cast<UScriptCode>(serifFont.key));
131     m_serifFontFamilies.clear();
132
133     for (const auto& sansSerifFont : m_sansSerifFontFamilies)
134         settings.setSansSerifFontFamily(sansSerifFont.value, static_cast<UScriptCode>(sansSerifFont.key));
135     m_sansSerifFontFamilies.clear();
136
137     for (const auto& cursiveFont : m_cursiveFontFamilies)
138         settings.setCursiveFontFamily(cursiveFont.value, static_cast<UScriptCode>(cursiveFont.key));
139     m_cursiveFontFamilies.clear();
140
141     for (const auto& fantasyFont : m_fantasyFontFamilies)
142         settings.setFantasyFontFamily(fantasyFont.value, static_cast<UScriptCode>(fantasyFont.key));
143     m_fantasyFontFamilies.clear();
144
145     for (const auto& pictographFont : m_pictographFontFamilies)
146         settings.setPictographFontFamily(pictographFont.value, static_cast<UScriptCode>(pictographFont.key));
147     m_pictographFontFamilies.clear();
148
149 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
150     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
151     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
152 #endif
153 #if ENABLE(TEXT_AUTOSIZING)
154     settings.setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
155 #endif
156     settings.setMediaTypeOverride(m_originalMediaTypeOverride);
157     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
158     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
159     settings.setImagesEnabled(m_imagesEnabled);
160     settings.setPreferMIMETypeForImages(m_preferMIMETypeForImages);
161     settings.setMinimumDOMTimerInterval(m_minimumTimerInterval);
162 #if ENABLE(VIDEO_TRACK)
163     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
164     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
165     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
166 #endif
167     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
168     settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
169     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
170     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
171     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
172     settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
173     settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
174     settings.setWebFontsAlwaysFallBack(m_webFontsAlwaysFallBack);
175     settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
176     settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
177     settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
178 #if ENABLE(TOUCH_EVENTS)
179     settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
180 #endif
181     settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
182     settings.setAllowsInlineMediaPlaybackAfterFullscreen(m_allowsInlineMediaPlaybackAfterFullscreen);
183     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
184     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
185 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
186     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
187 #endif
188     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
189     settings.setSystemLayoutDirection(m_systemLayoutDirection);
190     Settings::setAllowsAnySSLCertificate(false);
191 }
192
193 class InternalSettingsWrapper : public Supplement<Page> {
194 public:
195     explicit InternalSettingsWrapper(Page* page)
196         : m_internalSettings(InternalSettings::create(page)) { }
197     virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
198 #if !ASSERT_DISABLED
199     bool isRefCountedWrapper() const override { return true; }
200 #endif
201     InternalSettings* internalSettings() const { return m_internalSettings.get(); }
202
203 private:
204     RefPtr<InternalSettings> m_internalSettings;
205 };
206
207 const char* InternalSettings::supplementName()
208 {
209     return "InternalSettings";
210 }
211
212 InternalSettings* InternalSettings::from(Page* page)
213 {
214     if (!Supplement<Page>::from(page, supplementName()))
215         Supplement<Page>::provideTo(page, supplementName(), std::make_unique<InternalSettingsWrapper>(page));
216     return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
217 }
218
219 InternalSettings::~InternalSettings()
220 {
221 }
222
223 InternalSettings::InternalSettings(Page* page)
224     : InternalSettingsGenerated(page)
225     , m_page(page)
226     , m_backup(page->settings())
227 {
228 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
229     page->settings().setAllowsAirPlayForMediaPlayback(false);
230 #endif
231 }
232
233 void InternalSettings::resetToConsistentState()
234 {
235     page()->setPageScaleFactor(1, { 0, 0 });
236     page()->mainFrame().setPageAndTextZoomFactors(1, 1);
237     page()->setCanStartMedia(true);
238     page()->settings().setForcePendingWebGLPolicy(false);
239 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
240     page()->settings().setAllowsAirPlayForMediaPlayback(false);
241 #endif
242
243     m_backup.restoreTo(*settings());
244     m_backup = Backup(*settings());
245
246     InternalSettingsGenerated::resetToConsistentState();
247 }
248
249 Settings* InternalSettings::settings() const
250 {
251     if (!page())
252         return 0;
253     return &page()->settings();
254 }
255
256 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
257 {
258 #if ENABLE(TOUCH_EVENTS)
259     InternalSettingsGuardForSettings();
260     settings()->setTouchEventEmulationEnabled(enabled);
261 #else
262     UNUSED_PARAM(enabled);
263     UNUSED_PARAM(ec);
264 #endif
265 }
266
267 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
268 {
269     InternalSettingsGuardForSettings();
270     UScriptCode code = scriptNameToCode(script);
271     if (code == USCRIPT_INVALID_CODE)
272         return;
273     m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
274     settings()->setStandardFontFamily(family, code);
275 }
276
277 void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
278 {
279     InternalSettingsGuardForSettings();
280     UScriptCode code = scriptNameToCode(script);
281     if (code == USCRIPT_INVALID_CODE)
282         return;
283     m_backup.m_serifFontFamilies.add(code, settings()->serifFontFamily(code));
284     settings()->setSerifFontFamily(family, code);
285 }
286
287 void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
288 {
289     InternalSettingsGuardForSettings();
290     UScriptCode code = scriptNameToCode(script);
291     if (code == USCRIPT_INVALID_CODE)
292         return;
293     m_backup.m_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
294     settings()->setSansSerifFontFamily(family, code);
295 }
296
297 void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
298 {
299     InternalSettingsGuardForSettings();
300     UScriptCode code = scriptNameToCode(script);
301     if (code == USCRIPT_INVALID_CODE)
302         return;
303     m_backup.m_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
304     settings()->setFixedFontFamily(family, code);
305 }
306
307 void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
308 {
309     InternalSettingsGuardForSettings();
310     UScriptCode code = scriptNameToCode(script);
311     if (code == USCRIPT_INVALID_CODE)
312         return;
313     m_backup.m_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
314     settings()->setCursiveFontFamily(family, code);
315 }
316
317 void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
318 {
319     InternalSettingsGuardForSettings();
320     UScriptCode code = scriptNameToCode(script);
321     if (code == USCRIPT_INVALID_CODE)
322         return;
323     m_backup.m_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
324     settings()->setFantasyFontFamily(family, code);
325 }
326
327 void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
328 {
329     InternalSettingsGuardForSettings();
330     UScriptCode code = scriptNameToCode(script);
331     if (code == USCRIPT_INVALID_CODE)
332         return;
333     m_backup.m_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
334     settings()->setPictographFontFamily(family, code);
335 }
336
337 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
338 {
339 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
340     InternalSettingsGuardForSettings();
341     settings()->setTextAutosizingEnabled(enabled);
342 #else
343     UNUSED_PARAM(enabled);
344     UNUSED_PARAM(ec);
345 #endif
346 }
347
348 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
349 {
350 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
351     InternalSettingsGuardForSettings();
352     settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
353 #else
354     UNUSED_PARAM(width);
355     UNUSED_PARAM(height);
356     UNUSED_PARAM(ec);
357 #endif
358 }
359
360 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
361 {
362     InternalSettingsGuardForSettings();
363     settings()->setMediaTypeOverride(mediaType);
364 }
365
366 void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
367 {
368 #if ENABLE(TEXT_AUTOSIZING)
369     InternalSettingsGuardForSettings();
370     settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
371 #else
372     UNUSED_PARAM(fontScaleFactor);
373     UNUSED_PARAM(ec);
374 #endif
375 }
376
377 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
378 {
379     InternalSettingsGuardForSettings();
380     m_page->setCanStartMedia(enabled);
381 }
382
383 void InternalSettings::setWirelessPlaybackDisabled(bool available)
384 {
385 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
386     m_page->settings().setAllowsAirPlayForMediaPlayback(available);
387 #else
388     UNUSED_PARAM(available);
389 #endif
390 }
391
392 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
393 {
394     InternalSettingsGuardForSettings();
395     if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
396         settings()->setEditingBehaviorType(EditingWindowsBehavior);
397     else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
398         settings()->setEditingBehaviorType(EditingMacBehavior);
399     else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
400         settings()->setEditingBehaviorType(EditingUnixBehavior);
401     else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
402         settings()->setEditingBehaviorType(EditingIOSBehavior);
403     else
404         ec = SYNTAX_ERR;
405 }
406
407 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
408 {
409     InternalSettingsGuardForSettings();
410
411 #if ENABLE(VIDEO_TRACK)
412     if (!page())
413         return;
414
415     auto& captionPreferences = page()->group().captionPreferences();
416     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
417         captionPreferences.setUserPrefersSubtitles(enabled);
418     else if (equalLettersIgnoringASCIICase(kind, "captions"))
419         captionPreferences.setUserPrefersCaptions(enabled);
420     else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
421         captionPreferences.setUserPrefersTextDescriptions(enabled);
422     else
423         ec = SYNTAX_ERR;
424 #else
425     UNUSED_PARAM(kind);
426     UNUSED_PARAM(enabled);
427 #endif
428 }
429
430 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
431 {
432     InternalSettingsGuardForSettingsReturn(false);
433
434 #if ENABLE(VIDEO_TRACK)
435     if (!page())
436         return false;
437
438     auto& captionPreferences = page()->group().captionPreferences();
439     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
440         return captionPreferences.userPrefersSubtitles();
441     if (equalLettersIgnoringASCIICase(kind, "captions"))
442         return captionPreferences.userPrefersCaptions();
443     if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
444         return captionPreferences.userPrefersTextDescriptions();
445
446     ec = SYNTAX_ERR;
447     return false;
448 #else
449     UNUSED_PARAM(kind);
450     return false;
451 #endif
452 }
453
454 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
455 {
456     InternalSettingsGuardForSettings();
457
458     if (mode == "AllowAll")
459         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
460     else if (mode == "BlockThirdParty")
461         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
462     else if (mode == "BlockAll")
463         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
464     else
465         ec = SYNTAX_ERR;
466 }
467
468 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
469 {
470     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
471 }
472
473 void InternalSettings::setPreferMIMETypeForImages(bool preferMIMETypeForImages, ExceptionCode &ec)
474 {
475     InternalSettingsGuardForSettings();
476     settings()->setPreferMIMETypeForImages(preferMIMETypeForImages);
477 }
478
479 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
480 {
481     InternalSettingsGuardForSettings();
482     settings()->setImagesEnabled(enabled);
483 }
484
485 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
486 {
487     InternalSettingsGuardForSettings();
488     settings()->setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
489 }
490
491 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
492 {
493     InternalSettingsGuardForSettings();
494     settings()->setDefaultVideoPosterURL(url);
495 }
496
497 void InternalSettings::setForcePendingWebGLPolicy(bool forced, ExceptionCode& ec)
498 {
499     InternalSettingsGuardForSettings();
500     settings()->setForcePendingWebGLPolicy(forced);
501 }
502
503 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
504 {
505     InternalSettingsGuardForSettings();
506     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
507 }
508
509 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
510 {
511     InternalSettingsGuardForSettings();
512     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
513 }
514
515 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
516 {
517     InternalSettingsGuardForSettings();
518     settings()->setAutoscrollForDragAndDropEnabled(enabled);
519 }
520
521 void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
522 {
523     InternalSettingsGuardForSettings();
524     settings()->setFontFallbackPrefersPictographs(preferPictographs);
525 }
526
527 void InternalSettings::setWebFontsAlwaysFallBack(bool enable, ExceptionCode& ec)
528 {
529     InternalSettingsGuardForSettings();
530     settings()->setWebFontsAlwaysFallBack(enable);
531 }
532
533 void InternalSettings::setPluginReplacementEnabled(bool enabled)
534 {
535     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(enabled);
536 }
537
538 void InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode& ec)
539 {
540     InternalSettingsGuardForSettings();
541     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
542 }
543
544 void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
545 {
546     InternalSettingsGuardForSettings();
547     settings()->setShouldConvertPositionStyleOnCopy(convert);
548 }
549
550 void InternalSettings::setScrollingTreeIncludesFrames(bool enabled, ExceptionCode& ec)
551 {
552     InternalSettingsGuardForSettings();
553     settings()->setScrollingTreeIncludesFrames(enabled);
554 }
555
556 void InternalSettings::setAllowsInlineMediaPlayback(bool allows, ExceptionCode& ec)
557 {
558     InternalSettingsGuardForSettings();
559     settings()->setAllowsInlineMediaPlayback(allows);
560 }
561
562 void InternalSettings::setAllowsInlineMediaPlaybackAfterFullscreen(bool allows, ExceptionCode& ec)
563 {
564     InternalSettingsGuardForSettings();
565     settings()->setAllowsInlineMediaPlaybackAfterFullscreen(allows);
566 }
567
568 void InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires, ExceptionCode& ec)
569 {
570     InternalSettingsGuardForSettings();
571     settings()->setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
572 }
573
574 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled, ExceptionCode&)
575 {
576 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
577     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
578 #else
579     UNUSED_PARAM(enabled);
580 #endif
581 }
582
583 String InternalSettings::userInterfaceDirectionPolicy(ExceptionCode& ec)
584 {
585     InternalSettingsGuardForSettingsReturn("");
586     switch (settings()->userInterfaceDirectionPolicy()) {
587     case UserInterfaceDirectionPolicy::Content:
588         return ASCIILiteral("Content");
589     case UserInterfaceDirectionPolicy::System:
590         return ASCIILiteral("View");
591     }
592     ASSERT_NOT_REACHED();
593     return String();
594 }
595
596 void InternalSettings::setUserInterfaceDirectionPolicy(const String& policy, ExceptionCode& ec)
597 {
598     InternalSettingsGuardForSettings();
599     if (equalLettersIgnoringASCIICase(policy, "content")) {
600         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
601         return;
602     }
603     if (equalLettersIgnoringASCIICase(policy, "view")) {
604         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
605         return;
606     }
607     ec = INVALID_ACCESS_ERR;
608 }
609
610 String InternalSettings::systemLayoutDirection(ExceptionCode& ec)
611 {
612     InternalSettingsGuardForSettingsReturn("");
613     switch (settings()->systemLayoutDirection()) {
614     case LTR:
615         return ASCIILiteral("LTR");
616     case RTL:
617         return ASCIILiteral("RTL");
618     }
619     ASSERT_NOT_REACHED();
620     return String();
621 }
622
623 void InternalSettings::setSystemLayoutDirection(const String& direction, ExceptionCode& ec)
624 {
625     InternalSettingsGuardForSettings();
626     if (equalLettersIgnoringASCIICase(direction, "ltr")) {
627         settings()->setSystemLayoutDirection(LTR);
628         return;
629     }
630     if (equalLettersIgnoringASCIICase(direction, "rtl")) {
631         settings()->setSystemLayoutDirection(RTL);
632         return;
633     }
634     ec = INVALID_ACCESS_ERR;
635 }
636
637 void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
638 {
639     Settings::setAllowsAnySSLCertificate(allowsAnyCertificate);
640 }
641
642 // If you add to this list, make sure that you update the Backup class for test reproducability!
643
644 }