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