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 DEFINE_WRAPPERTYPEINFO(); 53 public: 54 class Backup { 55 public: 56 explicit Backup(Settings*); 57 void restoreTo(Settings*); 58 59 bool m_originalAuthorShadowDOMForAnyElementEnabled; 60 bool m_originalCSP; 61 bool m_originalLaxMixedContentCheckingEnabled; 62 bool m_originalOverlayScrollbarsEnabled; 63 EditingBehaviorType m_originalEditingBehavior; 64 bool m_originalTextAutosizingEnabled; 65 IntSize m_originalTextAutosizingWindowSizeOverride; 66 float m_originalAccessibilityFontScaleFactor; 67 String m_originalMediaTypeOverride; 68 bool m_originalMockScrollbarsEnabled; 69 bool m_originalMockGestureTapHighlightsEnabled; 70 bool m_langAttributeAwareFormControlUIEnabled; 71 bool m_imagesEnabled; 72 String m_defaultVideoPosterURL; 73 bool m_originalLayerSquashingEnabled; 74 bool m_originalPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled; 75 }; 76 77 static PassRefPtrWillBeRawPtr<InternalSettings> create(Page& page) 78 { 79 return adoptRefWillBeNoop(new InternalSettings(page)); 80 } 81 static InternalSettings* from(Page&); 82 83 #if !ENABLE(OILPAN) 84 void hostDestroyed() { m_page = nullptr; } 85 #endif 86 87 virtual ~InternalSettings(); 88 void resetToConsistentState(); 89 90 void setStandardFontFamily(const AtomicString& family, const String& script, ExceptionState&); 91 void setSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&); 92 void setSansSerifFontFamily(const AtomicString& family, const String& script, ExceptionState&); 93 void setFixedFontFamily(const AtomicString& family, const String& script, ExceptionState&); 94 void setCursiveFontFamily(const AtomicString& family, const String& script, ExceptionState&); 95 void setFantasyFontFamily(const AtomicString& family, const String& script, ExceptionState&); 96 void setPictographFontFamily(const AtomicString& family, const String& script, ExceptionState&); 97 98 void setDefaultVideoPosterURL(const String& url, ExceptionState&); 99 void setEditingBehavior(const String&, ExceptionState&); 100 void setImagesEnabled(bool, ExceptionState&); 101 void setMediaTypeOverride(const String& mediaType, ExceptionState&); 102 void setMockScrollbarsEnabled(bool, ExceptionState&); 103 void setMockGestureTapHighlightsEnabled(bool, ExceptionState&); 104 void setTextAutosizingEnabled(bool, ExceptionState&); 105 void setAccessibilityFontScaleFactor(float fontScaleFactor, ExceptionState&); 106 void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionState&); 107 void setViewportEnabled(bool, ExceptionState&); 108 109 // FIXME: This is a temporary flag and should be removed once squashing is 110 // ready (crbug.com/261605). 111 void setLayerSquashingEnabled(bool, ExceptionState&); 112 113 // FIXME: The following are RuntimeEnabledFeatures and likely 114 // cannot be changed after process start. These setters should 115 // be removed or moved onto internals.runtimeFlags: 116 void setAuthorShadowDOMForAnyElementEnabled(bool); 117 void setLangAttributeAwareFormControlUIEnabled(bool); 118 void setOverlayScrollbarsEnabled(bool); 119 void setExperimentalContentSecurityPolicyFeaturesEnabled(bool); 120 void setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(bool); 121 void setLaxMixedContentCheckingEnabled(bool); 122 123 virtual void trace(Visitor*) OVERRIDE; 124 125 void setAvailablePointerTypes(const String&, ExceptionState&); 126 void setPrimaryPointerType(const String&, ExceptionState&); 127 void setAvailableHoverTypes(const String&, ExceptionState&); 128 void setPrimaryHoverType(const String&, ExceptionState&); 129 130 private: 131 explicit InternalSettings(Page&); 132 133 Settings* settings() const; 134 Page* page() const { return m_page; } 135 static const char* supplementName(); 136 137 RawPtrWillBeWeakMember<Page> m_page; 138 Backup m_backup; 139 }; 140 141 } // namespace blink 142 143 #endif // InternalSettings_h 144