private void PropWebSecurity_Checked(object sender, EventArgs eventArgs) { _webSecurity = BooleanToCefState(PropWebSecurity.IsChecked != null && PropWebSecurity.IsChecked.Value); Browser.BrowserSettings.WebSecurity = _webSecurity; settings.Set("WebSecurity", _webSecurity); }
private void PropJavascriptCloseWindows_Checked(object sender, EventArgs eventArgs) { _javascriptCloseWindows = BooleanToCefState( PropJavascriptCloseWindows.IsChecked != null && PropJavascriptCloseWindows.IsChecked.Value); Browser.BrowserSettings.JavascriptCloseWindows = _javascriptCloseWindows; settings.Set("JavascriptCloseWindows", _javascriptCloseWindows); }
private void PropJavascriptAccessClipboard_Checked(object sender, EventArgs eventArgs) { _javascriptAccessClipboard = BooleanToCefState( PropJavascriptAccessClipboard.IsChecked != null && PropJavascriptAccessClipboard.IsChecked.Value); Browser.BrowserSettings.JavascriptAccessClipboard = _javascriptAccessClipboard; settings.Set("JavascriptAccessClipboard", _javascriptAccessClipboard); }
private void PropLocalStorage_Checked(object sender, EventArgs eventArgs) { _localStorage = BooleanToCefState( PropLocalStorage.IsChecked != null && PropLocalStorage.IsChecked.Value); Browser.BrowserSettings.LocalStorage = _localStorage; settings.Set("LocalStorage", _localStorage); }
private void PropDatabases_Checked(object sender, EventArgs eventArgs) { _databases = BooleanToCefState( PropDatabases.IsChecked != null && PropDatabases.IsChecked.Value); Browser.BrowserSettings.Databases = _databases; settings.Set("Databases", _databases); }
private void PropApplicationCache_Checked(object sender, EventArgs eventArgs) { _applicationCache = BooleanToCefState( PropApplicationCache.IsChecked != null && PropApplicationCache.IsChecked.Value); Browser.BrowserSettings.ApplicationCache = _applicationCache; settings.Set("ApplicationCache", _applicationCache); }
private void PropPlugins_Checked(object sender, EventArgs eventArgs) { _plugins = BooleanToCefState( PropPlugins.IsChecked != null && PropPlugins.IsChecked.Value); Browser.BrowserSettings.Plugins = _plugins; settings.Set("Plugins", _plugins); }
private void PropLoadImages_Checked(object sender, EventArgs eventArgs) { _loadImages = BooleanToCefState( PropLoadImages.IsChecked != null && PropLoadImages.IsChecked.Value); Browser.BrowserSettings.ImageLoading = _loadImages; settings.Set("ImageLoading", _loadImages); }
private void PropFileAccessFromFileUrls_Checked(object sender, EventArgs eventArgs) { _fileAccessFromFileUrls = BooleanToCefState( PropFileAccessFromFileUrls.IsChecked != null && PropFileAccessFromFileUrls.IsChecked.Value); Browser.BrowserSettings.FileAccessFromFileUrls = _fileAccessFromFileUrls; settings.Set("FileAccessFromFileUrls", _fileAccessFromFileUrls); }
private void PropPropJavascript_Checked(object sender, EventArgs eventArgs) { _javascript = BooleanToCefState( PropJavascript.IsChecked != null && PropJavascript.IsChecked.Value); Browser.BrowserSettings.Javascript = _javascript; settings.Set("Javascript", _javascript); }
public void Set(string key, CefState value) { foreach (var setting in Settings) { if (Equals(setting.Key, key)) { setting.Value = value; return; } } Settings.Add(new KeyValItem() { Key = key, Value = value }); }
public CefState GetOrDefault(string key, CefState defaultValue) { foreach (var setting in Settings) { if (Equals(setting.Key, key)) { return(setting.Value); } } Settings.Add(new KeyValItem() { Key = key, Value = defaultValue }); return(defaultValue); }
/** * CefState is 0-2 value: true, false or default. Since we are * going for simplistic approach here this can be simplified * to a boolean true or false value.. */ public bool CefStateToBoolean(CefState state) { switch (state) { case CefState.Default: return(false); case CefState.Enabled: return(true); case CefState.Disabled: return(false); default: return(false); } }
/// <summary> /// Set accessibility state for all frames. |accessibility_state| may be /// default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT /// then accessibility will be disabled by default and the state may be further /// controlled with the "force-renderer-accessibility" and /// "disable-renderer-accessibility" command-line switches. If /// |accessibility_state| is STATE_ENABLED then accessibility will be enabled. /// If |accessibility_state| is STATE_DISABLED then accessibility will be /// completely disabled. /// For windowed browsers accessibility will be enabled in Complete mode (which /// corresponds to kAccessibilityModeComplete in Chromium). In this mode all /// platform accessibility objects will be created and managed by Chromium's /// internal implementation. The client needs only to detect the screen reader /// and call this method appropriately. For example, on macOS the client can /// handle the @"AXEnhancedUserInterface" accessibility attribute to detect /// VoiceOver state changes and on Windows the client can handle WM_GETOBJECT /// with OBJID_CLIENT to detect accessibility readers. /// For windowless browsers accessibility will be enabled in TreeOnly mode /// (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In /// this mode renderer accessibility is enabled, the full tree is computed, and /// events are passed to CefAccessibiltyHandler, but platform accessibility /// objects are not created. The client may implement platform accessibility /// objects using CefAccessibiltyHandler callbacks if desired. /// </summary> public void SetAccessibilityState(CefState accessibilityState) { BrowserHost?.SetAccessibilityState(accessibilityState); }
public unsafe extern void SetAccessibilityState(CefState accessibility_state);
/// <summary> /// Set accessibility state for all frames. |accessibility_state| may be /// default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT /// then accessibility will be disabled by default and the state may be further /// controlled with the "force-renderer-accessibility" and "disable-renderer- /// accessibility" command-line switches. If |accessibility_state| is /// STATE_ENABLED then accessibility will be enabled. If |accessibility_state| /// is STATE_DISABLED then accessibility will be completely disabled. /// For windowed browsers accessibility will be enabled in Complete mode (which /// corresponds to kAccessibilityModeComplete in Chromium). In this mode all /// platform accessibility objects will be created and managed by Chromium's /// internal implementation. The client needs only to detect the screen reader /// and call this function appropriately. For example, on macOS the client can /// handle the /// " /// AXEnhancedUserStructure" accessibility attribute to detect /// VoiceOver state changes and on Windows the client can handle WM_GETOBJECT /// with OBJID_CLIENT to detect accessibility readers. /// For windowless browsers accessibility will be enabled in TreeOnly mode /// (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In /// this mode renderer accessibility is enabled, the full tree is computed, and /// events are passed to CefAccessibiltyHandler, but platform accessibility /// objects are not created. The client may implement platform accessibility /// objects using CefAccessibiltyHandler callbacks if desired. /// </summary> public unsafe virtual void SetAccessibilityState(CefState accessibilityState) { NativeInstance->SetAccessibilityState(accessibilityState); GC.KeepAlive(this); }
public MainWindow(bool invalidApp) { InitializeComponent(); #region Browser Handlers settings = new SettingsHelper(); downloadHandler = new DownloadHandler(); _browserSettings = new BrowserSettings(); Browser.DownloadHandler = downloadHandler; Browser.LifeSpanHandler = new LifespanHandler(); Browser.RequestHandler = new RequestHandler(); Browser.MenuHandler = new ContextMenuHandler(); Browser.JsDialogHandler = new JsDialogHandler(); Browser.RequestContext = new RequestContext(new RequestContextHandler()); Downloads.ItemsSource = filesDownloading; #endregion #region Browser Events Browser.TitleChanged += Browser_TitleChanged; Browser.FrameLoadEnd += Browser_FrameLoadEnd; Browser.LoadError += Browser_LoadError; downloadHandler.OnDownloadItemUpdated += DownloadHandlerOnOnDownloadItemUpdated; #endregion #region Load User Settings _webSecurity = settings.GetOrDefault("WebSecurity", CefState.Enabled); _applicationCache = settings.GetOrDefault("ApplicationCache", CefState.Disabled); _databases = settings.GetOrDefault("Databases", CefState.Disabled); _localStorage = settings.GetOrDefault("LocalStorage", CefState.Disabled); _javascript = settings.GetOrDefault("Javascript", CefState.Enabled); _javascriptAccessClipboard = settings.GetOrDefault("JavascriptAccessClipboard", CefState.Disabled); _javascriptCloseWindows = settings.GetOrDefault("JavascriptCloseWindows", CefState.Disabled); _fileAccessFromFileUrls = settings.GetOrDefault("FileAccessFromFileUrls", CefState.Disabled); _plugins = settings.GetOrDefault("Plugins", CefState.Disabled); _loadImages = settings.GetOrDefault("LoadImages", CefState.Enabled); _windowlessFrameRate = 60; #endregion #region Command Line Parser Parser.Default.ParseArguments <Options>(Environment.GetCommandLineArgs()).WithParsed(options => { Browser.Address = (string.IsNullOrEmpty(options.OpenUrl)) ? Settings.Default.Home : options.OpenUrl; if (options.App && !invalidApp) { _webSecurity = CefState.Enabled; _applicationCache = CefState.Enabled; _databases = CefState.Enabled; _localStorage = CefState.Enabled; _javascript = CefState.Enabled; _javascriptAccessClipboard = CefState.Enabled; _javascriptCloseWindows = CefState.Enabled; _fileAccessFromFileUrls = CefState.Disabled; _plugins = CefState.Disabled; _loadImages = CefState.Enabled; _forceSingleWindow = true; _appMode = true; C_BTN_Main.Visibility = Visibility.Collapsed; C_BTN_Back.Visibility = Visibility.Collapsed; C_BTN_Refresh.Visibility = Visibility.Collapsed; C_BTN_Forward.Visibility = Visibility.Collapsed; C_BTN_Settings.Visibility = Visibility.Collapsed; C_BTN_MakeApp.Visibility = Visibility.Collapsed; _appMode = true; } }); #endregion #region Browser Defaults _browserSettings.WebSecurity = _webSecurity; _browserSettings.ApplicationCache = _applicationCache; _browserSettings.Databases = _databases; _browserSettings.LocalStorage = _localStorage; _browserSettings.Javascript = _javascript; _browserSettings.JavascriptAccessClipboard = _javascriptAccessClipboard; _browserSettings.JavascriptCloseWindows = _javascriptCloseWindows; _browserSettings.FileAccessFromFileUrls = _fileAccessFromFileUrls; _browserSettings.Plugins = _plugins; _browserSettings.ImageLoading = _loadImages; _browserSettings.WindowlessFrameRate = _windowlessFrameRate; Browser.BrowserSettings = _browserSettings; PropWebSecurity.IsChecked = CefStateToBoolean(_webSecurity); PropApplicationCache.IsChecked = CefStateToBoolean(_applicationCache); PropDatabases.IsChecked = CefStateToBoolean(_databases); PropLocalStorage.IsChecked = CefStateToBoolean(_localStorage); PropJavascript.IsChecked = CefStateToBoolean(_javascript); PropJavascriptAccessClipboard.IsChecked = CefStateToBoolean(_javascriptAccessClipboard); PropJavascriptCloseWindows.IsChecked = CefStateToBoolean(_javascriptCloseWindows); PropFileAccessFromFileUrls.IsChecked = CefStateToBoolean(_fileAccessFromFileUrls); PropPlugins.IsChecked = CefStateToBoolean(_plugins); PropLoadImages.IsChecked = CefStateToBoolean(_loadImages); #endregion updateTimer = new Timer() { Enabled = invalidApp, Interval = 350 }; updateTimer.Tick += UpdateTimer_Tick; }