blob: 005ffb8702346e62068abae4b34daa1ccc861b56 [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
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#ifndef InternalSettings_h
28#define InternalSettings_h
29
30#include "InternalSettingsGenerated.h"
31#include "core/editing/EditingBehaviorTypes.h"
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000032#include "heap/Handle.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010033#include "platform/geometry/IntSize.h"
Torne (Richard Coles)e5249552013-05-15 11:35:13 +010034#include "wtf/PassRefPtr.h"
35#include "wtf/RefCounted.h"
36#include "wtf/text/WTFString.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010037
38namespace WebCore {
39
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010040class Document;
Ben Murdochdf957042013-08-06 11:01:27 +010041class ExceptionState;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000042class LocalFrame;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010043class Page;
44class Settings;
45
Torne (Richard Coles)09380292014-02-21 12:17:33 +000046class InternalSettings FINAL : public InternalSettingsGenerated {
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010047public:
48 class Backup {
49 public:
50 explicit Backup(Settings*);
51 void restoreTo(Settings*);
52
53 bool m_originalCSSExclusionsEnabled;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010054 bool m_originalAuthorShadowDOMForAnyElementEnabled;
Torne (Richard Coles)e5249552013-05-15 11:35:13 +010055 bool m_originalExperimentalWebSocketEnabled;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010056 bool m_originalStyleScoped;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000057 bool m_originalCSP;
Torne (Richard Coles)9bbd2f52013-09-19 22:37:05 +010058 bool m_originalOverlayScrollbarsEnabled;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010059 EditingBehaviorType m_originalEditingBehavior;
60 bool m_originalTextAutosizingEnabled;
61 IntSize m_originalTextAutosizingWindowSizeOverride;
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000062 float m_originalAccessibilityFontScaleFactor;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010063 String m_originalMediaTypeOverride;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010064 bool m_originalMockScrollbarsEnabled;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010065 bool m_langAttributeAwareFormControlUIEnabled;
66 bool m_imagesEnabled;
67 bool m_shouldDisplaySubtitles;
68 bool m_shouldDisplayCaptions;
69 bool m_shouldDisplayTextDescriptions;
70 String m_defaultVideoPosterURL;
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010071 bool m_originalCompositorDrivenAcceleratedScrollEnabled;
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000072 bool m_originalLayerSquashingEnabled;
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +010073 bool m_originalPasswordGenerationDecorationEnabled;
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010074 };
75
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000076 static PassRefPtrWillBeRawPtr<InternalSettings> create(Page& page)
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010077 {
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000078 return adoptRefWillBeNoop(new InternalSettings(page));
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010079 }
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000080 static InternalSettings* from(Page&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010081 void hostDestroyed() { m_page = 0; }
82
83 virtual ~InternalSettings();
84 void resetToConsistentState();
85
Torne (Richard Coles)09380292014-02-21 12:17:33 +000086 void setStandardFontFamily(const AtomicString& family, const String& script, ExceptionState&);
87 void setSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&);
88 void setSansSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&);
89 void setFixedFontFamily(const AtomicString& family, const String& script, ExceptionState&);
90 void setCursiveFontFamily(const AtomicString& family, const String& script, ExceptionState&);
91 void setFantasyFontFamily(const AtomicString& family, const String& script, ExceptionState&);
92 void setPictographFontFamily(const AtomicString& family, const String& script, ExceptionState&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010093
Ben Murdochdf957042013-08-06 11:01:27 +010094 void setDefaultVideoPosterURL(const String& url, ExceptionState&);
95 void setEditingBehavior(const String&, ExceptionState&);
96 void setImagesEnabled(bool, ExceptionState&);
97 void setMediaTypeOverride(const String& mediaType, ExceptionState&);
98 void setMockScrollbarsEnabled(bool, ExceptionState&);
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +010099 void setPasswordGenerationDecorationEnabled(bool, ExceptionState&);
Ben Murdochdf957042013-08-06 11:01:27 +0100100 void setTextAutosizingEnabled(bool, ExceptionState&);
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000101 void setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState&);
Ben Murdochdf957042013-08-06 11:01:27 +0100102 void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&);
103 void setTouchEventEmulationEnabled(bool, ExceptionState&);
Torne (Richard Coles)e1f1df52013-08-23 16:39:30 +0100104 void setViewportEnabled(bool, ExceptionState&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100105
Ben Murdoch591b9582013-07-10 11:41:44 +0100106 // FIXME: This is a temporary flag and should be removed once accelerated
107 // overflow scroll is ready (crbug.com/254111).
Ben Murdochdf957042013-08-06 11:01:27 +0100108 void setCompositorDrivenAcceleratedScrollingEnabled(bool, ExceptionState&);
Ben Murdoch591b9582013-07-10 11:41:44 +0100109
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000110 // FIXME: This is a temporary flag and should be removed once squashing is
111 // ready (crbug.com/261605).
112 void setLayerSquashingEnabled(bool, ExceptionState&);
113
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100114 // FIXME: The following are RuntimeEnabledFeatures and likely
Torne (Richard Coles)e5249552013-05-15 11:35:13 +0100115 // cannot be changed after process start. These setters should
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100116 // be removed or moved onto internals.runtimeFlags:
117 void setAuthorShadowDOMForAnyElementEnabled(bool);
118 void setCSSExclusionsEnabled(bool);
Torne (Richard Coles)e5249552013-05-15 11:35:13 +0100119 void setExperimentalWebSocketEnabled(bool);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100120 void setLangAttributeAwareFormControlUIEnabled(bool);
Torne (Richard Coles)9bbd2f52013-09-19 22:37:05 +0100121 void setOverlayScrollbarsEnabled(bool);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100122 void setStyleScopedEnabled(bool);
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000123 void setExperimentalContentSecurityPolicyFeaturesEnabled(bool);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100124
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000125 virtual void trace(Visitor* visitor) OVERRIDE { InternalSettingsGenerated::trace(visitor); }
126
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100127private:
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000128 explicit InternalSettings(Page&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100129
130 Settings* settings() const;
131 Page* page() const { return m_page; }
132 static const char* supplementName();
133
134 Page* m_page;
135 Backup m_backup;
136};
137
138} // namespace WebCore
139
140#endif