mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
44fdfa94c8
* JSB Rewrite - Add CefSharp.RegisterBoundObject javascript method To get around the problem of IPC timing, I've reversed the communication, now it's the render process requesting the bound objects, the implementation is incomplete at this stage, more just a basic proof of concept Rewrite BindingTest.html using QUnit One of the tests doesn't map correctly as it requires def user interaction TODO: - Get objects by name - Rename Messages.h values that relate to this change so they are more descriptive - Better error handling - Caching of objects within a render process - Investigate global context options, don't think it's possible to call an async method directly in the global context # Conflicts: # CefSharp.Example/Resources/BindingTest.html * JSB Improve Request/Response message names * BindingTest.html - Output stress test results * Remove JavascriptRootObject was leftover from time we used WCF to transmit objects * JavascriptObjectRepository - Objects are now sent in the same list with an IsAsync flag Separation when sending over IPC with two unique lists isn't necessary * JavascriptObjectRepository - Return objects by name or return all by default Untabify CefAppUnmanagedWrapper.cpp Add minor comment to CefBrowserWrapper for a reminder that we use Frame Identifier as dictionary key * Add //TODO: JSB comments for work that's left to be done Ideally within a render process we cache bound objects once they've been communicated, It would also be nice to make multiple binding requests so objects can later be added dynamically * JSB Allow multiple calls to CefSharp.RegisterBoundObject Update BindingTest.html to name two distinct calls to different bound objects * JSB - Add some notes about caching, no working implementation yet * JSB - Dynamically Register object on Request * JSB Add ability to unbind an object and rename RegisterBoundObject to BindObjectAsync # Conflicts: # CefSharp.Example/Resources/BindingTest.html * JSB BindObjectAsync - if objects already bound then return false * JSB - Ignore Indexer properties Were previously throwing an exception * JSB - Add LegacyJavascriptBindingEnabled option so preserve existing behaviour This is only useful for SPA application and those that only navigate to pages hosting within a single domain. Any sort of cross-site navigation and a new render process will be spawned and objects won't be bound automatically (You can use the new methods to request they're bound yourself, at least in theory, more testing required on this) * Add LegacyBindingTest.html Current disabled by default. To enable uncomment CefSharpSettings.LegacyJavascriptBindingEnabled = true; in CefExample.cs * RegisterJsObject and RegisterAsyncJsObject can now only be used when CefSharpSettings.LegacyJavascriptBindingEnabled = true See https://github.com/cefsharp/CefSharp/issues/2246 for details
92 lines
4.6 KiB
C#
92 lines
4.6 KiB
C#
// Copyright © 2010-2017 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.
|
|
|
|
using System;
|
|
|
|
namespace CefSharp
|
|
{
|
|
/// <summary>
|
|
/// Use this static class to configure some CefSharp specific settings like WcfTimeout
|
|
/// </summary>
|
|
public static class CefSharpSettings
|
|
{
|
|
/// <summary>
|
|
/// Set default values for CefSharpSettings
|
|
/// </summary>
|
|
static CefSharpSettings()
|
|
{
|
|
ShutdownOnExit = true;
|
|
LegacyJavascriptBindingEnabled = false;
|
|
WcfTimeout = TimeSpan.FromSeconds(2);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Objects registered using RegisterJsObject and RegisterAsyncJsObject
|
|
/// will be automatically bound in the first render process that's created
|
|
/// for a ChromiumWebBrowser instance. If you perform a cross-site
|
|
/// navigation a process switch will occur and bound objects will no longer
|
|
/// be automatically avaliable. For those upgrading from version 57 or below
|
|
/// that do no perform cross-site navigation (e.g. Single Page applications or
|
|
/// applications that only refer to a single domain) can set this property to
|
|
/// true and use the old behaviour.Defaults to false
|
|
/// NOTE: Set this before your first call to RegisterJsObject or RegisterAsyncJsObject
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Javascript binding in CefSharp version 57 and below used the
|
|
/// --process-per-tab Process Model to limit the number of render
|
|
/// processes to 1 per ChromiumWebBrowser instance, this allowed
|
|
/// us to communicate bound javascript objects when the process was
|
|
/// initially created (OnRenderViewReady is only called for the first
|
|
/// process creation or after a crash), subsiquently all bound objects
|
|
/// were registered in ever V8Context in OnContextCreated (executed in the render process).
|
|
/// Chromium has made changes and --process-per-tab is not currently working.
|
|
/// Performing a cross-site navigation (from one domain to a different domain)
|
|
/// will cause a new render process to be created, subsiquent render processes
|
|
/// won't have access to the bound object information by default.
|
|
/// </remarks>
|
|
public static bool LegacyJavascriptBindingEnabled { get; set; }
|
|
|
|
/// <summary>
|
|
/// WCF is used by RegisterJsObject feature for Javascript Binding
|
|
/// It's reccomended that anyone developing a new application use
|
|
/// the RegisterAsyncJsObject version which communicates using native
|
|
/// Chromium IPC.
|
|
/// </summary>
|
|
public static bool WcfEnabled { get; set; }
|
|
|
|
/// <summary>
|
|
/// Change the Close timeout for the WCF channel used by the sync JSB binding.
|
|
/// The default value is currently 2 seconds. Changing this to <see cref="TimeSpan.Zero"/>
|
|
/// will result on Abort() being called on the WCF Channel Host
|
|
/// </summary>
|
|
public static TimeSpan WcfTimeout { get; set; }
|
|
|
|
/// <summary>
|
|
/// For the WinForms and WPF instances of ChromiumWebBrowser the relevant Application Exit event
|
|
/// is hooked and Cef.Shutdown() called by default. Set this to false to disable this behaviour.
|
|
/// This value needs to be set before the first instance of ChromiumWebBrowser is created as
|
|
/// the event handlers are hooked in the static constructor for the ChromiumWebBrowser class
|
|
/// </summary>
|
|
public static bool ShutdownOnExit { get; set; }
|
|
|
|
/// <summary>
|
|
/// The proxy options that will be used for all connections
|
|
///
|
|
/// If set before the call to Cef.Initialize, command line arguments will be set for you
|
|
/// If a username and password is provided and the IPs match authentication is done automatically
|
|
///
|
|
/// NOTE: GetAuthCredentials won't be called for a proxy server that matches the IP
|
|
/// NOTE: It isn't possble to change the proxy after the call to Cef.Initialize
|
|
/// </summary>
|
|
public static ProxyOptions Proxy { get; set; }
|
|
|
|
/// <summary>
|
|
/// This influences the behavior of RegisterAsyncJsObject and how method calls are made.
|
|
/// By default the <see cref="MethodRunnerQueue"/> executes Tasks in a sync fashion.
|
|
/// Setting this property to true will allocate new Tasks on TaskScheduler.Default for execution.
|
|
/// </summary>
|
|
public static bool ConcurrentTaskExecution { get; set; }
|
|
}
|
|
}
|