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 "EditingBehaviorTypes.h"
31#include "IntSize.h"
32#include "InternalSettingsGenerated.h"
33#include <wtf/PassRefPtr.h>
34#include <wtf/RefCounted.h>
35#include <wtf/text/WTFString.h>
36
37namespace WebCore {
38
39typedef int ExceptionCode;
40
41class Frame;
42class Document;
43class Page;
44class Settings;
45
46class InternalSettings : public InternalSettingsGenerated {
47public:
48    class Backup {
49    public:
50        explicit Backup(Settings*);
51        void restoreTo(Settings*);
52
53        bool m_originalCSSExclusionsEnabled;
54        bool m_originalCSSShapesEnabled;
55        bool m_originalCSSVariablesEnabled;
56#if ENABLE(SHADOW_DOM)
57        bool m_originalShadowDOMEnabled;
58        bool m_originalAuthorShadowDOMForAnyElementEnabled;
59#endif
60#if ENABLE(STYLE_SCOPED)
61        bool m_originalStyleScoped;
62#endif
63        EditingBehaviorType m_originalEditingBehavior;
64#if ENABLE(TEXT_AUTOSIZING)
65        bool m_originalTextAutosizingEnabled;
66        IntSize m_originalTextAutosizingWindowSizeOverride;
67        float m_originalTextAutosizingFontScaleFactor;
68#endif
69        String m_originalMediaTypeOverride;
70#if ENABLE(DIALOG_ELEMENT)
71        bool m_originalDialogElementEnabled;
72#endif
73        bool m_originalCanvasUsesAcceleratedDrawing;
74        bool m_originalMockScrollbarsEnabled;
75        bool m_originalUsesOverlayScrollbars;
76        bool m_langAttributeAwareFormControlUIEnabled;
77        bool m_imagesEnabled;
78        double m_minimumTimerInterval;
79#if ENABLE(VIDEO_TRACK)
80        bool m_shouldDisplaySubtitles;
81        bool m_shouldDisplayCaptions;
82        bool m_shouldDisplayTextDescriptions;
83#endif
84        String m_defaultVideoPosterURL;
85        bool m_originalTimeWithoutMouseMovementBeforeHidingControls;
86        bool m_useLegacyBackgroundSizeShorthandBehavior;
87    };
88
89    static PassRefPtr<InternalSettings> create(Page* page)
90    {
91        return adoptRef(new InternalSettings(page));
92    }
93    static InternalSettings* from(Page*);
94    void hostDestroyed() { m_page = 0; }
95
96    virtual ~InternalSettings();
97    void resetToConsistentState();
98
99    void setMockScrollbarsEnabled(bool enabled, ExceptionCode&);
100    void setUsesOverlayScrollbars(bool enabled, ExceptionCode&);
101    void setTouchEventEmulationEnabled(bool enabled, ExceptionCode&);
102    void setShadowDOMEnabled(bool enabled, ExceptionCode&);
103    void setAuthorShadowDOMForAnyElementEnabled(bool);
104    void setStyleScopedEnabled(bool);
105    void setStandardFontFamily(const String& family, const String& script, ExceptionCode&);
106    void setSerifFontFamily(const String& family, const String& script, ExceptionCode&);
107    void setSansSerifFontFamily(const String& family, const String& script, ExceptionCode&);
108    void setFixedFontFamily(const String& family, const String& script, ExceptionCode&);
109    void setCursiveFontFamily(const String& family, const String& script, ExceptionCode&);
110    void setFantasyFontFamily(const String& family, const String& script, ExceptionCode&);
111    void setPictographFontFamily(const String& family, const String& script, ExceptionCode&);
112    void setTextAutosizingEnabled(bool enabled, ExceptionCode&);
113    void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode&);
114    void setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode&);
115    void setMediaTypeOverride(const String& mediaType, ExceptionCode&);
116    void setCSSExclusionsEnabled(bool enabled, ExceptionCode&);
117    void setCSSShapesEnabled(bool enabled, ExceptionCode&);
118    void setCSSVariablesEnabled(bool enabled, ExceptionCode&);
119    bool cssVariablesEnabled(ExceptionCode&);
120    void setCanStartMedia(bool, ExceptionCode&);
121    void setEditingBehavior(const String&, ExceptionCode&);
122    void setDialogElementEnabled(bool, ExceptionCode&);
123    void setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode&);
124    bool shouldDisplayTrackKind(const String& kind, ExceptionCode&);
125    void setStorageBlockingPolicy(const String&, ExceptionCode&);
126    void setLangAttributeAwareFormControlUIEnabled(bool);
127    void setImagesEnabled(bool enabled, ExceptionCode&);
128    void setMinimumTimerInterval(double intervalInSeconds, ExceptionCode&);
129    void setDefaultVideoPosterURL(const String& url, ExceptionCode&);
130    void setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode&);
131    void setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode&);
132
133private:
134    explicit InternalSettings(Page*);
135
136    Settings* settings() const;
137    Page* page() const { return m_page; }
138    static const char* supplementName();
139
140    Page* m_page;
141    Backup m_backup;
142};
143
144} // namespace WebCore
145
146#endif
147