Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / testing / InternalSettings.h
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 #ifndef InternalSettings_h
28 #define InternalSettings_h
29
30 #include "core/InternalSettingsGenerated.h"
31 #include "core/editing/EditingBehaviorTypes.h"
32 #include "platform/geometry/IntSize.h"
33 #include "platform/heap/Handle.h"
34 #include "wtf/PassRefPtr.h"
35 #include "wtf/RefCounted.h"
36 #include "wtf/text/WTFString.h"
37
38 namespace blink {
39
40 class Document;
41 class ExceptionState;
42 class LocalFrame;
43 class Page;
44 class Settings;
45
46 #if ENABLE(OILPAN)
47 class InternalSettings FINAL : public InternalSettingsGenerated, public HeapSupplement<Page> {
48     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(InternalSettings);
49 #else
50 class InternalSettings FINAL : public InternalSettingsGenerated {
51 #endif
52 public:
53     class Backup {
54     public:
55         explicit Backup(Settings*);
56         void restoreTo(Settings*);
57
58         bool m_originalAuthorShadowDOMForAnyElementEnabled;
59         bool m_originalCSP;
60         bool m_originalLaxMixedContentCheckingEnabled;
61         bool m_originalOverlayScrollbarsEnabled;
62         EditingBehaviorType m_originalEditingBehavior;
63         bool m_originalTextAutosizingEnabled;
64         IntSize m_originalTextAutosizingWindowSizeOverride;
65         float m_originalAccessibilityFontScaleFactor;
66         String m_originalMediaTypeOverride;
67         bool m_originalMockScrollbarsEnabled;
68         bool m_originalMockGestureTapHighlightsEnabled;
69         bool m_langAttributeAwareFormControlUIEnabled;
70         bool m_imagesEnabled;
71         String m_defaultVideoPosterURL;
72         bool m_originalLayerSquashingEnabled;
73         bool m_originalPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled;
74     };
75
76     static PassRefPtrWillBeRawPtr<InternalSettings> create(Page& page)
77     {
78         return adoptRefWillBeNoop(new InternalSettings(page));
79     }
80     static InternalSettings* from(Page&);
81
82 #if !ENABLE(OILPAN)
83     void hostDestroyed() { m_page = nullptr; }
84 #endif
85
86     virtual ~InternalSettings();
87     void resetToConsistentState();
88
89     void setStandardFontFamily(const AtomicString& family, const String& script, ExceptionState&);
90     void setSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&);
91     void setSansSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&);
92     void setFixedFontFamily(const AtomicString& family, const String& script, ExceptionState&);
93     void setCursiveFontFamily(const AtomicString& family, const String& script, ExceptionState&);
94     void setFantasyFontFamily(const AtomicString& family, const String& script, ExceptionState&);
95     void setPictographFontFamily(const AtomicString& family, const String& script, ExceptionState&);
96
97     void setDefaultVideoPosterURL(const String& url, ExceptionState&);
98     void setEditingBehavior(const String&, ExceptionState&);
99     void setImagesEnabled(bool, ExceptionState&);
100     void setMediaTypeOverride(const String& mediaType, ExceptionState&);
101     void setMockScrollbarsEnabled(bool, ExceptionState&);
102     void setMockGestureTapHighlightsEnabled(bool, ExceptionState&);
103     void setTextAutosizingEnabled(bool, ExceptionState&);
104     void setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState&);
105     void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&);
106     void setViewportEnabled(bool, ExceptionState&);
107
108     // FIXME: This is a temporary flag and should be removed once squashing is
109     // ready (crbug.com/261605).
110     void setLayerSquashingEnabled(bool, ExceptionState&);
111
112     // FIXME: The following are RuntimeEnabledFeatures and likely
113     // cannot be changed after process start. These setters should
114     // be removed or moved onto internals.runtimeFlags:
115     void setAuthorShadowDOMForAnyElementEnabled(bool);
116     void setLangAttributeAwareFormControlUIEnabled(bool);
117     void setOverlayScrollbarsEnabled(bool);
118     void setExperimentalContentSecurityPolicyFeaturesEnabled(bool);
119     void setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(bool);
120     void setLaxMixedContentCheckingEnabled(bool);
121
122     virtual void trace(Visitor*) OVERRIDE;
123
124 private:
125     explicit InternalSettings(Page&);
126
127     Settings* settings() const;
128     Page* page() const { return m_page; }
129     static const char* supplementName();
130
131     RawPtrWillBeWeakMember<Page> m_page;
132     Backup m_backup;
133 };
134
135 } // namespace blink
136
137 #endif