Home | History | Annotate | Download | only in testing
      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 "InternalSettingsGenerated.h"
     31 #include "core/editing/EditingBehaviorTypes.h"
     32 #include "core/platform/graphics/IntSize.h"
     33 #include "wtf/PassRefPtr.h"
     34 #include "wtf/RefCounted.h"
     35 #include "wtf/text/WTFString.h"
     36 
     37 namespace WebCore {
     38 
     39 class Document;
     40 class ExceptionState;
     41 class Frame;
     42 class Page;
     43 class Settings;
     44 
     45 class InternalSettings : public InternalSettingsGenerated {
     46 public:
     47     class Backup {
     48     public:
     49         explicit Backup(Settings*);
     50         void restoreTo(Settings*);
     51 
     52         bool m_originalCSSExclusionsEnabled;
     53         bool m_originalAuthorShadowDOMForAnyElementEnabled;
     54         bool m_originalExperimentalWebSocketEnabled;
     55         bool m_originalStyleScoped;
     56         EditingBehaviorType m_originalEditingBehavior;
     57         bool m_originalTextAutosizingEnabled;
     58         IntSize m_originalTextAutosizingWindowSizeOverride;
     59         float m_originalTextAutosizingFontScaleFactor;
     60         String m_originalMediaTypeOverride;
     61         bool m_originalLazyLayoutEnabled;
     62         bool m_originalMockScrollbarsEnabled;
     63         bool m_originalUsesOverlayScrollbars;
     64         bool m_langAttributeAwareFormControlUIEnabled;
     65         bool m_imagesEnabled;
     66         bool m_shouldDisplaySubtitles;
     67         bool m_shouldDisplayCaptions;
     68         bool m_shouldDisplayTextDescriptions;
     69         String m_defaultVideoPosterURL;
     70     };
     71 
     72     static PassRefPtr<InternalSettings> create(Page* page)
     73     {
     74         return adoptRef(new InternalSettings(page));
     75     }
     76     static InternalSettings* from(Page*);
     77     void hostDestroyed() { m_page = 0; }
     78 
     79     virtual ~InternalSettings();
     80     void resetToConsistentState();
     81 
     82     void setStandardFontFamily(const String& family, const String& script, ExceptionState&);
     83     void setSerifFontFamily(const String& family, const String& script, ExceptionState&);
     84     void setSansSerifFontFamily(const String& family, const String& script, ExceptionState&);
     85     void setFixedFontFamily(const String& family, const String& script, ExceptionState&);
     86     void setCursiveFontFamily(const String& family, const String& script, ExceptionState&);
     87     void setFantasyFontFamily(const String& family, const String& script, ExceptionState&);
     88     void setPictographFontFamily(const String& family, const String& script, ExceptionState&);
     89 
     90     void setDefaultVideoPosterURL(const String& url, ExceptionState&);
     91     void setEditingBehavior(const String&, ExceptionState&);
     92     void setImagesEnabled(bool, ExceptionState&);
     93     void setMediaTypeOverride(const String& mediaType, ExceptionState&);
     94     void setMockScrollbarsEnabled(bool, ExceptionState&);
     95     void setTextAutosizingEnabled(bool, ExceptionState&);
     96     void setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionState&);
     97     void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&);
     98     void setTouchEventEmulationEnabled(bool, ExceptionState&);
     99     void setUsesOverlayScrollbars(bool, ExceptionState&);
    100 
    101     // FIXME: This is a temporary flag and should be removed once accelerated
    102     // overflow scroll is ready (crbug.com/254111).
    103     void setCompositorDrivenAcceleratedScrollingEnabled(bool, ExceptionState&);
    104 
    105     // FIXME: The following are RuntimeEnabledFeatures and likely
    106     // cannot be changed after process start. These setters should
    107     // be removed or moved onto internals.runtimeFlags:
    108     void setAuthorShadowDOMForAnyElementEnabled(bool);
    109     void setCSSExclusionsEnabled(bool);
    110     void setExperimentalWebSocketEnabled(bool);
    111     void setLangAttributeAwareFormControlUIEnabled(bool);
    112     void setLazyLayoutEnabled(bool);
    113     void setStyleScopedEnabled(bool);
    114 
    115 private:
    116     explicit InternalSettings(Page*);
    117 
    118     Settings* settings() const;
    119     Page* page() const { return m_page; }
    120     static const char* supplementName();
    121 
    122     Page* m_page;
    123     Backup m_backup;
    124 };
    125 
    126 } // namespace WebCore
    127 
    128 #endif
    129