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 "platform/geometry/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 bool m_originalOverlayScrollbarsEnabled; 57 EditingBehaviorType m_originalEditingBehavior; 58 bool m_originalTextAutosizingEnabled; 59 IntSize m_originalTextAutosizingWindowSizeOverride; 60 float m_originalAccessibilityFontScaleFactor; 61 String m_originalMediaTypeOverride; 62 bool m_originalMockScrollbarsEnabled; 63 bool m_langAttributeAwareFormControlUIEnabled; 64 bool m_imagesEnabled; 65 bool m_shouldDisplaySubtitles; 66 bool m_shouldDisplayCaptions; 67 bool m_shouldDisplayTextDescriptions; 68 String m_defaultVideoPosterURL; 69 bool m_originalCompositorDrivenAcceleratedScrollEnabled; 70 bool m_originalLayerSquashingEnabled; 71 bool m_originalPasswordGenerationDecorationEnabled; 72 }; 73 74 static PassRefPtr<InternalSettings> create(Page* page) 75 { 76 return adoptRef(new InternalSettings(page)); 77 } 78 static InternalSettings* from(Page*); 79 void hostDestroyed() { m_page = 0; } 80 81 virtual ~InternalSettings(); 82 void resetToConsistentState(); 83 84 void setStandardFontFamily(const String& family, const String& script, ExceptionState&); 85 void setSerifFontFamily(const String& family, const String& script, ExceptionState&); 86 void setSansSerifFontFamily(const String& family, const String& script, ExceptionState&); 87 void setFixedFontFamily(const String& family, const String& script, ExceptionState&); 88 void setCursiveFontFamily(const String& family, const String& script, ExceptionState&); 89 void setFantasyFontFamily(const String& family, const String& script, ExceptionState&); 90 void setPictographFontFamily(const String& family, const String& script, ExceptionState&); 91 92 void setDefaultVideoPosterURL(const String& url, ExceptionState&); 93 void setEditingBehavior(const String&, ExceptionState&); 94 void setImagesEnabled(bool, ExceptionState&); 95 void setMediaTypeOverride(const String& mediaType, ExceptionState&); 96 void setMockScrollbarsEnabled(bool, ExceptionState&); 97 void setPasswordGenerationDecorationEnabled(bool, ExceptionState&); 98 void setTextAutosizingEnabled(bool, ExceptionState&); 99 void setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState&); 100 void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&); 101 void setTouchEventEmulationEnabled(bool, ExceptionState&); 102 void setViewportEnabled(bool, ExceptionState&); 103 104 // FIXME: This is a temporary flag and should be removed once accelerated 105 // overflow scroll is ready (crbug.com/254111). 106 void setCompositorDrivenAcceleratedScrollingEnabled(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 setCSSExclusionsEnabled(bool); 117 void setExperimentalWebSocketEnabled(bool); 118 void setLangAttributeAwareFormControlUIEnabled(bool); 119 void setOverlayScrollbarsEnabled(bool); 120 void setStyleScopedEnabled(bool); 121 122 private: 123 explicit InternalSettings(Page*); 124 125 Settings* settings() const; 126 Page* page() const { return m_page; } 127 static const char* supplementName(); 128 129 Page* m_page; 130 Backup m_backup; 131 }; 132 133 } // namespace WebCore 134 135 #endif 136