f0e85928aa5280976ebe908d24d88b334066c3e5
[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_preferMIMETypeForImages(settings.preferMIMETypeForImages())
83     , m_minimumTimerInterval(settings.minimumDOMTimerInterval())
84 #if ENABLE(VIDEO_TRACK)
85     , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
86     , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
87     , m_shouldDisplayTextDescriptions(settings.shouldDisplayTextDescriptions())
88 #endif
89     , m_defaultVideoPosterURL(settings.defaultVideoPosterURL())
90     , m_forcePendingWebGLPolicy(settings.isForcePendingWebGLPolicy())
91     , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings.timeWithoutMouseMovementBeforeHidingControls())
92     , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
93     , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
94     , m_pluginReplacementEnabled(settings.pluginReplacementEnabled())
95     , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
96     , m_fontFallbackPrefersPictographs(settings.fontFallbackPrefersPictographs())
97     , m_webFontsAlwaysFallBack(settings.webFontsAlwaysFallBack())
98     , m_backgroundShouldExtendBeyondPage(settings.backgroundShouldExtendBeyondPage())
99     , m_storageBlockingPolicy(settings.storageBlockingPolicy())
100     , m_scrollingTreeIncludesFrames(settings.scrollingTreeIncludesFrames())
101 #if ENABLE(TOUCH_EVENTS)
102     , m_touchEventEmulationEnabled(settings.isTouchEventEmulationEnabled())
103 #endif
104 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
105     , m_allowsAirPlayForMediaPlayback(settings.allowsAirPlayForMediaPlayback())
106 #endif
107     , m_allowsInlineMediaPlayback(settings.allowsInlineMediaPlayback())
108     , m_allowsInlineMediaPlaybackAfterFullscreen(settings.allowsInlineMediaPlaybackAfterFullscreen())
109     , m_inlineMediaPlaybackRequiresPlaysInlineAttribute(settings.inlineMediaPlaybackRequiresPlaysInlineAttribute())
110 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
111     , m_indexedDBWorkersEnabled(RuntimeEnabledFeatures::sharedFeatures().indexedDBWorkersEnabled())
112 #endif
113     , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
114     , m_systemLayoutDirection(settings.systemLayoutDirection())
115     , m_pdfImageCachingPolicy(settings.pdfImageCachingPolicy())
116 {
117 }
118
119 void InternalSettings::Backup::restoreTo(Settings& settings)
120 {
121     settings.setEditingBehaviorType(m_originalEditingBehavior);
122
123     for (const auto& standardFont : m_standardFontFamilies)
124         settings.setStandardFontFamily(standardFont.value, static_cast<UScriptCode>(standardFont.key));
125     m_standardFontFamilies.clear();
126
127     for (const auto& fixedFont : m_fixedFontFamilies)
128         settings.setFixedFontFamily(fixedFont.value, static_cast<UScriptCode>(fixedFont.key));
129     m_fixedFontFamilies.clear();
130
131     for (const auto& serifFont : m_serifFontFamilies)
132         settings.setSerifFontFamily(serifFont.value, static_cast<UScriptCode>(serifFont.key));
133     m_serifFontFamilies.clear();
134
135     for (const auto& sansSerifFont : m_sansSerifFontFamilies)
136         settings.setSansSerifFontFamily(sansSerifFont.value, static_cast<UScriptCode>(sansSerifFont.key));
137     m_sansSerifFontFamilies.clear();
138
139     for (const auto& cursiveFont : m_cursiveFontFamilies)
140         settings.setCursiveFontFamily(cursiveFont.value, static_cast<UScriptCode>(cursiveFont.key));
141     m_cursiveFontFamilies.clear();
142
143     for (const auto& fantasyFont : m_fantasyFontFamilies)
144         settings.setFantasyFontFamily(fantasyFont.value, static_cast<UScriptCode>(fantasyFont.key));
145     m_fantasyFontFamilies.clear();
146
147     for (const auto& pictographFont : m_pictographFontFamilies)
148         settings.setPictographFontFamily(pictographFont.value, static_cast<UScriptCode>(pictographFont.key));
149     m_pictographFontFamilies.clear();
150
151 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
152     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
153     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
154 #endif
155 #if ENABLE(TEXT_AUTOSIZING)
156     settings.setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
157 #endif
158     settings.setMediaTypeOverride(m_originalMediaTypeOverride);
159     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
160     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
161     settings.setImagesEnabled(m_imagesEnabled);
162     settings.setPreferMIMETypeForImages(m_preferMIMETypeForImages);
163     settings.setMinimumDOMTimerInterval(m_minimumTimerInterval);
164 #if ENABLE(VIDEO_TRACK)
165     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
166     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
167     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
168 #endif
169     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
170     settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
171     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
172     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
173     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
174     settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
175     settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
176     settings.setWebFontsAlwaysFallBack(m_webFontsAlwaysFallBack);
177     settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
178     settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
179     settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
180 #if ENABLE(TOUCH_EVENTS)
181     settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
182 #endif
183     settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
184     settings.setAllowsInlineMediaPlaybackAfterFullscreen(m_allowsInlineMediaPlaybackAfterFullscreen);
185     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
186     settings.setPluginReplacementEnabled(m_pluginReplacementEnabled);
187 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
188     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
189 #endif
190     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
191     settings.setSystemLayoutDirection(m_systemLayoutDirection);
192     settings.setPdfImageCachingPolicy(m_pdfImageCachingPolicy);
193     Settings::setAllowsAnySSLCertificate(false);
194 }
195
196 class InternalSettingsWrapper : public Supplement<Page> {
197 public:
198     explicit InternalSettingsWrapper(Page* page)
199         : m_internalSettings(InternalSettings::create(page)) { }
200     virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
201 #if !ASSERT_DISABLED
202     bool isRefCountedWrapper() const override { return true; }
203 #endif
204     InternalSettings* internalSettings() const { return m_internalSettings.get(); }
205
206 private:
207     RefPtr<InternalSettings> m_internalSettings;
208 };
209
210 const char* InternalSettings::supplementName()
211 {
212     return "InternalSettings";
213 }
214
215 InternalSettings* InternalSettings::from(Page* page)
216 {
217     if (!Supplement<Page>::from(page, supplementName()))
218         Supplement<Page>::provideTo(page, supplementName(), std::make_unique<InternalSettingsWrapper>(page));
219     return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
220 }
221
222 InternalSettings::~InternalSettings()
223 {
224 }
225
226 InternalSettings::InternalSettings(Page* page)
227     : InternalSettingsGenerated(page)
228     , m_page(page)
229     , m_backup(page->settings())
230 {
231 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
232     setAllowsAirPlayForMediaPlayback(false);
233 #endif
234 }
235
236 void InternalSettings::resetToConsistentState()
237 {
238     page()->setPageScaleFactor(1, { 0, 0 });
239     page()->mainFrame().setPageAndTextZoomFactors(1, 1);
240     page()->setCanStartMedia(true);
241     page()->settings().setForcePendingWebGLPolicy(false);
242 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
243     setAllowsAirPlayForMediaPlayback(false);
244 #endif
245
246     m_backup.restoreTo(*settings());
247     m_backup = Backup(*settings());
248
249     InternalSettingsGenerated::resetToConsistentState();
250 }
251
252 Settings* InternalSettings::settings() const
253 {
254     if (!page())
255         return 0;
256     return &page()->settings();
257 }
258
259 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
260 {
261 #if ENABLE(TOUCH_EVENTS)
262     InternalSettingsGuardForSettings();
263     settings()->setTouchEventEmulationEnabled(enabled);
264 #else
265     UNUSED_PARAM(enabled);
266     UNUSED_PARAM(ec);
267 #endif
268 }
269
270 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
271 {
272     InternalSettingsGuardForSettings();
273     UScriptCode code = scriptNameToCode(script);
274     if (code == USCRIPT_INVALID_CODE)
275         return;
276     m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
277     settings()->setStandardFontFamily(family, code);
278 }
279
280 void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
281 {
282     InternalSettingsGuardForSettings();
283     UScriptCode code = scriptNameToCode(script);
284     if (code == USCRIPT_INVALID_CODE)
285         return;
286     m_backup.m_serifFontFamilies.add(code, settings()->serifFontFamily(code));
287     settings()->setSerifFontFamily(family, code);
288 }
289
290 void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
291 {
292     InternalSettingsGuardForSettings();
293     UScriptCode code = scriptNameToCode(script);
294     if (code == USCRIPT_INVALID_CODE)
295         return;
296     m_backup.m_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
297     settings()->setSansSerifFontFamily(family, code);
298 }
299
300 void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
301 {
302     InternalSettingsGuardForSettings();
303     UScriptCode code = scriptNameToCode(script);
304     if (code == USCRIPT_INVALID_CODE)
305         return;
306     m_backup.m_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
307     settings()->setFixedFontFamily(family, code);
308 }
309
310 void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
311 {
312     InternalSettingsGuardForSettings();
313     UScriptCode code = scriptNameToCode(script);
314     if (code == USCRIPT_INVALID_CODE)
315         return;
316     m_backup.m_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
317     settings()->setCursiveFontFamily(family, code);
318 }
319
320 void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
321 {
322     InternalSettingsGuardForSettings();
323     UScriptCode code = scriptNameToCode(script);
324     if (code == USCRIPT_INVALID_CODE)
325         return;
326     m_backup.m_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
327     settings()->setFantasyFontFamily(family, code);
328 }
329
330 void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
331 {
332     InternalSettingsGuardForSettings();
333     UScriptCode code = scriptNameToCode(script);
334     if (code == USCRIPT_INVALID_CODE)
335         return;
336     m_backup.m_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
337     settings()->setPictographFontFamily(family, code);
338 }
339
340 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
341 {
342 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
343     InternalSettingsGuardForSettings();
344     settings()->setTextAutosizingEnabled(enabled);
345 #else
346     UNUSED_PARAM(enabled);
347     UNUSED_PARAM(ec);
348 #endif
349 }
350
351 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
352 {
353 #if ENABLE(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
354     InternalSettingsGuardForSettings();
355     settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
356 #else
357     UNUSED_PARAM(width);
358     UNUSED_PARAM(height);
359     UNUSED_PARAM(ec);
360 #endif
361 }
362
363 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
364 {
365     InternalSettingsGuardForSettings();
366     settings()->setMediaTypeOverride(mediaType);
367 }
368
369 void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
370 {
371 #if ENABLE(TEXT_AUTOSIZING)
372     InternalSettingsGuardForSettings();
373     settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
374 #else
375     UNUSED_PARAM(fontScaleFactor);
376     UNUSED_PARAM(ec);
377 #endif
378 }
379
380 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
381 {
382     InternalSettingsGuardForSettings();
383     m_page->setCanStartMedia(enabled);
384 }
385
386 void InternalSettings::setAllowsAirPlayForMediaPlayback(bool allows)
387 {
388 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
389     m_page->settings().setAllowsAirPlayForMediaPlayback(allows);
390 #else
391     UNUSED_PARAM(allows);
392 #endif
393 }
394
395 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
396 {
397     InternalSettingsGuardForSettings();
398     if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
399         settings()->setEditingBehaviorType(EditingWindowsBehavior);
400     else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
401         settings()->setEditingBehaviorType(EditingMacBehavior);
402     else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
403         settings()->setEditingBehaviorType(EditingUnixBehavior);
404     else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
405         settings()->setEditingBehaviorType(EditingIOSBehavior);
406     else
407         ec = SYNTAX_ERR;
408 }
409
410 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
411 {
412     InternalSettingsGuardForSettings();
413
414 #if ENABLE(VIDEO_TRACK)
415     if (!page())
416         return;
417
418     auto& captionPreferences = page()->group().captionPreferences();
419     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
420         captionPreferences.setUserPrefersSubtitles(enabled);
421     else if (equalLettersIgnoringASCIICase(kind, "captions"))
422         captionPreferences.setUserPrefersCaptions(enabled);
423     else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
424         captionPreferences.setUserPrefersTextDescriptions(enabled);
425     else
426         ec = SYNTAX_ERR;
427 #else
428     UNUSED_PARAM(kind);
429     UNUSED_PARAM(enabled);
430 #endif
431 }
432
433 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
434 {
435     InternalSettingsGuardForSettingsReturn(false);
436
437 #if ENABLE(VIDEO_TRACK)
438     if (!page())
439         return false;
440
441     auto& captionPreferences = page()->group().captionPreferences();
442     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
443         return captionPreferences.userPrefersSubtitles();
444     if (equalLettersIgnoringASCIICase(kind, "captions"))
445         return captionPreferences.userPrefersCaptions();
446     if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
447         return captionPreferences.userPrefersTextDescriptions();
448
449     ec = SYNTAX_ERR;
450     return false;
451 #else
452     UNUSED_PARAM(kind);
453     return false;
454 #endif
455 }
456
457 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
458 {
459     InternalSettingsGuardForSettings();
460
461     if (mode == "AllowAll")
462         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
463     else if (mode == "BlockThirdParty")
464         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
465     else if (mode == "BlockAll")
466         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
467     else
468         ec = SYNTAX_ERR;
469 }
470
471 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
472 {
473     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
474 }
475
476 void InternalSettings::setPreferMIMETypeForImages(bool preferMIMETypeForImages, ExceptionCode &ec)
477 {
478     InternalSettingsGuardForSettings();
479     settings()->setPreferMIMETypeForImages(preferMIMETypeForImages);
480 }
481
482 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
483 {
484     InternalSettingsGuardForSettings();
485     settings()->setImagesEnabled(enabled);
486 }
487
488 void InternalSettings::setPDFImageCachingPolicy(const String& policy, ExceptionCode& ec)
489 {
490     InternalSettingsGuardForSettings();
491     if (equalLettersIgnoringASCIICase(policy, "disabled"))
492         settings()->setPdfImageCachingPolicy(PDFImageCachingDisabled);
493     else if (equalLettersIgnoringASCIICase(policy, "belowmemorylimit"))
494         settings()->setPdfImageCachingPolicy(PDFImageCachingBelowMemoryLimit);
495     else if (equalLettersIgnoringASCIICase(policy, "clipboundsonly"))
496         settings()->setPdfImageCachingPolicy(PDFImageCachingClipBoundsOnly);
497     else if (equalLettersIgnoringASCIICase(policy, "enabled"))
498         settings()->setPdfImageCachingPolicy(PDFImageCachingEnabled);
499     else
500         ec = SYNTAX_ERR;
501 }
502
503 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
504 {
505     InternalSettingsGuardForSettings();
506     settings()->setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
507 }
508
509 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
510 {
511     InternalSettingsGuardForSettings();
512     settings()->setDefaultVideoPosterURL(url);
513 }
514
515 void InternalSettings::setForcePendingWebGLPolicy(bool forced, ExceptionCode& ec)
516 {
517     InternalSettingsGuardForSettings();
518     settings()->setForcePendingWebGLPolicy(forced);
519 }
520
521 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
522 {
523     InternalSettingsGuardForSettings();
524     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
525 }
526
527 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
528 {
529     InternalSettingsGuardForSettings();
530     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
531 }
532
533 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
534 {
535     InternalSettingsGuardForSettings();
536     settings()->setAutoscrollForDragAndDropEnabled(enabled);
537 }
538
539 void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
540 {
541     InternalSettingsGuardForSettings();
542     settings()->setFontFallbackPrefersPictographs(preferPictographs);
543 }
544
545 void InternalSettings::setWebFontsAlwaysFallBack(bool enable, ExceptionCode& ec)
546 {
547     InternalSettingsGuardForSettings();
548     settings()->setWebFontsAlwaysFallBack(enable);
549 }
550
551 void InternalSettings::setPluginReplacementEnabled(bool enabled, ExceptionCode& ec)
552 {
553     InternalSettingsGuardForSettings();
554     settings()->setPluginReplacementEnabled(enabled);
555 }
556
557 void InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode& ec)
558 {
559     InternalSettingsGuardForSettings();
560     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
561 }
562
563 void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
564 {
565     InternalSettingsGuardForSettings();
566     settings()->setShouldConvertPositionStyleOnCopy(convert);
567 }
568
569 void InternalSettings::setScrollingTreeIncludesFrames(bool enabled, ExceptionCode& ec)
570 {
571     InternalSettingsGuardForSettings();
572     settings()->setScrollingTreeIncludesFrames(enabled);
573 }
574
575 void InternalSettings::setAllowsInlineMediaPlayback(bool allows, ExceptionCode& ec)
576 {
577     InternalSettingsGuardForSettings();
578     settings()->setAllowsInlineMediaPlayback(allows);
579 }
580
581 void InternalSettings::setAllowsInlineMediaPlaybackAfterFullscreen(bool allows, ExceptionCode& ec)
582 {
583     InternalSettingsGuardForSettings();
584     settings()->setAllowsInlineMediaPlaybackAfterFullscreen(allows);
585 }
586
587 void InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires, ExceptionCode& ec)
588 {
589     InternalSettingsGuardForSettings();
590     settings()->setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
591 }
592
593 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled, ExceptionCode&)
594 {
595 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
596     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
597 #else
598     UNUSED_PARAM(enabled);
599 #endif
600 }
601
602 String InternalSettings::userInterfaceDirectionPolicy(ExceptionCode& ec)
603 {
604     InternalSettingsGuardForSettingsReturn("");
605     switch (settings()->userInterfaceDirectionPolicy()) {
606     case UserInterfaceDirectionPolicy::Content:
607         return ASCIILiteral("Content");
608     case UserInterfaceDirectionPolicy::System:
609         return ASCIILiteral("View");
610     }
611     ASSERT_NOT_REACHED();
612     return String();
613 }
614
615 void InternalSettings::setUserInterfaceDirectionPolicy(const String& policy, ExceptionCode& ec)
616 {
617     InternalSettingsGuardForSettings();
618     if (equalLettersIgnoringASCIICase(policy, "content")) {
619         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
620         return;
621     }
622     if (equalLettersIgnoringASCIICase(policy, "view")) {
623         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
624         return;
625     }
626     ec = INVALID_ACCESS_ERR;
627 }
628
629 String InternalSettings::systemLayoutDirection(ExceptionCode& ec)
630 {
631     InternalSettingsGuardForSettingsReturn("");
632     switch (settings()->systemLayoutDirection()) {
633     case LTR:
634         return ASCIILiteral("LTR");
635     case RTL:
636         return ASCIILiteral("RTL");
637     }
638     ASSERT_NOT_REACHED();
639     return String();
640 }
641
642 void InternalSettings::setSystemLayoutDirection(const String& direction, ExceptionCode& ec)
643 {
644     InternalSettingsGuardForSettings();
645     if (equalLettersIgnoringASCIICase(direction, "ltr")) {
646         settings()->setSystemLayoutDirection(LTR);
647         return;
648     }
649     if (equalLettersIgnoringASCIICase(direction, "rtl")) {
650         settings()->setSystemLayoutDirection(RTL);
651         return;
652     }
653     ec = INVALID_ACCESS_ERR;
654 }
655
656 void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
657 {
658     Settings::setAllowsAnySSLCertificate(allowsAnyCertificate);
659 }
660
661 // If you add to this list, make sure that you update the Backup class for test reproducability!
662
663 }