mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
2572715407
* Core - Add IApp interface and DefaultApp implementation Move code from Cef.Initialize into CefSharpApp Working towards #2139 * CefSharpApp.h - Allow CefCustomScheme->SchemeHandlerFactory to be null If cefCustomScheme->SchemeHandlerFactory is null then we no longer attempt to call CefRegisterSchemeHandlerFactory You can then choose which RequestContext you wish to register your handler for, no longer forcing you to register in the global context Remove null checks in OnScheduleMessagePumpWork as we're throwing an exception if they're null when the CefApp is created
50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
// Copyright © 2019 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.Collections.Generic;
|
|
|
|
namespace CefSharp
|
|
{
|
|
/// <summary>
|
|
/// Default implementation of <see cref="IApp"/> which represents the CefApp class
|
|
/// </summary>
|
|
public class DefaultApp : IApp
|
|
{
|
|
public IBrowserProcessHandler BrowserProcessHandler { get; private set; }
|
|
public IEnumerable<CefCustomScheme> Schemes { get; private set; }
|
|
|
|
public DefaultApp(IBrowserProcessHandler browserProcessHandler, IEnumerable<CefCustomScheme> schemes)
|
|
{
|
|
BrowserProcessHandler = browserProcessHandler;
|
|
Schemes = schemes;
|
|
}
|
|
|
|
void IApp.OnRegisterCustomSchemes(ISchemeRegistrar registrar)
|
|
{
|
|
OnRegisterCustomSchemes(registrar);
|
|
}
|
|
|
|
protected void OnRegisterCustomSchemes(ISchemeRegistrar registrar)
|
|
{
|
|
foreach (var scheme in Schemes)
|
|
{
|
|
//We don't need to register http or https, they're built in schemes
|
|
if (scheme.SchemeName == "http" || scheme.SchemeName == "https")
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var success = registrar.AddCustomScheme(scheme.SchemeName, scheme.IsStandard, scheme.IsLocal, scheme.IsDisplayIsolated, scheme.IsSecure, scheme.IsCorsEnabled, scheme.IsCSPBypassing);
|
|
|
|
if (!success)
|
|
{
|
|
var msg = "CefSchemeRegistrar::AddCustomScheme failed for schemeName:" + scheme.SchemeName;
|
|
//TODO: Log error
|
|
//LOG(ERROR) << StringUtils::ToNative(msg).ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|