web_settings.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * Copyright (C) 2009 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SETTINGS_H_
  31. #define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SETTINGS_H_
  32. #include <unicode/uscript.h>
  33. #include "third_party/blink/public/common/css/navigation_controls.h"
  34. #include "third_party/blink/public/common/css/preferred_color_scheme.h"
  35. #include "third_party/blink/public/common/web_preferences/viewport_style.h"
  36. #include "third_party/blink/public/common/web_preferences/web_preferences.h"
  37. #include "third_party/blink/public/mojom/v8_cache_options.mojom-forward.h"
  38. #include "third_party/blink/public/platform/web_common.h"
  39. #include "third_party/blink/public/platform/web_effective_connection_type.h"
  40. #include "third_party/blink/public/platform/web_size.h"
  41. namespace blink {
  42. class WebString;
  43. // WebSettings is owned by the WebView and allows code to modify the settings
  44. // for the WebView's page without any knowledge of WebCore itself. For the most
  45. // part, these functions have a 1:1 mapping with the methods in
  46. // WebCore/page/Settings.h.
  47. class WebSettings {
  48. public:
  49. // Selection strategy defines how the selection granularity changes when the
  50. // selection extent is moved.
  51. enum class SelectionStrategyType {
  52. // Always uses character granularity.
  53. kCharacter,
  54. // "Expand by word, shrink by character" selection strategy.
  55. // Uses character granularity when selection is shrinking. If the
  56. // selection is expanding, granularity doesn't change until a word
  57. // boundary is passed, after which the granularity switches to "word".
  58. kDirection
  59. };
  60. // Defines user preference for text track kind.
  61. enum class TextTrackKindUserPreference {
  62. // Display only tracks marked as default
  63. kDefault,
  64. // If available, display captions track in preferred language, else display
  65. // subtitles.
  66. kCaptions,
  67. // If available, display subtitles track in preferred language, else display
  68. // captions.
  69. kSubtitles
  70. };
  71. // Defines the default for 'passive' field used in the AddEventListenerOptions
  72. // interface when javascript calls addEventListener.
  73. enum class PassiveEventListenerDefault {
  74. kFalse, // Default of false.
  75. kTrue, // Default of true.
  76. kForceAllTrue // Force all values to be true even when specified.
  77. };
  78. // Sets value of a setting by its string identifier from Settings.in and
  79. // string representation of value. An enum's string representation is the
  80. // string representation of the integer value of the enum.
  81. virtual void SetFromStrings(const WebString& name,
  82. const WebString& value) = 0;
  83. virtual bool ShrinksViewportContentToFit() const = 0;
  84. virtual bool ViewportEnabled() const = 0;
  85. virtual void SetAccelerated2dCanvasMSAASampleCount(int) = 0;
  86. virtual void SetPreferCompositingToLCDTextEnabled(bool) = 0;
  87. // Not implemented yet, see http://crbug.com/178119
  88. virtual void SetAcceleratedCompositingForTransitionEnabled(bool) {}
  89. // If set to true, allows frames with an https origin to display passive
  90. // contents at an insecure URL. Otherwise, disallows it. The
  91. // LocalFrameClient set to the frame may override the value set by this
  92. // method.
  93. virtual void SetAccessibilityPasswordValuesEnabled(bool) = 0;
  94. virtual void SetAllowFileAccessFromFileURLs(bool) = 0;
  95. virtual void SetAllowCustomScrollbarInMainFrame(bool) = 0;
  96. virtual void SetAllowGeolocationOnInsecureOrigins(bool) = 0;
  97. // If set to true, allows frames with an https origin to run active
  98. // contents at an insecure URL. This includes WebSockets. Otherwise,
  99. // disallows it. The LocalFrameClient set to the frame may override the
  100. // value set by this method.
  101. virtual void SetAllowRunningOfInsecureContent(bool) = 0;
  102. virtual void SetAllowScriptsToCloseWindows(bool) = 0;
  103. virtual void SetAllowUniversalAccessFromFileURLs(bool) = 0;
  104. virtual void SetAlwaysShowContextMenuOnTouch(bool) = 0;
  105. virtual void SetAntialiased2dCanvasEnabled(bool) = 0;
  106. virtual void SetAntialiasedClips2dCanvasEnabled(bool) = 0;
  107. virtual void SetAutoplayPolicy(web_pref::AutoplayPolicy) = 0;
  108. virtual void SetAutoZoomFocusedNodeToLegibleScale(bool) = 0;
  109. virtual void SetCaretBrowsingEnabled(bool) = 0;
  110. virtual void SetClobberUserAgentInitialScaleQuirk(bool) = 0;
  111. virtual void SetCookieEnabled(bool) = 0;
  112. virtual void SetNavigateOnDragDrop(bool) = 0;
  113. virtual void SetCursiveFontFamily(const WebString&,
  114. UScriptCode = USCRIPT_COMMON) = 0;
  115. virtual void SetDNSPrefetchingEnabled(bool) = 0;
  116. virtual void SetDOMPasteAllowed(bool) = 0;
  117. virtual void SetDefaultFixedFontSize(int) = 0;
  118. virtual void SetDefaultFontSize(int) = 0;
  119. virtual void SetDefaultTextEncodingName(const WebString&) = 0;
  120. virtual void SetDefaultVideoPosterURL(const WebString&) = 0;
  121. void SetDeferred2dCanvasEnabled(bool) {} // temporary stub
  122. virtual void SetDeviceScaleAdjustment(float) = 0;
  123. virtual void SetDisableReadingFromCanvas(bool) = 0;
  124. virtual void SetDontSendKeyEventsToJavascript(bool) = 0;
  125. virtual void SetDoubleTapToZoomEnabled(bool) = 0;
  126. virtual void SetDownloadableBinaryFontsEnabled(bool) = 0;
  127. virtual void SetEditingBehavior(web_pref::EditingBehaviorType) = 0;
  128. virtual void SetEnableScrollAnimator(bool) = 0;
  129. virtual void SetPrefersReducedMotion(bool) = 0;
  130. virtual void SetSmoothScrollForFindEnabled(bool) = 0;
  131. virtual void SetWebGL1Enabled(bool) = 0;
  132. virtual void SetWebGL2Enabled(bool) = 0;
  133. virtual void SetFantasyFontFamily(const WebString&,
  134. UScriptCode = USCRIPT_COMMON) = 0;
  135. virtual void SetFixedFontFamily(const WebString&,
  136. UScriptCode = USCRIPT_COMMON) = 0;
  137. virtual void SetNetworkQuietTimeout(double timeout) = 0;
  138. virtual void SetForceMainWorldInitialization(bool) = 0;
  139. virtual void SetForceZeroLayoutHeight(bool) = 0;
  140. virtual void SetFullscreenSupported(bool) = 0;
  141. virtual void SetHideDownloadUI(bool) = 0;
  142. virtual void SetHighlightAds(bool) = 0;
  143. virtual void SetHyperlinkAuditingEnabled(bool) = 0;
  144. virtual void SetIgnoreMainFrameOverflowHiddenQuirk(bool) = 0;
  145. virtual void SetImageAnimationPolicy(web_pref::ImageAnimationPolicy) = 0;
  146. virtual void SetImagesEnabled(bool) = 0;
  147. virtual void SetInlineTextBoxAccessibilityEnabled(bool) = 0;
  148. virtual void SetJavaScriptCanAccessClipboard(bool) = 0;
  149. virtual void SetJavaScriptEnabled(bool) = 0;
  150. virtual void SetLoadsImagesAutomatically(bool) = 0;
  151. virtual void SetLoadWithOverviewMode(bool) = 0;
  152. virtual void SetShouldReuseGlobalForUnownedMainFrame(bool) = 0;
  153. virtual void SetLocalStorageEnabled(bool) = 0;
  154. virtual void SetMainFrameClipsContent(bool) = 0;
  155. virtual void SetMainFrameResizesAreOrientationChanges(bool) = 0;
  156. virtual void SetMaxTouchPoints(int) = 0;
  157. virtual void SetPictureInPictureEnabled(bool) = 0;
  158. virtual void SetDataSaverHoldbackWebApi(bool) = 0;
  159. virtual void SetWebAppScope(const WebString&) = 0;
  160. virtual void SetPresentationRequiresUserGesture(bool) = 0;
  161. virtual void SetEmbeddedMediaExperienceEnabled(bool) = 0;
  162. virtual void SetImmersiveModeEnabled(bool) = 0;
  163. virtual void SetMinimumFontSize(int) = 0;
  164. virtual void SetMinimumLogicalFontSize(int) = 0;
  165. virtual void SetHideScrollbars(bool) = 0;
  166. virtual void SetOfflineWebApplicationCacheEnabled(bool) = 0;
  167. virtual void SetPassiveEventListenerDefault(PassiveEventListenerDefault) = 0;
  168. virtual void SetPasswordEchoDurationInSeconds(double) = 0;
  169. virtual void SetPasswordEchoEnabled(bool) = 0;
  170. virtual void SetPictographFontFamily(const WebString&,
  171. UScriptCode = USCRIPT_COMMON) = 0;
  172. virtual void SetPluginsEnabled(bool) = 0;
  173. virtual void SetPresentationReceiver(bool) = 0;
  174. virtual void SetAvailablePointerTypes(int) = 0;
  175. virtual void SetPrimaryPointerType(ui::PointerType) = 0;
  176. virtual void SetAvailableHoverTypes(int) = 0;
  177. virtual void SetPrimaryHoverType(ui::HoverType) = 0;
  178. virtual void SetPreferHiddenVolumeControls(bool) = 0;
  179. virtual void SetShouldProtectAgainstIpcFlooding(bool) = 0;
  180. virtual void SetRenderVSyncNotificationEnabled(bool) = 0;
  181. virtual void SetReportScreenSizeInPhysicalPixelsQuirk(bool) = 0;
  182. virtual void SetRubberBandingOnCompositorThread(bool) = 0;
  183. virtual void SetSansSerifFontFamily(const WebString&,
  184. UScriptCode = USCRIPT_COMMON) = 0;
  185. virtual void SetSelectTrailingWhitespaceEnabled(bool) = 0;
  186. virtual void SetSelectionIncludesAltImageText(bool) = 0;
  187. virtual void SetSelectionStrategy(SelectionStrategyType) = 0;
  188. virtual void SetSerifFontFamily(const WebString&,
  189. UScriptCode = USCRIPT_COMMON) = 0;
  190. virtual void SetShouldPrintBackgrounds(bool) = 0;
  191. virtual void SetShouldClearDocumentBackground(bool) = 0;
  192. virtual void SetShowContextMenuOnMouseUp(bool) = 0;
  193. virtual void SetShrinksViewportContentToFit(bool) = 0;
  194. virtual void SetSmartInsertDeleteEnabled(bool) = 0;
  195. // Spatial navigation feature, when enabled, improves the experience
  196. // of keyboard-controlling the web pages which originally were not designed
  197. // for keyboard navigation. It allows to use arrow keys to move focus between
  198. // the adjacent HTML elements. As a side effect, it extends the criteria for
  199. // elements to be focusable to include any element which has click or keyboard
  200. // event handlers specified. User can also trigger click handlers for such
  201. // elements using SPACE or ENTER keys.
  202. virtual void SetSpatialNavigationEnabled(bool) = 0;
  203. virtual void SetSpellCheckEnabledByDefault(bool) = 0;
  204. virtual void SetStandardFontFamily(const WebString&,
  205. UScriptCode = USCRIPT_COMMON) = 0;
  206. virtual void SetStrictMixedContentChecking(bool) = 0;
  207. virtual void SetStrictMixedContentCheckingForPlugin(bool) = 0;
  208. virtual void SetStrictPowerfulFeatureRestrictions(bool) = 0;
  209. virtual void SetStrictlyBlockBlockableMixedContent(bool) = 0;
  210. virtual void SetSupportDeprecatedTargetDensityDPI(bool) = 0;
  211. virtual void SetSupportsMultipleWindows(bool) = 0;
  212. virtual void SetSyncXHRInDocumentsEnabled(bool) = 0;
  213. virtual void SetTextAreasAreResizable(bool) = 0;
  214. virtual void SetTextAutosizingEnabled(bool) = 0;
  215. virtual void SetAccessibilityFontScaleFactor(float) = 0;
  216. virtual void SetAccessibilityAlwaysShowFocus(bool) = 0;
  217. virtual void SetTextTrackKindUserPreference(TextTrackKindUserPreference) = 0;
  218. virtual void SetTextTrackBackgroundColor(const WebString&) = 0;
  219. virtual void SetTextTrackFontFamily(const WebString&) = 0;
  220. virtual void SetTextTrackFontStyle(const WebString&) = 0;
  221. virtual void SetTextTrackFontVariant(const WebString&) = 0;
  222. virtual void SetTextTrackMarginPercentage(float) = 0;
  223. virtual void SetTextTrackTextColor(const WebString&) = 0;
  224. virtual void SetTextTrackTextShadow(const WebString&) = 0;
  225. virtual void SetTextTrackTextSize(const WebString&) = 0;
  226. virtual void SetTextTrackWindowColor(const WebString&) = 0;
  227. virtual void SetTextTrackWindowPadding(const WebString&) = 0;
  228. virtual void SetTextTrackWindowRadius(const WebString&) = 0;
  229. virtual void SetThreadedScrollingEnabled(bool) = 0;
  230. virtual void SetTouchDragDropEnabled(bool) = 0;
  231. virtual void SetTouchDragEndContextMenu(bool) = 0;
  232. virtual void SetBarrelButtonForDragEnabled(bool) = 0;
  233. virtual void SetUseLegacyBackgroundSizeShorthandBehavior(bool) = 0;
  234. virtual void SetViewportStyle(web_pref::ViewportStyle) = 0;
  235. virtual void SetUseWideViewport(bool) = 0;
  236. virtual void SetV8CacheOptions(mojom::V8CacheOptions) = 0;
  237. virtual void SetValidationMessageTimerMagnification(int) = 0;
  238. virtual void SetViewportEnabled(bool) = 0;
  239. virtual void SetViewportMetaEnabled(bool) = 0;
  240. virtual void SetViewportMetaMergeContentQuirk(bool) = 0;
  241. virtual void SetViewportMetaNonUserScalableQuirk(bool) = 0;
  242. virtual void SetViewportMetaZeroValuesQuirk(bool) = 0;
  243. virtual void SetWebGLErrorsToConsoleEnabled(bool) = 0;
  244. virtual void SetWebSecurityEnabled(bool) = 0;
  245. virtual void SetWideViewportQuirkEnabled(bool) = 0;
  246. virtual void SetMediaControlsEnabled(bool) = 0;
  247. virtual void SetDoNotUpdateSelectionOnMutatingSelectionRange(bool) = 0;
  248. virtual void SetLowPriorityIframesThreshold(WebEffectiveConnectionType) = 0;
  249. virtual void SetLazyLoadEnabled(bool) = 0;
  250. virtual void SetLazyFrameLoadingDistanceThresholdPxUnknown(int) = 0;
  251. virtual void SetLazyFrameLoadingDistanceThresholdPxOffline(int) = 0;
  252. virtual void SetLazyFrameLoadingDistanceThresholdPxSlow2G(int) = 0;
  253. virtual void SetLazyFrameLoadingDistanceThresholdPx2G(int) = 0;
  254. virtual void SetLazyFrameLoadingDistanceThresholdPx3G(int) = 0;
  255. virtual void SetLazyFrameLoadingDistanceThresholdPx4G(int) = 0;
  256. virtual void SetLazyImageLoadingDistanceThresholdPxUnknown(int) = 0;
  257. virtual void SetLazyImageLoadingDistanceThresholdPxOffline(int) = 0;
  258. virtual void SetLazyImageLoadingDistanceThresholdPxSlow2G(int) = 0;
  259. virtual void SetLazyImageLoadingDistanceThresholdPx2G(int) = 0;
  260. virtual void SetLazyImageLoadingDistanceThresholdPx3G(int) = 0;
  261. virtual void SetLazyImageLoadingDistanceThresholdPx4G(int) = 0;
  262. virtual void SetLazyImageFirstKFullyLoadUnknown(int) = 0;
  263. virtual void SetLazyImageFirstKFullyLoadSlow2G(int) = 0;
  264. virtual void SetLazyImageFirstKFullyLoad2G(int) = 0;
  265. virtual void SetLazyImageFirstKFullyLoad3G(int) = 0;
  266. virtual void SetLazyImageFirstKFullyLoad4G(int) = 0;
  267. virtual void SetForceDarkModeEnabled(bool) = 0;
  268. virtual void SetPreferredColorScheme(PreferredColorScheme) = 0;
  269. virtual void SetNavigationControls(NavigationControls) = 0;
  270. virtual void SetAriaModalPrunesAXTree(bool) = 0;
  271. virtual void SetUseAXMenuList(bool) = 0;
  272. virtual void SetSelectionClipboardBufferAvailable(bool) = 0;
  273. virtual void SetAccessibilityIncludeSvgGElement(bool) = 0;
  274. protected:
  275. ~WebSettings() = default;
  276. };
  277. } // namespace blink
  278. #endif