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 THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_INTERNAL_SETTINGS_H_ 28 #define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_INTERNAL_SETTINGS_H_ 29 30 #include "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h" 31 #include "third_party/blink/renderer/core/editing/editing_behavior_types.h" 32 #include "third_party/blink/renderer/core/page/page.h" 33 #include "third_party/blink/renderer/core/testing/internal_settings_generated.h" 34 #include "third_party/blink/renderer/platform/geometry/int_size.h" 35 #include "third_party/blink/renderer/platform/graphics/image_animation_policy.h" 36 #include "third_party/blink/renderer/platform/heap/handle.h" 37 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" 38 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" 39 40 namespace blink { 41 42 class ExceptionState; 43 class Page; 44 class Settings; 45 46 class InternalSettings final : public InternalSettingsGenerated, 47 public InternalSettingsPageSupplementBase { 48 USING_GARBAGE_COLLECTED_MIXIN(InternalSettings); 49 DEFINE_WRAPPERTYPEINFO(); 50 51 public: 52 class Backup { 53 DISALLOW_NEW(); 54 55 public: 56 explicit Backup(Settings*); 57 void RestoreTo(Settings*); 58 59 bool original_csp_; 60 bool original_overlay_scrollbars_enabled_; 61 EditingBehaviorType original_editing_behavior_; 62 bool original_text_autosizing_enabled_; 63 IntSize original_text_autosizing_window_size_override_; 64 float original_accessibility_font_scale_factor_; 65 String original_media_type_override_; 66 blink::mojom::DisplayMode original_display_mode_override_; 67 bool original_mock_gesture_tap_highlights_enabled_; 68 bool lang_attribute_aware_form_control_ui_enabled_; 69 bool images_enabled_; 70 String default_video_poster_url_; 71 ImageAnimationPolicy original_image_animation_policy_; 72 bool original_scroll_top_left_interop_enabled_; 73 }; 74 75 static InternalSettings* From(Page&); 76 77 explicit InternalSettings(Page&); 78 ~InternalSettings() override; 79 80 void ResetToConsistentState(); 81 82 void setStandardFontFamily(const AtomicString& family, 83 const String& script, 84 ExceptionState&); 85 void setSerifFontFamily(const AtomicString& family, 86 const String& script, 87 ExceptionState&); 88 void setSansSerifFontFamily(const AtomicString& family, 89 const String& script, 90 ExceptionState&); 91 void setFixedFontFamily(const AtomicString& family, 92 const String& script, 93 ExceptionState&); 94 void setCursiveFontFamily(const AtomicString& family, 95 const String& script, 96 ExceptionState&); 97 void setFantasyFontFamily(const AtomicString& family, 98 const String& script, 99 ExceptionState&); 100 void setPictographFontFamily(const AtomicString& family, 101 const String& script, 102 ExceptionState&); 103 104 void setDefaultVideoPosterURL(const String& url, ExceptionState&); 105 void setEditingBehavior(const String&, ExceptionState&); 106 void setImagesEnabled(bool, ExceptionState&); 107 void setMediaTypeOverride(const String& media_type, ExceptionState&); 108 void setDisplayModeOverride(const String& display_mode, ExceptionState&); 109 void setHideScrollbars(bool, ExceptionState&); 110 void setMockGestureTapHighlightsEnabled(bool, ExceptionState&); 111 void setTextAutosizingEnabled(bool, ExceptionState&); 112 void setTextTrackKindUserPreference(const String& preference, 113 ExceptionState&); 114 void setAccessibilityFontScaleFactor(float font_scale_factor, 115 ExceptionState&); 116 void setTextAutosizingWindowSizeOverride(int width, 117 int height, 118 ExceptionState&); 119 void setViewportEnabled(bool, ExceptionState&); 120 void setViewportMetaEnabled(bool, ExceptionState&); 121 void setViewportStyle(const String& preference, ExceptionState&); 122 void setPresentationReceiver(bool, ExceptionState&); 123 void setAutoplayPolicy(const String&, ExceptionState&); 124 void setUniversalAccessFromFileURLs(bool, ExceptionState&); 125 126 // FIXME: The following are RuntimeEnabledFeatures and likely 127 // cannot be changed after process start. These setters should 128 // be removed or moved onto internals.runtimeFlags: 129 void setLangAttributeAwareFormControlUIEnabled(bool); 130 void setExperimentalContentSecurityPolicyFeaturesEnabled(bool); 131 void setImageAnimationPolicy(const String&, ExceptionState&); 132 void setScrollTopLeftInteropEnabled(bool); 133 134 void Trace(Visitor*) override; 135 136 void setAvailablePointerTypes(const String&, ExceptionState&); 137 void setPrimaryPointerType(const String&, ExceptionState&); 138 void setAvailableHoverTypes(const String&, ExceptionState&); 139 void setPrimaryHoverType(const String&, ExceptionState&); 140 void SetDnsPrefetchLogging(bool, ExceptionState&); 141 void SetPreloadLogging(bool, ExceptionState&); 142 143 private: 144 Settings* GetSettings() const; GetPage()145 Page* GetPage() const { return GetSupplementable(); } 146 147 Backup backup_; 148 }; 149 150 } // namespace blink 151 152 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_INTERNAL_SETTINGS_H_ 153