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 WebCore { 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_originalCSSExclusionsEnabled; 59 bool m_originalAuthorShadowDOMForAnyElementEnabled; 60 bool m_originalCSP; 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_langAttributeAwareFormControlUIEnabled; 69 bool m_imagesEnabled; 70 String m_defaultVideoPosterURL; 71 bool m_originalLayerSquashingEnabled; 72 bool m_originalPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled; 73 }; 74 75 static PassRefPtrWillBeRawPtr<InternalSettings> create(Page& page) 76 { 77 return adoptRefWillBeNoop(new InternalSettings(page)); 78 } 79 static InternalSettings* from(Page&); 80 81 #if !ENABLE(OILPAN) 82 void hostDestroyed() { m_page = nullptr; } 83 #endif 84 85 virtual ~InternalSettings(); 86 void resetToConsistentState(); 87 88 void setStandardFontFamily(const AtomicString& family, const String& script, ExceptionState&); 89 void setSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&); 90 void setSansSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&); 91 void setFixedFontFamily(const AtomicString& family, const String& script, ExceptionState&); 92 void setCursiveFontFamily(const AtomicString& family, const String& script, ExceptionState&); 93 void setFantasyFontFamily(const AtomicString& family, const String& script, ExceptionState&); 94 void setPictographFontFamily(const AtomicString& family, const String& script, ExceptionState&); 95 96 void setDefaultVideoPosterURL(const String& url, ExceptionState&); 97 void setEditingBehavior(const String&, ExceptionState&); 98 void setImagesEnabled(bool, ExceptionState&); 99 void setMediaTypeOverride(const String& mediaType, ExceptionState&); 100 void setMockScrollbarsEnabled(bool, ExceptionState&); 101 void setTextAutosizingEnabled(bool, ExceptionState&); 102 void setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState&); 103 void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&); 104 void setViewportEnabled(bool, ExceptionState&); 105 106 // FIXME: This is a temporary flag and should be removed once squashing is 107 // ready (crbug.com/261605). 108 void setLayerSquashingEnabled(bool, ExceptionState&); 109 110 // FIXME: The following are RuntimeEnabledFeatures and likely 111 // cannot be changed after process start. These setters should 112 // be removed or moved onto internals.runtimeFlags: 113 void setAuthorShadowDOMForAnyElementEnabled(bool); 114 void setCSSExclusionsEnabled(bool); 115 void setLangAttributeAwareFormControlUIEnabled(bool); 116 void setOverlayScrollbarsEnabled(bool); 117 void setExperimentalContentSecurityPolicyFeaturesEnabled(bool); 118 void setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(bool); 119 120 virtual void trace(Visitor*) OVERRIDE; 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 RawPtrWillBeWeakMember<Page> m_page; 130 Backup m_backup; 131 }; 132 133 } // namespace WebCore 134 135 #endif 136