// Copyright © 2010-2015 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #pragma once #include "Stdafx.h" #include "Internals/StringUtils.h" #include "RequestContext.h" using namespace CefSharp::Internals; namespace CefSharp { /// /// Browser initialization settings. Specify NULL or 0 to get the recommended /// default values. The consequences of using custom values may not be well /// tested. Many of these and other settings can also configured using command- /// line switches. /// public ref class BrowserSettings { internal: CefBrowserSettings* _browserSettings; public: BrowserSettings() : _browserSettings(new CefBrowserSettings()) { } !BrowserSettings() { delete _browserSettings; } ~BrowserSettings() { this->!BrowserSettings(); } property String^ StandardFontFamily { String^ get() { return StringUtils::ToClr(_browserSettings->standard_font_family); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->standard_font_family, value); } } property String^ FixedFontFamily { String^ get() { return StringUtils::ToClr(_browserSettings->fixed_font_family); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->fixed_font_family, value); } } property String^ SerifFontFamily { String^ get() { return StringUtils::ToClr(_browserSettings->serif_font_family); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->serif_font_family, value); } } property String^ SansSerifFontFamily { String^ get() { return StringUtils::ToClr(_browserSettings->sans_serif_font_family); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->sans_serif_font_family, value); } } property String^ CursiveFontFamily { String^ get() { return StringUtils::ToClr(_browserSettings->cursive_font_family); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->cursive_font_family, value); } } property String^ FantasyFontFamily { String^ get() { return StringUtils::ToClr(_browserSettings->fantasy_font_family); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->fantasy_font_family, value); } } property int DefaultFontSize { int get() { return _browserSettings->default_font_size; } void set(int value) { _browserSettings->default_font_size = value; } } property int DefaultFixedFontSize { int get() { return _browserSettings->default_fixed_font_size; } void set(int value) { _browserSettings->default_fixed_font_size = value; } } property int MinimumFontSize { int get() { return _browserSettings->minimum_font_size; } void set(int value) { _browserSettings->minimum_font_size = value; } } property int MinimumLogicalFontSize { int get() { return _browserSettings->minimum_logical_font_size; } void set(int value) { _browserSettings->minimum_logical_font_size = value; } } /// /// Default encoding for Web content. If empty "ISO-8859-1" will be used. Also /// configurable using the "default-encoding" command-line switch. /// property String^ DefaultEncoding { String^ get() { return StringUtils::ToClr(_browserSettings->default_encoding); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->default_encoding, value); } } /// /// Controls the loading of fonts from remote sources. Also configurable using /// the "disable-remote-fonts" command-line switch. /// property CefState RemoteFonts { CefState get() { return (CefState)_browserSettings->remote_fonts; } void set(CefState value) { _browserSettings->remote_fonts = (cef_state_t)value; } } /// /// Controls whether JavaScript can be executed. Also configurable using the /// "disable-javascript" command-line switch. /// property CefState Javascript { CefState get() { return (CefState)_browserSettings->javascript; } void set(CefState value) { _browserSettings->javascript = (cef_state_t)value; } } /// /// Controls whether JavaScript can be used for opening windows. Also /// configurable using the "disable-javascript-open-windows" command-line /// switch. /// property CefState JavascriptOpenWindows { CefState get() { return (CefState)_browserSettings->javascript_open_windows; } void set(CefState value) { _browserSettings->javascript_open_windows = (cef_state_t)value; } } /// /// Controls whether JavaScript can be used to close windows that were not /// opened via JavaScript. JavaScript can still be used to close windows that /// were opened via JavaScript. Also configurable using the /// "disable-javascript-close-windows" command-line switch. /// property CefState JavascriptCloseWindows { CefState get() { return (CefState)_browserSettings->javascript_close_windows; } void set(CefState value) { _browserSettings->javascript_close_windows = (cef_state_t)value; } } /// /// Controls whether JavaScript can access the clipboard. Also configurable /// using the "disable-javascript-access-clipboard" command-line switch. /// property CefState JavascriptAccessClipboard { CefState get() { return (CefState)_browserSettings->javascript_access_clipboard; } void set(CefState value) { _browserSettings->javascript_access_clipboard = (cef_state_t)value; } } /// /// Controls whether DOM pasting is supported in the editor via /// execCommand("paste"). The |javascript_access_clipboard| setting must also /// be enabled. Also configurable using the "disable-javascript-dom-paste" /// command-line switch. /// property CefState JavascriptDomPaste { CefState get() { return (CefState)_browserSettings->javascript_dom_paste; } void set(CefState value) { _browserSettings->javascript_dom_paste = (cef_state_t)value; } } /// /// Controls whether the caret position will be drawn. Also configurable using /// the "enable-caret-browsing" command-line switch. /// property CefState CaretBrowsing { CefState get() { return (CefState)_browserSettings->caret_browsing; } void set(CefState value) { _browserSettings->caret_browsing = (cef_state_t)value; } } /// /// Controls whether the Java plugin will be loaded. Also configurable using /// the "disable-java" command-line switch. /// property CefState Java { CefState get() { return (CefState)_browserSettings->java; } void set(CefState value) { _browserSettings->java = (cef_state_t)value; } } /// /// Controls whether any plugins will be loaded. Also configurable using the /// "disable-plugins" command-line switch. /// property CefState Plugins { CefState get() { return (CefState)_browserSettings->plugins; } void set(CefState value) { _browserSettings->plugins = (cef_state_t)value; } } /// /// Controls whether file URLs will have access to all URLs. Also configurable /// using the "allow-universal-access-from-files" command-line switch. /// property CefState UniversalAccessFromFileUrls { CefState get() { return (CefState)_browserSettings->universal_access_from_file_urls; } void set(CefState value) { _browserSettings->universal_access_from_file_urls = (cef_state_t)value; } } /// /// Controls whether file URLs will have access to other file URLs. Also /// configurable using the "allow-access-from-files" command-line switch. /// property CefState FileAccessFromFileUrls { CefState get() { return (CefState)_browserSettings->file_access_from_file_urls; } void set(CefState value) { _browserSettings->file_access_from_file_urls = (cef_state_t)value; } } /// /// Controls whether web security restrictions (same-origin policy) will be /// enforced. Disabling this setting is not recommend as it will allow risky /// security behavior such as cross-site scripting (XSS). Also configurable /// using the "disable-web-security" command-line switch. /// property CefState WebSecurity { CefState get() { return (CefState)_browserSettings->web_security; } void set(CefState value) { _browserSettings->web_security = (cef_state_t)value; } } /// /// Controls whether image URLs will be loaded from the network. A cached image /// will still be rendered if requested. Also configurable using the /// "disable-image-loading" command-line switch. /// property CefState ImageLoading { CefState get() { return (CefState)_browserSettings->image_loading; } void set(CefState value) { _browserSettings->image_loading = (cef_state_t)value; } } /// /// Controls whether standalone images will be shrunk to fit the page. Also /// configurable using the "image-shrink-standalone-to-fit" command-line /// switch. /// property CefState ImageShrinkStandaloneToFit { CefState get() { return (CefState)_browserSettings->image_shrink_standalone_to_fit; } void set(CefState value) { _browserSettings->image_shrink_standalone_to_fit = (cef_state_t)value; } } /// /// Controls whether text areas can be resized. Also configurable using the /// "disable-text-area-resize" command-line switch. /// property CefState TextAreaResize { CefState get() { return (CefState)_browserSettings->text_area_resize; } void set(CefState value) { _browserSettings->text_area_resize = (cef_state_t)value; } } /// /// Controls whether the tab key can advance focus to links. Also configurable /// using the "disable-tab-to-links" command-line switch. /// property CefState TabToLinks { CefState get() { return (CefState)_browserSettings->tab_to_links; } void set(CefState value) { _browserSettings->tab_to_links = (cef_state_t)value; } } /// /// Controls whether local storage can be used. Also configurable using the /// "disable-local-storage" command-line switch. /// property CefState LocalStorage { CefState get() { return (CefState)_browserSettings->local_storage; } void set(CefState value) { _browserSettings->local_storage = (cef_state_t)value; } } /// /// Controls whether databases can be used. Also configurable using the /// "disable-databases" command-line switch. /// property CefState Databases { CefState get() { return (CefState)_browserSettings->databases; } void set(CefState value) { _browserSettings->databases = (cef_state_t)value; } } /// /// Controls whether the application cache can be used. Also configurable using /// the "disable-application-cache" command-line switch. /// property CefState ApplicationCache { CefState get() { return (CefState)_browserSettings->application_cache; } void set(CefState value) { _browserSettings->application_cache = (cef_state_t)value; } } /// /// Controls whether WebGL can be used. Note that WebGL requires hardware /// support and may not work on all systems even when enabled. Also /// configurable using the "disable-webgl" command-line switch. /// property CefState WebGl { CefState get() { return (CefState)_browserSettings->webgl; } void set(CefState value) { _browserSettings->webgl = (cef_state_t)value; } } /// /// Opaque background color used for the browser before a document is loaded /// and when no document color is specified. By default the background color /// will be the same as CefSettings.background_color. Only the RGB compontents /// of the specified value will be used. The alpha component must greater than /// 0 to enable use of the background color but will be otherwise ignored. /// property uint32 BackgroundColor { uint32 get() { return _browserSettings->background_color; } void set(uint32 value) { _browserSettings->background_color = value; } } /// /// Comma delimited ordered list of language codes without any whitespace that /// will be used in the "Accept-Language" HTTP header. May be overridden on a /// per-browser basis using the CefBrowserSettings.AcceptLanguageList value. /// If both values are empty then "en-US,en" will be used. Can be overridden /// for individual RequestContext instances via the /// RequestContextSettings.AcceptLanguageList value. /// virtual property String^ AcceptLanguageList { String^ get() { return StringUtils::ToClr(_browserSettings->accept_language_list); } void set(String^ value) { StringUtils::AssignNativeFromClr(_browserSettings->accept_language_list, value); } } property Nullable OffScreenTransparentBackground; }; }