Move internal testing classes from ExceptionCode to Exception
[WebKit-https.git] / Source / WebCore / testing / InternalSettings.h
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013-2016 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 #pragma once
28
29 // FIXME (121927): This include should not be needed.
30 #include <wtf/text/AtomicStringHash.h>
31
32 #include "EditingBehaviorTypes.h"
33 #include "ExceptionOr.h"
34 #include "FontGenericFamilies.h"
35 #include "IntSize.h"
36 #include "InternalSettingsGenerated.h"
37 #include "SecurityOrigin.h"
38 #include "Settings.h"
39 #include "WritingMode.h"
40
41 namespace WebCore {
42
43 class Page;
44 class Settings;
45
46 class InternalSettings : public InternalSettingsGenerated {
47 public:
48     static Ref<InternalSettings> create(Page*);
49     static InternalSettings* from(Page*);
50     void hostDestroyed();
51     void resetToConsistentState();
52
53     ExceptionOr<void> setUsesOverlayScrollbars(bool);
54     ExceptionOr<void> setTouchEventEmulationEnabled(bool);
55     ExceptionOr<void> setStandardFontFamily(const String& family, const String& script);
56     ExceptionOr<void> setSerifFontFamily(const String& family, const String& script);
57     ExceptionOr<void> setSansSerifFontFamily(const String& family, const String& script);
58     ExceptionOr<void> setFixedFontFamily(const String& family, const String& script);
59     ExceptionOr<void> setCursiveFontFamily(const String& family, const String& script);
60     ExceptionOr<void> setFantasyFontFamily(const String& family, const String& script);
61     ExceptionOr<void> setPictographFontFamily(const String& family, const String& script);
62     ExceptionOr<void> setTextAutosizingEnabled(bool);
63     ExceptionOr<void> setTextAutosizingWindowSizeOverride(int width, int height);
64     ExceptionOr<void> setTextAutosizingFontScaleFactor(float);
65     ExceptionOr<void> setMediaTypeOverride(const String&);
66     ExceptionOr<void> setCanStartMedia(bool);
67     ExceptionOr<void> setAllowsAirPlayForMediaPlayback(bool);
68     ExceptionOr<void> setEditingBehavior(const String&);
69     ExceptionOr<void> setPreferMIMETypeForImages(bool);
70     ExceptionOr<void> setPDFImageCachingPolicy(const String&);
71     ExceptionOr<void> setShouldDisplayTrackKind(const String& kind, bool enabled);
72     ExceptionOr<bool> shouldDisplayTrackKind(const String& kind);
73     ExceptionOr<void> setStorageBlockingPolicy(const String&);
74     static void setLangAttributeAwareFormControlUIEnabled(bool);
75     ExceptionOr<void> setImagesEnabled(bool);
76     ExceptionOr<void> setMinimumTimerInterval(double intervalInSeconds);
77     ExceptionOr<void> setDefaultVideoPosterURL(const String&);
78     ExceptionOr<void> setForcePendingWebGLPolicy(bool);
79     ExceptionOr<void> setTimeWithoutMouseMovementBeforeHidingControls(double);
80     ExceptionOr<void> setUseLegacyBackgroundSizeShorthandBehavior(bool);
81     ExceptionOr<void> setAutoscrollForDragAndDropEnabled(bool);
82     ExceptionOr<void> setFontFallbackPrefersPictographs(bool);
83     ExceptionOr<void> setWebFontsAlwaysFallBack(bool);
84     ExceptionOr<void> setQuickTimePluginReplacementEnabled(bool);
85     ExceptionOr<void> setYouTubeFlashPluginReplacementEnabled(bool);
86     ExceptionOr<void> setBackgroundShouldExtendBeyondPage(bool);
87     ExceptionOr<void> setShouldConvertPositionStyleOnCopy(bool);
88     ExceptionOr<void> setScrollingTreeIncludesFrames(bool);
89     ExceptionOr<void> setAllowsInlineMediaPlayback(bool);
90     ExceptionOr<void> setAllowsInlineMediaPlaybackAfterFullscreen(bool);
91     ExceptionOr<void> setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool);
92     static void setIndexedDBWorkersEnabled(bool);
93     ExceptionOr<String> userInterfaceDirectionPolicy();
94     ExceptionOr<void> setUserInterfaceDirectionPolicy(const String&);
95     ExceptionOr<String> systemLayoutDirection();
96     ExceptionOr<void> setSystemLayoutDirection(const String&);
97     ExceptionOr<bool> variationFontsEnabled();
98     ExceptionOr<void> setVariationFontsEnabled(bool);
99
100     enum class ForcedPrefersReducedMotionValue { System, On, Off };
101     ForcedPrefersReducedMotionValue forcedPrefersReducedMotionValue() const;
102     void setForcedPrefersReducedMotionValue(ForcedPrefersReducedMotionValue);
103
104     static void setAllowsAnySSLCertificate(bool);
105
106 private:
107     explicit InternalSettings(Page*);
108
109     Settings& settings() const;
110     static const char* supplementName();
111
112     class Backup {
113     public:
114         explicit Backup(Settings&);
115         void restoreTo(Settings&);
116
117         EditingBehaviorType m_originalEditingBehavior;
118
119         // Initially empty, only used if changed by a test.
120         ScriptFontFamilyMap m_standardFontFamilies;
121         ScriptFontFamilyMap m_fixedFontFamilies;
122         ScriptFontFamilyMap m_serifFontFamilies;
123         ScriptFontFamilyMap m_sansSerifFontFamilies;
124         ScriptFontFamilyMap m_cursiveFontFamilies;
125         ScriptFontFamilyMap m_fantasyFontFamilies;
126         ScriptFontFamilyMap m_pictographFontFamilies;
127
128 #if ENABLE(TEXT_AUTOSIZING)
129         bool m_originalTextAutosizingEnabled;
130         IntSize m_originalTextAutosizingWindowSizeOverride;
131 #endif
132
133         String m_originalMediaTypeOverride;
134         bool m_originalCanvasUsesAcceleratedDrawing;
135         bool m_originalMockScrollbarsEnabled;
136         bool m_originalUsesOverlayScrollbars;
137         bool m_langAttributeAwareFormControlUIEnabled;
138         bool m_imagesEnabled;
139         bool m_preferMIMETypeForImages;
140         std::chrono::milliseconds m_minimumTimerInterval;
141 #if ENABLE(VIDEO_TRACK)
142         bool m_shouldDisplaySubtitles;
143         bool m_shouldDisplayCaptions;
144         bool m_shouldDisplayTextDescriptions;
145 #endif
146         String m_defaultVideoPosterURL;
147         bool m_forcePendingWebGLPolicy;
148         bool m_originalTimeWithoutMouseMovementBeforeHidingControls;
149         bool m_useLegacyBackgroundSizeShorthandBehavior;
150         bool m_autoscrollForDragAndDropEnabled;
151         bool m_quickTimePluginReplacementEnabled;
152         bool m_youTubeFlashPluginReplacementEnabled;
153         bool m_shouldConvertPositionStyleOnCopy;
154         bool m_fontFallbackPrefersPictographs;
155         bool m_webFontsAlwaysFallBack;
156         bool m_backgroundShouldExtendBeyondPage;
157         SecurityOrigin::StorageBlockingPolicy m_storageBlockingPolicy;
158         bool m_scrollingTreeIncludesFrames;
159 #if ENABLE(TOUCH_EVENTS)
160         bool m_touchEventEmulationEnabled;
161 #endif
162 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
163         bool m_allowsAirPlayForMediaPlayback;
164 #endif
165         bool m_allowsInlineMediaPlayback;
166         bool m_allowsInlineMediaPlaybackAfterFullscreen;
167         bool m_inlineMediaPlaybackRequiresPlaysInlineAttribute;
168 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
169         bool m_indexedDBWorkersEnabled;
170 #endif
171 #if ENABLE(VARIATION_FONTS)
172         bool m_variationFontsEnabled;
173 #endif
174         bool m_inputEventsEnabled;
175
176         UserInterfaceDirectionPolicy m_userInterfaceDirectionPolicy;
177         TextDirection m_systemLayoutDirection;
178         PDFImageCachingPolicy m_pdfImageCachingPolicy;
179         Settings::ForcedPrefersReducedMotionValue m_forcedPrefersReducedMotionValue;
180     };
181
182     Page* m_page;
183     Backup m_backup;
184 };
185
186 } // namespace WebCore