-
Notifications
You must be signed in to change notification settings - Fork 277
Configuration
Most required Cef configuration is done via ChromelyConfiguration class. ChromelyConfiguration provides default values that can be used as-is or set new properties.
The followings are configured:
CefAppArgs - Cef app arguments
CefStartUrl - Cef start url
CefHostWidth - Cef start width
CefHostHeight - Cef start height
CefLogSeverity - Cef log severity
CefLogFile - Cef log file
Use default logger or set a new one
Use default IOC container or set a new one
Registration of custom url schemes
Registration of external url schemes
Registration of custom scheme handlers
Registration of custom Javascript objects
ChromelyConfiguration is fluently set. Sample Configuration:
ChromelyConfiguration config = ChromelyConfiguration
.Create()
.WithCefAppArgs(args)
.WithCefHostSize(1200, 900)
.WithCefLogFile("logs\\chromely.cef_new.log")
.WithCefStartUrl(startUrl)
.WithCefLogSeverity(LogSeverity.Info)
.UseDefaultLogger("logs\\chromely_new.log", true)
.RegisterSchemeHandler("http", "chromely.com", new CefGlueSchemeHandlerFactory());
Chromely provides a simple default logger. This can be set in the configuration. The default file can be changed and also if the logs can also be written to the console.
ChromelyConfiguration config = ChromelyConfiguration
.Create()
.....
.UseDefaultLogger("logs\\chromely_new.log", true)
....
A new logger (of type IChromelyLogger) can be set.
IChromelyLogger logger = new NewLogger();
ChromelyConfiguration config = ChromelyConfiguration
.Create()
....
.WithLogger(logger)
....
A new IOC container (of type IChromelyContainer) can be set prior to setting the configuration object or set passing via constructor (create). *** This must be done prior to other registrations otherwise the default container will kick in during these registrations and will be lost (invalid). ONLY one IOC container is required.
// The IOC container must implement the IChromelyContainer interface.
IChromelyContainer newContainer = new CustomContainer();
IoC.Container = newContainer;
Or:
// The IOC container must implement the IChromelyContainer interface.
IChromelyContainer newContainer = new CustomContainer();
ChromelyConfiguration config = ChromelyConfiguration()
.Create(newContainer)
.....
Custom url schemes can be just custom (can be used as developer pleases) or custom external urls. External urls are urls opened by the default browser - externally to Chromely (e.g - www.google.com). For more on external url registration see - External Url Registration. One or more custom url schemes can be registered with:
ChromelyConfiguration config = ChromelyConfiguration()
.Create()
....
.RegisterCustomrUrlScheme("http", "chromely.com")
.RegisterCustomrUrlScheme("test", "test.com")
.RegisterExternaleUrlScheme("https", "google.com")
.RegisterExternaleUrlScheme("https", "https://github.com/mattkol/Chromely")
.....
For more on custom scheme handling registration see - Custom Scheme Handling.
One or more custom scheme handlers can be registered with:
ChromelyConfiguration config = ChromelyConfiguration()
.Create()
....
.RegisterSchemeHandler("http", "chromely.com", new CefGlueSchemeHandlerFactory())
.RegisterSchemeHandler("http", "chromely2.com", new CustomSchemeHandlerFactory())
.....
For more on custom Javascript objects registration see - Custom Javascript Object.
One or more custom scheme handlers can be registered with:
ChromelyConfiguration config = ChromelyConfiguration()
.Create()
....
.RegisterJsHandler("boundControllerAsync", new CefSharpBoundObject(), null, true);
.RegisterJsHandler("boundControllerAsync2", new NewCefSharpBoundObject(), null, true);
.....
Chromely
Getting Started
Networking
Resources
Debugging
Detailed documentation on:
- Getting Started
- Configuring Chromely
- Loading Html
- Resource Handling
- Configuring Message Routing
- Register Ajax/XHR Handlers
- JavaScript Execution
- Scheme Registration
- Scheme Handlers
- Custom Http Handlers
- How to use commands
- Custom CEF Handlers
- Chromely on Raspberry Pi
- How to use app settings
- CEF binaries download
- Using DevTools