diff --git a/CefSharp.Core/BrowserSettings.h b/CefSharp.Core/BrowserSettings.h
index 593948ff7..cac8b1b08 100644
--- a/CefSharp.Core/BrowserSettings.h
+++ b/CefSharp.Core/BrowserSettings.h
@@ -11,6 +11,12 @@ 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:
@@ -87,195 +93,241 @@ namespace CefSharp
{
int get() { return _browserSettings->minimum_logical_font_size; }
void set(int value) { _browserSettings->minimum_logical_font_size = value; }
- }
-
- property Nullable^ RemoteFontsDisabled
- {
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->remote_fonts); }
- void set(Nullable^ value) { _browserSettings->remote_fonts = CefStateFromDisabledSetting(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); }
}
- property Nullable^ JavascriptDisabled
+ ///
+ /// Controls the loading of fonts from remote sources. Also configurable using
+ /// the "disable-remote-fonts" command-line switch.
+ ///
+ property CefState RemoteFonts
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->javascript); }
- void set(Nullable^ value) { _browserSettings->javascript = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->remote_fonts; }
+ void set(CefState value) { _browserSettings->remote_fonts = (cef_state_t)value; }
}
- property Nullable^ JavaScriptOpenWindowsDisabled
+ ///
+ /// Controls whether JavaScript can be executed. Also configurable using the
+ /// "disable-javascript" command-line switch.
+ ///
+ property CefState Javascript
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->javascript_open_windows); }
- void set(Nullable^ value) { _browserSettings->javascript_open_windows = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->javascript; }
+ void set(CefState value) { _browserSettings->javascript = (cef_state_t)value; }
}
- property Nullable^ JavaScriptCloseWindowsDisabled
+ ///
+ /// Controls whether JavaScript can be used for opening windows. Also
+ /// configurable using the "disable-javascript-open-windows" command-line
+ /// switch.
+ ///
+ property CefState JavascriptOpenWindows
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->javascript_close_windows); }
- void set(Nullable^ value) { _browserSettings->javascript_close_windows = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->javascript_open_windows; }
+ void set(CefState value) { _browserSettings->javascript_open_windows = (cef_state_t)value; }
}
- property Nullable^ JavaScriptAccessClipboardDisabled
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->javascript_access_clipboard); }
- void set(Nullable^ value) { _browserSettings->javascript_access_clipboard = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->javascript_close_windows; }
+ void set(CefState value) { _browserSettings->javascript_close_windows = (cef_state_t)value; }
}
- property Nullable^ JavascriptDomPasteDisabled
+ ///
+ /// Controls whether JavaScript can access the clipboard. Also configurable
+ /// using the "disable-javascript-access-clipboard" command-line switch.
+ ///
+ property CefState JavascriptAccessClipboard
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->javascript_dom_paste); }
- void set(Nullable^ value) { _browserSettings->javascript_dom_paste = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->javascript_access_clipboard; }
+ void set(CefState value) { _browserSettings->javascript_access_clipboard = (cef_state_t)value; }
}
- property Nullable^ CaretBrowsingEnabled
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToEnabledSetting(_browserSettings->caret_browsing); }
- void set(Nullable^ value) { _browserSettings->caret_browsing = CefStateFromEnabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->javascript_dom_paste; }
+ void set(CefState value) { _browserSettings->javascript_dom_paste = (cef_state_t)value; }
}
- property Nullable^ JavaDisabled
+ ///
+ /// Controls whether the caret position will be drawn. Also configurable using
+ /// the "enable-caret-browsing" command-line switch.
+ ///
+ property CefState CaretBrowsing
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->java); }
- void set(Nullable^ value) { _browserSettings->java = CefStateFromDisabledSetting(value); }
+ 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; }
}
- property Nullable^ PluginsDisabled
+ ///
+ /// Controls whether any plugins will be loaded. Also configurable using the
+ /// "disable-plugins" command-line switch.
+ ///
+ property CefState Plugins
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->plugins); }
- void set(Nullable^ value) { _browserSettings->plugins = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->plugins; }
+ void set(CefState value) { _browserSettings->plugins = (cef_state_t)value; }
}
- property Nullable^ UniversalAccessFromFileUrlsAllowed
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToEnabledSetting(_browserSettings->universal_access_from_file_urls); }
- void set(Nullable^ value) { _browserSettings->universal_access_from_file_urls = CefStateFromEnabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->universal_access_from_file_urls; }
+ void set(CefState value) { _browserSettings->universal_access_from_file_urls = (cef_state_t)value; }
}
- property Nullable^ FileAccessFromFileUrlsAllowed
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToEnabledSetting(_browserSettings->file_access_from_file_urls); }
- void set(Nullable^ value) { _browserSettings->file_access_from_file_urls = CefStateFromEnabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->file_access_from_file_urls; }
+ void set(CefState value) { _browserSettings->file_access_from_file_urls = (cef_state_t)value; }
}
- property Nullable^ WebSecurityDisabled
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->web_security); }
- void set(Nullable^ value) { _browserSettings->web_security = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->web_security; }
+ void set(CefState value) { _browserSettings->web_security = (cef_state_t)value; }
}
- property Nullable^ ImageLoadingDisabled
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->image_loading); }
- void set(Nullable^ value) { _browserSettings->image_loading = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->image_loading; }
+ void set(CefState value) { _browserSettings->image_loading = (cef_state_t)value; }
}
- property Nullable^ ImageShrinkStandaloneToFitEnabled
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToEnabledSetting(_browserSettings->image_shrink_standalone_to_fit); }
- void set(Nullable^ value) { _browserSettings->image_shrink_standalone_to_fit= CefStateFromEnabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->image_shrink_standalone_to_fit; }
+ void set(CefState value) { _browserSettings->image_shrink_standalone_to_fit = (cef_state_t)value; }
}
- property Nullable^ TextAreaResizeDisabled
+ ///
+ /// Controls whether text areas can be resized. Also configurable using the
+ /// "disable-text-area-resize" command-line switch.
+ ///
+ property CefState TextAreaResize
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->text_area_resize); }
- void set(Nullable^ value) { _browserSettings->text_area_resize = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->text_area_resize; }
+ void set(CefState value) { _browserSettings->text_area_resize = (cef_state_t)value; }
}
- property Nullable^ TabToLinksDisabled
+ ///
+ /// Controls whether the tab key can advance focus to links. Also configurable
+ /// using the "disable-tab-to-links" command-line switch.
+ ///
+ property CefState TabToLinks
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->tab_to_links); }
- void set(Nullable^ value) { _browserSettings->tab_to_links = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->tab_to_links; }
+ void set(CefState value) { _browserSettings->tab_to_links = (cef_state_t)value; }
}
- property Nullable^ LocalStorageDisabled
+ ///
+ /// Controls whether local storage can be used. Also configurable using the
+ /// "disable-local-storage" command-line switch.
+ ///
+ property CefState LocalStorage
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->local_storage); }
- void set(Nullable^ value) { _browserSettings->local_storage = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->local_storage; }
+ void set(CefState value) { _browserSettings->local_storage = (cef_state_t)value; }
}
- property Nullable^ DatabasesDisabled
+ ///
+ /// Controls whether databases can be used. Also configurable using the
+ /// "disable-databases" command-line switch.
+ ///
+ property CefState Databases
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->databases); }
- void set(Nullable^ value) { _browserSettings->databases = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->databases; }
+ void set(CefState value) { _browserSettings->databases = (cef_state_t)value; }
}
- property Nullable^ ApplicationCacheDisabled
+ ///
+ /// Controls whether the application cache can be used. Also configurable using
+ /// the "disable-application-cache" command-line switch.
+ ///
+ property CefState ApplicationCache
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->application_cache); }
- void set(Nullable^ value) { _browserSettings->application_cache = CefStateFromDisabledSetting(value); }
+ CefState get() { return (CefState)_browserSettings->application_cache; }
+ void set(CefState value) { _browserSettings->application_cache = (cef_state_t)value; }
}
- property Nullable^ WebGlDisabled
+ ///
+ /// 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
{
- Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->webgl); }
- void set(Nullable^ value) { _browserSettings->webgl = CefStateFromDisabledSetting(value); }
+ 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; }
+ }
- property Nullable^ OffScreenTransparentBackground;
-
- private:
- Nullable CefStateToDisabledSetting(cef_state_t state)
- {
- if (state == STATE_ENABLED)
- {
- return Nullable(false);
- }
- else if (state == STATE_DISABLED)
- {
- return Nullable(true);
- }
- return Nullable();
- }
-
- cef_state_t CefStateFromDisabledSetting(Nullable^ value)
- {
- if (value == nullptr)
- {
- return STATE_DEFAULT;
- }
- else if (value->Value)
- {
- return STATE_DISABLED;
- }
- else // !value->Value
- {
- return STATE_ENABLED;
- }
- return STATE_DEFAULT;
- }
-
- Nullable CefStateToEnabledSetting(cef_state_t state)
- {
- if (state == STATE_ENABLED)
- {
- return Nullable(true);
- }
- else if (state == STATE_DISABLED)
- {
- return Nullable(false);
- }
- return Nullable();
- }
-
- cef_state_t CefStateFromEnabledSetting(Nullable^ value)
- {
- if (value == nullptr)
- {
- return STATE_DEFAULT;
- }
- else if (value->Value)
- {
- return STATE_ENABLED;
- }
- else // !value->Value
- {
- return STATE_DISABLED;
- }
- return STATE_DEFAULT;
- }
+ property Nullable OffScreenTransparentBackground;
};
}
\ No newline at end of file
diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.cpp b/CefSharp.Core/ManagedCefBrowserAdapter.cpp
index 68c4d39fe..b447e613f 100644
--- a/CefSharp.Core/ManagedCefBrowserAdapter.cpp
+++ b/CefSharp.Core/ManagedCefBrowserAdapter.cpp
@@ -16,7 +16,7 @@ void ManagedCefBrowserAdapter::CreateOffscreenBrowser(IntPtr windowHandle, Brows
auto hwnd = static_cast(windowHandle.ToPointer());
CefWindowInfo window;
- auto transparent = browserSettings->OffScreenTransparentBackground->GetValueOrDefault(true);
+ auto transparent = browserSettings->OffScreenTransparentBackground.GetValueOrDefault(true);
window.SetAsWindowless(hwnd, transparent);
CefString addressNative = StringUtils::ToNative(address);
diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj
index 99318ad16..1b20f23c0 100644
--- a/CefSharp/CefSharp.csproj
+++ b/CefSharp/CefSharp.csproj
@@ -94,6 +94,7 @@
+
diff --git a/CefSharp/CefState.cs b/CefSharp/CefState.cs
new file mode 100644
index 000000000..f03a883d7
--- /dev/null
+++ b/CefSharp/CefState.cs
@@ -0,0 +1,22 @@
+// 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.
+
+namespace CefSharp
+{
+ public enum CefState
+ {
+ ///
+ /// Use the default state for the setting.
+ ///
+ Default = 0,
+ ///
+ /// Enable or allow the setting.
+ ///
+ Enabled,
+ ///
+ /// Disable or disallow the setting.
+ ///
+ Disabled,
+ }
+}