Add project

This commit is contained in:
Diamond Creeper 2023-02-20 23:24:10 +13:00
commit 7fcb279842
961 changed files with 370491 additions and 0 deletions

View file

@ -0,0 +1,153 @@
// Copyright © 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;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CefSharp
{
/// <summary>
/// Async extensions for different interfaces
/// </summary>
public static class AsyncExtensions
{
/// <summary>
/// Deletes all cookies that matches all the provided parameters asynchronously.
/// If both <paramref name="url"/> and <paramref name="name"/> are empty, all cookies will be deleted.
/// </summary>
/// <param name="cookieManager">cookie manager</param>
/// <param name="url">The cookie URL. If an empty string is provided, any URL will be matched.</param>
/// <param name="name">The name of the cookie. If an empty string is provided, any URL will be matched.</param>
/// <returns>Returns -1 if a non-empty invalid URL is specified, or if cookies cannot be accessed;
/// otherwise, a task that represents the delete operation. The value of the TResult will be the number of cookies that were deleted or -1 if unknown.</returns>
public static Task<int> DeleteCookiesAsync(this ICookieManager cookieManager, string url = null, string name = null)
{
if (cookieManager == null)
{
throw new NullReferenceException("cookieManager");
}
if (cookieManager.IsDisposed)
{
throw new ObjectDisposedException("cookieManager");
}
var callback = new TaskDeleteCookiesCallback();
if (cookieManager.DeleteCookies(url, name, callback))
{
return callback.Task;
}
//There was a problem deleting cookies
return Task.FromResult(TaskDeleteCookiesCallback.InvalidNoOfCookiesDeleted);
}
/// <summary>
/// Sets a cookie given a valid URL and explicit user-provided cookie attributes.
/// This function expects each attribute to be well-formed. It will check for disallowed
/// characters (e.g. the ';' character is disallowed within the cookie value attribute) and will return false without setting
/// </summary>
/// <param name="cookieManager">cookie manager</param>
/// <param name="url">The cookie URL. If an empty string is provided, any URL will be matched.</param>
/// <param name="cookie">the cookie to be set</param>
/// <returns>returns false if the cookie cannot be set (e.g. if illegal charecters such as ';' are used);
/// otherwise task that represents the set operation. The value of the TResult parameter contains a bool to indicate success.</returns>
public static Task<bool> SetCookieAsync(this ICookieManager cookieManager, string url, Cookie cookie)
{
if (cookieManager == null)
{
throw new NullReferenceException("cookieManager");
}
if (cookieManager.IsDisposed)
{
throw new ObjectDisposedException("cookieManager");
}
var callback = new TaskSetCookieCallback();
if (cookieManager.SetCookie(url, cookie, callback))
{
return callback.Task;
}
//There was a problem setting cookies
return Task.FromResult(false);
}
/// <summary>
/// Visits all cookies. The returned cookies are sorted by longest path, then by earliest creation date.
/// </summary>
/// <param name="cookieManager">cookie manager</param>
/// <returns>A task that represents the VisitAllCookies operation. The value of the TResult parameter contains a List of cookies
/// or null if cookies cannot be accessed.</returns>
public static Task<List<Cookie>> VisitAllCookiesAsync(this ICookieManager cookieManager)
{
var cookieVisitor = new TaskCookieVisitor();
if (cookieManager.VisitAllCookies(cookieVisitor))
{
return cookieVisitor.Task;
}
return Task.FromResult<List<Cookie>>(null);
}
/// <summary>
/// Visits a subset of the cookies. The results are filtered by the given url scheme, host, domain and path.
/// If <paramref name="includeHttpOnly"/> is true, HTTP-only cookies will also be included in the results. The returned cookies
/// are sorted by longest path, then by earliest creation date.
/// </summary>
/// <param name="cookieManager">cookie manager</param>
/// <param name="url">The URL to use for filtering a subset of the cookies available.</param>
/// <param name="includeHttpOnly">A flag that determines whether HTTP-only cookies will be shown in results.</param>
/// <returns>A task that represents the VisitUrlCookies operation. The value of the TResult parameter contains a List of cookies.
/// or null if cookies cannot be accessed.</returns>
public static Task<List<Cookie>> VisitUrlCookiesAsync(this ICookieManager cookieManager, string url, bool includeHttpOnly)
{
var cookieVisitor = new TaskCookieVisitor();
if (cookieManager.VisitUrlCookies(url, includeHttpOnly, cookieVisitor))
{
return cookieVisitor.Task;
}
return Task.FromResult<List<Cookie>>(null);
}
/// <summary>
/// Flush the backing store (if any) to disk.
/// </summary>
/// <param name="cookieManager">cookieManager instance</param>
/// <returns>A task that represents the FlushStore operation. Result indicates if the flush completed successfully.
/// Will return false if the cookikes cannot be accessed.</returns>
public static Task<bool> FlushStoreAsync(this ICookieManager cookieManager)
{
var handler = new TaskCompletionCallback();
if (cookieManager.FlushStore(handler))
{
return handler.Task;
}
//returns null if cookies cannot be accessed.
return Task.FromResult(false);
}
/// <summary>
/// Retrieve a snapshot of current navigation entries
/// </summary>
/// <param name="browserHost">browserHost</param>
/// <param name="currentOnly">If true the List will only contain the current navigation entry.
/// If false the List will include all navigation entries will be included. Default is false</param>
public static Task<List<NavigationEntry>> GetNavigationEntriesAsync(this IBrowserHost browserHost, bool currentOnly = false)
{
var visitor = new TaskNavigationEntryVisitor();
browserHost.GetNavigationEntries(visitor, currentOnly);
return visitor.Task;
}
}
}

View file

@ -0,0 +1,33 @@
// Copyright © 2016 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 CefSharp.ModelBinding;
namespace CefSharp
{
/// <summary>
/// Javascript binding options
/// </summary>
public class BindingOptions
{
/// <summary>
/// Set of options with the default binding
/// </summary>
public static BindingOptions DefaultBinder
{
get { return new BindingOptions { Binder = new DefaultBinder() }; }
}
/// <summary>
/// Model binder used for passing complex classes as params to methods
/// </summary>
public IBinder Binder { get; set; }
/// <summary>
/// Interceptor used for intercepting calls to the target object methods. For instance, can be used
/// for logging calls (from js) to .net methods.
/// </summary>
public IMethodInterceptor MethodInterceptor { get; set; }
}
}

View file

@ -0,0 +1,31 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface used for asynchronous continuation of authentication requests.
/// </summary>
public interface IAuthCallback : IDisposable
{
/// <summary>
/// Continue the authentication request.
/// </summary>
/// <param name="username">requested username</param>
/// <param name="password">requested password</param>
void Continue(string username, string password);
/// <summary>
/// Cancel the authentication request.
/// </summary>
void Cancel();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,27 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface used to asynchronously continue a download.
/// </summary>
public interface IBeforeDownloadCallback : IDisposable
{
/// <summary>
/// Call to continue the download.
/// </summary>
/// <param name="downloadPath">full file path for the download including the file name
/// or leave blank to use the suggested name and the default temp directory</param>
/// <param name="showDialog">Set to true if you do wish to show the default "Save As" dialog</param>
void Continue(string downloadPath, bool showDialog);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,29 @@
// Copyright © 2014 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>
/// Generic callback interface used for asynchronous continuation.
/// </summary>
public interface ICallback : IDisposable
{
/// <summary>
/// Continue processing.
/// </summary>
void Continue();
/// <summary>
/// Cancel processing.
/// </summary>
void Cancel();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,24 @@
// Copyright © 2014 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>
/// Generic callback interface used for asynchronous completion.
/// </summary>
public interface ICompletionCallback : IDisposable
{
/// <summary>
/// Method that will be called once the task is complete.
/// </summary>
void OnComplete();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,27 @@
// Copyright © 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>
/// Interface to implement to be notified of asynchronous completion via ICookieManager.DeleteCookies().
/// It will be executed asynchronously on the CEF IO thread after the cookie has been deleted
/// </summary>
public interface IDeleteCookiesCallback : IDisposable
{
/// <summary>
/// Method that will be called upon completion.
/// </summary>
/// <param name="numDeleted">will be the number of cookies that were deleted or -1 if unknown.</param>
void OnComplete(int numDeleted);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,81 @@
// Copyright © 2020 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;
using System.IO;
namespace CefSharp.Callback
{
/// <summary>
/// Callback interface for <see cref="IBrowserHost.AddDevToolsMessageObserver"/>.
/// The methods of this class will be called on the CEF UI thread.
/// </summary>
public interface IDevToolsMessageObserver : IDisposable
{
/// <summary>
/// Method that will be called on receipt of a DevTools protocol message.
/// Method result dictionaries include an "id" (int) value that identifies the
/// orginating method call sent from IBrowserHost.SendDevToolsMessage, and
/// optionally either a "result" (dictionary) or "error" (dictionary) value.
/// The "error" dictionary will contain "code" (int) and "message" (string)
/// values. Event dictionaries include a "method" (string) value and optionally
/// a "params" (dictionary) value. See the DevTools protocol documentation at
/// https://chromedevtools.github.io/devtools-protocol/ for details of
/// supported method calls and the expected "result" or "params" dictionary
/// contents. JSON dictionaries can be parsed using the CefParseJSON function
/// if desired, however be aware of performance considerations when parsing
/// large messages (some of which may exceed 1MB in size).
/// </summary>
/// <param name="browser">is the originating browser instance</param>
/// <param name="message">is a UTF8-encoded JSON dictionary representing either a method result or an event.
/// is only valid for the scope of this callback and should be copied if necessary
/// </param>
/// <returns>Return true if the message was handled or false if the message
/// should be further processed and passed to the OnDevToolsMethodResult or
/// OnDevToolsEvent methods as appropriate.</returns>
bool OnDevToolsMessage(IBrowser browser, Stream message);
/// <summary>
/// Method that will be called after attempted execution of a DevTools protocol
/// </summary>
/// <param name="browser">is the originating browser instance</param>
/// <param name="messageId">is the id value that identifies the originating method call message</param>
/// <param name="success">If the method succeeded <paramref name="success"/> will be true and <paramref name="result"/> will be the
/// UTF8-encoded JSON "result" dictionary value (which may be empty).
/// If the method failed <paramref name="success"/> will be false and <paramref name="result"/> will be the UTF8-encoded
/// JSON "error" dictionary value.
/// </param>
/// <param name="result">The stream is only valid for the scope of this
/// callback and should be copied if necessary. See the OnDevToolsMessage
/// documentation for additional details on contents</param>
void OnDevToolsMethodResult(IBrowser browser, int messageId, bool success, Stream result);
/// <summary>
/// Method that will be called on receipt of a DevTools protocol event.
/// </summary>
/// <param name="browser">is the originating browser instance</param>
/// <param name="method">is the method value</param>
/// <param name="parameters">is the UTF8-encoded JSON "params" dictionary value (which
/// may be empty). This stream is only valid for the scope of this callback and
/// should be copied if necessary. See the OnDevToolsMessage documentation for
/// additional details on contents.
/// </param>
void OnDevToolsEvent(IBrowser browser, string method, Stream parameters);
/// <summary>
/// Method that will be called when the DevTools agent has attached.
/// This will generally occur in response to the first message sent while the agent is detached.
/// </summary>
/// <param name="browser">is the originating browser instance</param>
void OnDevToolsAgentAttached(IBrowser browser);
/// <summary>
/// Method that will be called when the DevTools agent has detached.
/// Any method results that were pending before the agent became detached will not be delivered, and any active
/// event subscriptions will be canceled.
/// </summary>
/// <param name="browser">is the originating browser instance</param>
void OnDevToolsAgentDetached(IBrowser browser);
}
}

View file

@ -0,0 +1,34 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface used to asynchronously cancel a download.
/// </summary>
public interface IDownloadItemCallback : IDisposable
{
/// <summary>
/// Call to cancel the download.
/// </summary>
void Cancel();
/// <summary>
/// Call to pause the download.
/// </summary>
void Pause();
/// <summary>
/// Call to resume the download.
/// </summary>
void Resume();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,34 @@
// Copyright © 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.
using System;
using System.Collections.Generic;
namespace CefSharp
{
/// <summary>
/// Callback interface for asynchronous continuation of file dialog requests.
/// </summary>
public interface IFileDialogCallback : IDisposable
{
/// <summary>
/// Continue the file selection.
/// </summary>
/// <param name="selectedAcceptFilter">should be the 0-based index of the value selected from the accept filters
/// array passed to <see cref="IDialogHandler.OnFileDialog"/></param>
/// <param name="filePaths">should be a single value or a list of values depending on the dialog mode.
/// An empty value is treated the same as calling Cancel().</param>
void Continue(int selectedAcceptFilter, List<string> filePaths);
/// <summary>
/// Cancel the file selection.
/// </summary>
void Cancel();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,32 @@
// Copyright © 2018 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;
using System.IO;
namespace CefSharp
{
/// <summary>
/// Callback interface used for asynchronous continuation of <see cref="IExtensionHandler.GetExtensionResource"/>.
/// </summary>
public interface IGetExtensionResourceCallback : IDisposable
{
/// <summary>
/// Continue the request. Read the resource contents from stream.
/// </summary>
/// <param name="stream">stream to be used as response.</param>
void Continue(Stream stream);
/// <summary>
/// Continue the request
/// </summary>
/// <param name="data">data to be used as response</param>
void Continue(byte[] data);
/// <summary>
/// Cancel the request.
/// </summary>
void Cancel();
}
}

View file

@ -0,0 +1,45 @@
// Copyright © 2014 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;
using System.Threading.Tasks;
namespace CefSharp
{
/// <summary>
/// Javascript callback interface
/// </summary>
public interface IJavascriptCallback : IDisposable
{
/// <summary>
/// Callback Id
/// </summary>
Int64 Id { get; }
/// <summary>
/// Execute the javascript callback
/// </summary>
/// <param name="parms">param array of objects</param>
/// <returns>JavascriptResponse</returns>
Task<JavascriptResponse> ExecuteAsync(params object[] parms);
/// <summary>
/// Execute the javascript callback
/// </summary>
/// <param name="timeout">timeout</param>
/// <param name="parms">param array of objects</param>
/// <returns>JavascriptResponse</returns>
Task<JavascriptResponse> ExecuteWithTimeoutAsync(TimeSpan? timeout, params object[] parms);
/// <summary>
/// Check to see if the underlying resource are still available to execute the callback
/// </summary>
bool CanExecute { get; }
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,32 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface used for asynchronous continuation of JavaScript dialog requests.
/// </summary>
public interface IJsDialogCallback : IDisposable
{
/// <summary>
/// Continue the Javascript dialog request.
/// </summary>
/// <param name="success">Set to true if the OK button was pressed.</param>
/// <param name="userInput">value should be specified for prompt dialogs.</param>
void Continue(bool success, string userInput);
/// <summary>
/// Continue the Javascript dialog request.
/// </summary>
/// <param name="success">Set to true if the OK button was pressed.</param>
void Continue(bool success);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,28 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface for <see cref="IBrowserHost.PrintToPdf"/>. The methods of this interface
/// will be called on the CEF UI thread.
/// </summary>
public interface IPrintToPdfCallback : IDisposable
{
/// <summary>
/// Method that will be executed when the PDF printing has completed.
/// </summary>
/// <param name="path">The output path.</param>
/// <param name="ok">Will be true if the printing completed
/// successfully or false otherwise.</param>
void OnPdfPrintFinished(string path, bool ok);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,25 @@
// Copyright © 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>
/// Content Decryption Module (CDM) registration callback used for asynchronous completion.
/// </summary>
public interface IRegisterCdmCallback : IDisposable
{
/// <summary>
/// Method that will be called once CDM registration is complete
/// </summary>
/// <param name="registration">The result of the CDM registration process</param>
void OnRegistrationComplete(CdmRegistration registration);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,30 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface used for asynchronous continuation of url requests.
/// </summary>
public interface IRequestCallback : IDisposable
{
/// <summary>
/// Continue the url request.
/// </summary>
/// <param name="allow">If is true the request will be continued, otherwise, the request will be canceled.</param>
void Continue(bool allow);
/// <summary>
/// Cancel the url request.
/// </summary>
void Cancel();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,28 @@
// Copyright © 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.
using System;
using System.Collections.Generic;
namespace CefSharp
{
/// <summary>
/// Callback interface for <see cref="IRequestContext.ResolveHostAsync(Uri)"/>
/// </summary>
public interface IResolveCallback : IDisposable
{
/// <summary>
/// Called after the ResolveHost request has completed.
/// </summary>
/// <param name="result">The result code</param>
/// <param name="resolvedIpAddresses">will be the list of resolved IP addresses or
/// empty if the resolution failed.</param>
void OnResolveCompleted(CefErrorCode result, IList<string> resolvedIpAddresses);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,33 @@
// 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;
namespace CefSharp.Callback
{
/// <summary>
/// Callback for asynchronous continuation of <see cref="IResourceHandler.Read"/>.
/// </summary>
public interface IResourceReadCallback : IDisposable
{
/// <summary>
/// Callback for asynchronous continuation of <see cref="IResourceHandler.Read"/>. If bytesRead == 0
/// the response will be considered complete.
/// </summary>
/// <param name="bytesRead">
/// If bytesRead == 0 the response will be considered complete.
/// If bytesRead &gt; 0 then <see cref="IResourceHandler.Read"/> will be called again until the request is complete (based on either the
/// result or the expected content length). If bytesRead &lt; 0 then the
/// request will fail and the bytesRead value will be treated as the error
/// code.
/// </param>
void Continue(int bytesRead);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,28 @@
// 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;
namespace CefSharp.Callback
{
/// <summary>
/// Callback for asynchronous continuation of <see cref="IResourceHandler.Skip"/>.
/// </summary>
public interface IResourceSkipCallback : IDisposable
{
/// <summary>
/// Callback for asynchronous continuation of Skip().
/// </summary>
/// <param name="bytesSkipped">If bytesSkipped &gt; 0 then either Skip() will be called
/// again until the requested number of bytes have been skipped or the request will proceed.
/// If bytesSkipped &lt;= the request will fail with ERR_REQUEST_RANGE_NOT_SATISFIABLE.</param>
void Continue(Int64 bytesSkipped);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,31 @@
// Copyright © 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.
using System;
namespace CefSharp
{
/// <summary>
/// Callback interface used for continuation of custom context menu display.
/// </summary>
public interface IRunContextMenuCallback : IDisposable
{
/// <summary>
/// Complete context menu display by selecting the specified commandId and eventFlags;
/// </summary>
/// <param name="commandId">the command Id</param>
/// <param name="eventFlags">the event flags</param>
void Continue(CefMenuCommand commandId, CefEventFlags eventFlags);
/// <summary>
/// Cancel context menu display.
/// </summary>
void Cancel();
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,22 @@
// Copyright © 2018 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.Callback
{
/// <summary>
/// Callback interface for IBrowserHost.RunFileDialog.
/// The methods of this class will be called on the CEF UI thread.
/// </summary>
public interface IRunFileDialogCallback
{
/// <summary>
/// Called asynchronously after the file dialog is dismissed.
/// </summary>
/// <param name="selectedAcceptFilter">is the 0-based index of the value selected from the accept filters array passed to IBrowserHost.RunFileDialog</param>
/// <param name="filePaths">will be a single value or a list of values depending on the dialog mode. If the selection was cancelled filePaths will be empty</param>
void OnFileDialogDismissed(int selectedAcceptFilter, IList<string> filePaths);
}
}

View file

@ -0,0 +1,27 @@
// Copyright © 2014 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;
using System.Security.Cryptography.X509Certificates;
namespace CefSharp
{
/// <summary>
/// Callback interface used to select a client certificate for authentication.
/// </summary>
public interface ISelectClientCertificateCallback : IDisposable
{
/// <summary>
/// Callback interface used to select a client certificate for authentication.
/// <see langword="null"/> value means that no client certificate should be used.
/// </summary>
/// <param name="selectedCert">selected certificate</param>
void Select(X509Certificate2 selectedCert);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,27 @@
// Copyright © 2014 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>
/// Interface to implement to be notified of asynchronous completion via ICookieManager.SetCookie().
/// It will be executed asynchronously on the CEF IO thread after the cookie has been set
/// </summary>
public interface ISetCookieCallback : IDisposable
{
/// <summary>
/// Method that will be called upon completion.
/// </summary>
/// <param name="success">success will be true if the cookie was set successfully.</param>
void OnComplete(bool success);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}

View file

@ -0,0 +1,32 @@
// Copyright © 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.
using System;
namespace CefSharp.Callback
{
/// <summary>
/// Provides a callback implementation of <see cref="ICompletionCallback"/>
/// that does nothing with complete.
/// Added to workaround a CEF bug as per https://github.com/cefsharp/CefSharp/issues/2957#issuecomment-555285400
/// </summary>
public class NoOpCompletionCallback : ICompletionCallback
{
void ICompletionCallback.OnComplete()
{
}
bool ICompletionCallback.IsDisposed
{
//For now we return false
get { return false; }
}
void IDisposable.Dispose()
{
}
}
}

View file

@ -0,0 +1,63 @@
// Copyright © 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.
using System;
using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a callback implementation of <see cref="ICompletionCallback"/>.
/// </summary>
public class TaskCompletionCallback : ICompletionCallback
{
private readonly TaskCompletionSource<bool> taskCompletionSource;
private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
/// <summary>
/// Default constructor
/// </summary>
public TaskCompletionCallback()
{
taskCompletionSource = new TaskCompletionSource<bool>();
}
void ICompletionCallback.OnComplete()
{
onComplete = true;
taskCompletionSource.TrySetResultAsync(true);
}
/// <summary>
/// Task used to await this callback
/// </summary>
public Task<bool> Task
{
get { return taskCompletionSource.Task; }
}
bool ICompletionCallback.IsDisposed
{
get { return isDisposed; }
}
void IDisposable.Dispose()
{
var task = taskCompletionSource.Task;
//If onComplete is false then ICompletionCallback.OnComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false)
{
taskCompletionSource.TrySetResultAsync(false);
}
isDisposed = true;
}
}
}

View file

@ -0,0 +1,67 @@
// Copyright © 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;
using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a callback implementation of <see cref="IDeleteCookiesCallback"/>.
/// </summary>
public class TaskDeleteCookiesCallback : IDeleteCookiesCallback
{
/// <summary>
/// Invalid Number of Cookies
/// </summary>
public const int InvalidNoOfCookiesDeleted = -1;
private readonly TaskCompletionSource<int> taskCompletionSource;
private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
/// <summary>
/// Default constructor
/// </summary>
public TaskDeleteCookiesCallback()
{
taskCompletionSource = new TaskCompletionSource<int>();
}
void IDeleteCookiesCallback.OnComplete(int numDeleted)
{
onComplete = true;
taskCompletionSource.TrySetResultAsync(numDeleted);
}
/// <summary>
/// Task used to await this callback
/// </summary>
public Task<int> Task
{
get { return taskCompletionSource.Task; }
}
bool IDeleteCookiesCallback.IsDisposed
{
get { return isDisposed; }
}
void IDisposable.Dispose()
{
var task = taskCompletionSource.Task;
//If onComplete is false then IDeleteCookiesCallback.OnComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false)
{
taskCompletionSource.TrySetResultAsync(InvalidNoOfCookiesDeleted);
}
isDisposed = true;
}
}
}

View file

@ -0,0 +1,55 @@
// Copyright © 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.
using System;
using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a callback implementation of <see cref="IPrintToPdfCallback"/>.
/// </summary>
public sealed class TaskPrintToPdfCallback : IPrintToPdfCallback
{
private readonly TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
/// <summary>
/// Task used to await this callback
/// </summary>
public Task<bool> Task
{
get { return taskCompletionSource.Task; }
}
void IPrintToPdfCallback.OnPdfPrintFinished(string path, bool ok)
{
onComplete = true;
taskCompletionSource.TrySetResultAsync(ok);
}
bool IPrintToPdfCallback.IsDisposed
{
get { return isDisposed; }
}
void IDisposable.Dispose()
{
var task = taskCompletionSource.Task;
//If onComplete is false then IPrintToPdfCallback.OnPdfPrintFinished was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false)
{
taskCompletionSource.TrySetResultAsync(false);
}
isDisposed = true;
}
}
}

View file

@ -0,0 +1,63 @@
// Copyright © 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;
using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a callback implementation of <see cref="IRegisterCdmCallback"/> for use with asynchronous Widevine CDM registration.
/// </summary>
public class TaskRegisterCdmCallback : IRegisterCdmCallback
{
private readonly TaskCompletionSource<CdmRegistration> taskCompletionSource;
private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
/// <summary>
/// Default constructor
/// </summary>
public TaskRegisterCdmCallback()
{
taskCompletionSource = new TaskCompletionSource<CdmRegistration>();
}
void IRegisterCdmCallback.OnRegistrationComplete(CdmRegistration registration)
{
onComplete = true;
taskCompletionSource.TrySetResultAsync(registration);
}
/// <summary>
/// Task used to await this callback
/// </summary>
public Task<CdmRegistration> Task
{
get { return taskCompletionSource.Task; }
}
bool IRegisterCdmCallback.IsDisposed
{
get { return isDisposed; }
}
void IDisposable.Dispose()
{
var task = taskCompletionSource.Task;
//If onComplete is false then IRegisterCdmCallback.OnRegistrationComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false)
{
taskCompletionSource.TrySetResultAsync(null);
}
isDisposed = true;
}
}
}

View file

@ -0,0 +1,64 @@
// Copyright © 2016 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;
using System.Collections.Generic;
using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a callback implementation of <see cref="IResolveCallback"/>.
/// </summary>
public class TaskResolveCallback : IResolveCallback
{
private readonly TaskCompletionSource<ResolveCallbackResult> taskCompletionSource;
private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
/// <summary>
/// Default constructor
/// </summary>
public TaskResolveCallback()
{
taskCompletionSource = new TaskCompletionSource<ResolveCallbackResult>();
}
void IResolveCallback.OnResolveCompleted(CefErrorCode result, IList<string> resolvedIpAddresses)
{
onComplete = true;
taskCompletionSource.TrySetResultAsync(new ResolveCallbackResult(result, resolvedIpAddresses));
}
bool IResolveCallback.IsDisposed
{
get { return isDisposed; }
}
/// <summary>
/// Task used to await this callback
/// </summary>
public Task<ResolveCallbackResult> Task
{
get { return taskCompletionSource.Task; }
}
void IDisposable.Dispose()
{
var task = taskCompletionSource.Task;
//If onComplete is false then IResolveCallback.OnResolveCompleted was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false)
{
taskCompletionSource.TrySetResultAsync(new ResolveCallbackResult(CefErrorCode.Unexpected, null));
}
isDisposed = true;
}
}
}

View file

@ -0,0 +1,63 @@
// Copyright © 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.
using System;
using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a callback implementation of <see cref="ISetCookieCallback"/>.
/// </summary>
public class TaskSetCookieCallback : ISetCookieCallback
{
private readonly TaskCompletionSource<bool> taskCompletionSource;
private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
/// <summary>
/// Default constructor
/// </summary>
public TaskSetCookieCallback()
{
taskCompletionSource = new TaskCompletionSource<bool>();
}
void ISetCookieCallback.OnComplete(bool success)
{
onComplete = true;
taskCompletionSource.TrySetResultAsync(success);
}
/// <summary>
/// Task used to await this callback
/// </summary>
public Task<bool> Task
{
get { return taskCompletionSource.Task; }
}
bool ISetCookieCallback.IsDisposed
{
get { return isDisposed; }
}
void IDisposable.Dispose()
{
var task = taskCompletionSource.Task;
//If onComplete is false then ISetCookieCallback.OnComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false)
{
taskCompletionSource.TrySetResultAsync(false);
}
isDisposed = true;
}
}
}

View file

@ -0,0 +1,33 @@
// Copyright © 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.
namespace CefSharp
{
/// <summary>
/// Represents the response to an attempt to register the Widevine Content Decryption Module (CDM)
/// </summary>
public sealed class CdmRegistration
{
/// <summary>
/// If CDM registration succeeded then value will be <see cref="CdmRegistrationErrorCode.None"/>, for other values see the enumeration <see cref="CdmRegistrationErrorCode" />.
/// </summary>
public CdmRegistrationErrorCode ErrorCode { get; private set; }
/// <summary>
/// Contains an error message containing additional information if <see cref="ErrorCode"/> is not <see cref="CdmRegistrationErrorCode.None"/>.
/// </summary>
public string ErrorMessage { get; private set; }
/// <summary>
/// CdmRegistration
/// </summary>
/// <param name="errorCode">error code</param>
/// <param name="errorMessage">error message</param>
public CdmRegistration(CdmRegistrationErrorCode errorCode, string errorMessage)
{
ErrorCode = errorCode;
ErrorMessage = errorMessage;
}
}
}

View file

@ -0,0 +1,269 @@
// Copyright © 2014 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;
using System.Collections.Generic;
using System.Linq;
using CefSharp.Enums;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Used in conjunction with CefSettings.RegisterScheme to register a scheme.
/// You can register your own custom scheme e.g. custom:// if you are using a build in scheme
/// (http/https) then you should directly register your <see cref="ISchemeHandlerFactory"/> using
/// Cef.GetGlobalRequestContext().RegisterSchemeHandlerFactory - make sure the Global RequestContext has
/// been initialized before doing so, you can use <see cref="IBrowserProcessHandler.OnContextInitialized"/>
/// for notification of RequestContext initialization (Pass an IBrowserProcessHandler instance to Cef.Initialize)
/// </summary>
public sealed class CefCustomScheme
{
private SchemeOptions schemeOptions;
/// <summary>
/// Schema Name e.g. custom
/// </summary>
public string SchemeName { get; set; }
/// <summary>
/// Optional Domain Name. An empty value for a standard scheme
/// will cause the factory to match all domain names. The |domain_name| value
/// will be ignored for non-standard schemes.
/// </summary>
public string DomainName { get; set; }
/// <summary>
/// If true the scheme will be treated as a standard scheme.
/// Standard schemes are subject to URL canonicalization and parsing rules as
/// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
/// at http://www.ietf.org/rfc/rfc1738.txt
///
/// In particular, the syntax for standard scheme URLs must be of the form:
/// <pre>
/// [scheme]://[username]:[password]@[host]:[port]/[url-path]
/// </pre>
/// Standard scheme URLs must have a host component that is a fully qualified
/// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of
/// RFC 1123. These URLs will be canonicalized to "scheme://host/path" in the
/// simplest case and "scheme://username:password@host:port/path" in the most
/// explicit case. For example, "scheme:host/path" and "scheme:///host/path"
/// will both be canonicalized to "scheme://host/path". The origin of a
/// standard scheme URL is the combination of scheme, host and port (i.e.,
/// "scheme://host:port" in the most explicit case).
///
/// For non-standard scheme URLs only the "scheme:" component is parsed and
/// canonicalized. The remainder of the URL will be passed to the handler
/// as-is. For example, "scheme:///some%20text" will remain the same.
/// Non-standard scheme URLs cannot be used as a target for form submission.
/// </summary>
public bool IsStandard
{
get { return schemeOptions.HasFlag(SchemeOptions.Standard); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.Standard;
}
else
{
schemeOptions &= ~SchemeOptions.Standard;
}
}
}
/// <summary>
/// If true the scheme will be treated as local (i.e. with the
/// same security rules as those applied to "file" URLs). Normal pages cannot
/// link to or access local URLs. Also, by default, local URLs can only perform
/// XMLHttpRequest calls to the same URL (origin + path) that originated the
/// request. To allow XMLHttpRequest calls from a local URL to other URLs with
/// the same origin set the CefSettings.file_access_from_file_urls_allowed
/// value to true. To allow XMLHttpRequest calls from a local URL to all
/// origins set the CefSettings.universal_access_from_file_urls_allowed value
/// to true.
/// </summary>
public bool IsLocal
{
get { return schemeOptions.HasFlag(SchemeOptions.Local); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.Local;
}
else
{
schemeOptions &= ~SchemeOptions.Local;
}
}
}
/// <summary>
/// If true the scheme will be treated as display-isolated.
/// This means that pages cannot display these URLs unless they are
/// from the same scheme. For example, pages in another origin cannot create
/// iframes or hyperlinks to URLs with this scheme.
/// </summary>
public bool IsDisplayIsolated
{
get { return schemeOptions.HasFlag(SchemeOptions.DisplayIsolated); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.DisplayIsolated;
}
else
{
schemeOptions &= ~SchemeOptions.DisplayIsolated;
}
}
}
/// <summary>
/// If true the scheme will be treated with the same security
/// rules as those applied to "https" URLs. For example, loading this scheme
/// from other secure schemes will not trigger mixed content warnings.
/// </summary>
public bool IsSecure
{
get { return schemeOptions.HasFlag(SchemeOptions.Secure); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.Secure;
}
else
{
schemeOptions &= ~SchemeOptions.Secure;
}
}
}
/// <summary>
/// If true the scheme can be sent CORS requests.
/// This value should be true in most cases where IsStandard is true.
/// </summary>
public bool IsCorsEnabled
{
get { return schemeOptions.HasFlag(SchemeOptions.CorsEnabled); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.CorsEnabled;
}
else
{
schemeOptions &= ~SchemeOptions.CorsEnabled;
}
}
}
/// <summary>
/// If true the scheme can bypass Content-Security-Policy(CSP) checks.
/// This value should be false in most cases where IsStandard is true.
/// </summary>
public bool IsCSPBypassing
{
get { return schemeOptions.HasFlag(SchemeOptions.CspBypassing); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.CspBypassing;
}
else
{
schemeOptions &= ~SchemeOptions.CspBypassing;
}
}
}
/// <summary>
/// If true the scheme can perform Fetch API requests.
/// </summary>
public bool IsFetchEnabled
{
get { return schemeOptions.HasFlag(SchemeOptions.FetchEnabled); }
set
{
if (value)
{
schemeOptions |= SchemeOptions.FetchEnabled;
}
else
{
schemeOptions &= ~SchemeOptions.FetchEnabled;
}
}
}
/// <summary>
/// Factory Class that creates <see cref="IResourceHandler"/> instances
/// for handling scheme requests. Leave this null if you wish to manually register the
/// scheme handler with the relevant RequestContext.
/// </summary>
public ISchemeHandlerFactory SchemeHandlerFactory { get; set; }
/// <summary>
/// Gets the underlying scheme options that represents
/// </summary>
public SchemeOptions Options
{
get { return schemeOptions; }
}
/// <summary>
/// Creates a new CefCustomScheme.
/// </summary>
public CefCustomScheme()
{
schemeOptions = SchemeOptions.Standard | SchemeOptions.Secure | SchemeOptions.CorsEnabled;
}
/// <summary>
/// Creates a new CefCustomScheme.
/// </summary>
/// <param name="schemeName">scheme name</param>
/// <param name="options">scheme options</param>
public CefCustomScheme(string schemeName, SchemeOptions options)
{
SchemeName = schemeName;
schemeOptions = options;
}
/// <summary>
/// Method used internally
/// </summary>
/// <param name="args">command line arguments</param>
/// <returns>list of scheme objects</returns>
public static List<CefCustomScheme> ParseCommandLineArguments(IEnumerable<string> args)
{
var schemes = args.GetArgumentValue(CefSharpArguments.CustomSchemeArgument);
var customSchemes = new List<CefCustomScheme>();
if (!string.IsNullOrEmpty(schemes))
{
schemes.Split(';').ToList().ForEach(x =>
{
var tokens = x.Split('|');
var schemeName = tokens[0];
var schemeOptions = SchemeOptions.None;
Enum.TryParse(tokens[1], out schemeOptions);
var customScheme = new CefCustomScheme(schemeName, schemeOptions);
customSchemes.Add(customScheme);
});
}
return customSchemes;
}
}
}

View file

@ -0,0 +1,80 @@
// Copyright © 2016 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;
using System.IO;
using System.Runtime.InteropServices;
namespace CefSharp
{
/// <summary>
/// CefLibraryHandle is a SafeHandle that Loads libcef.dll and relesases it when disposed/finalized
/// Calls LoadLibraryEx with LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH
/// Make sure to set settings.BrowserSubprocessPath and settings.LocalesDirPath
/// </summary>
/// <remarks>Adapted from http://www.pinvoke.net/default.aspx/kernel32.loadlibraryex</remarks>
public class CefLibraryHandle : SafeHandle
{
/// <summary>
/// In general not a fan of having inline classes/enums
/// In this case it's not something that I'd like to see exposed
/// as it's just a helper and outside the scope of the project
/// </summary>
[Flags]
private enum LoadLibraryFlags : uint
{
DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
}
/// <summary>
/// Default constructor
/// </summary>
/// <param name="path">libcef.dll full path.</param>
public CefLibraryHandle(string path) : base(IntPtr.Zero, true)
{
if (!File.Exists(path))
{
throw new FileNotFoundException("NotFound", path);
}
var handle = LoadLibraryEx(path, IntPtr.Zero, LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH);
base.SetHandle(handle);
}
/// <summary>
/// When overridden in a derived class, gets a value indicating whether the handle value is invalid.
/// </summary>
/// <value>
/// true if the handle value is invalid; otherwise, false.
/// </value>
public override bool IsInvalid
{
get { return this.handle == IntPtr.Zero; }
}
/// <summary>
/// When overridden in a derived class, executes the code required to free the handle.
/// </summary>
/// <returns>
/// true if the handle is released successfully; otherwise, in the event of a catastrophic failure, false. In this case, it
/// generates a releaseHandleFailed MDA Managed Debugging Assistant.
/// </returns>
protected override bool ReleaseHandle()
{
return FreeLibrary(this.handle);
}
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FreeLibrary(IntPtr hModule);
}
}

View file

@ -0,0 +1,98 @@
// Copyright © 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.
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;
#if !NETCOREAPP
WcfTimeout = TimeSpan.FromSeconds(2);
#endif
SubprocessExitIfParentProcessClosed = true;
}
/// <summary>
/// Objects registered using <see cref="IJavascriptObjectRepository.Register"/>
/// will be automatically bound when a V8Context is created. (Soon as the Javascript
/// context is created for a browser). This behaviour is like that seen with Javascript
/// Binding in version 57 and earlier.
/// NOTE: MUST be set before creating your first ChromiumWebBrowser instance.
/// </summary>
[Obsolete("Use chromiumWebBrowser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; instead." +
"Must be called before creating your first ChromiumWebBrowser instance." +
"See https://github.com/cefsharp/CefSharp/issues/2977 for details.")]
public static bool LegacyJavascriptBindingEnabled { get; set; }
#if !NETCOREAPP
/// <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; }
#endif
/// <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>
/// CefSharp.BrowserSubprocess will monitor the parent process and exit if the parent process closes
/// before the subprocess. This currently defaults to true.
/// See https://github.com/cefsharp/CefSharp/issues/2359 for more information.
/// </summary>
public static bool SubprocessExitIfParentProcessClosed { 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 how methods are executed for objects registered using
/// <see cref="IJavascriptObjectRepository.Register(string, object, bool, BindingOptions)"/>.
/// By default the <see cref="Internals.MethodRunnerQueue"/> queues Tasks for execution in a sequential order.
/// A single method is exeucted at a time. Setting this property to true allows for concurrent task execution.
/// Method calls are executed on <see cref="System.Threading.Tasks.TaskScheduler.Default"/> (ThreadPool).
/// </summary>
public static bool ConcurrentTaskExecution { get; set; }
/// <summary>
/// If true a message will be sent from the render subprocess to the
/// browser when a DOM node (or no node) gets focus. The default is
/// false.
/// </summary>
public static bool FocusedNodeChangedEnabled { get; set; }
}
}

View file

@ -0,0 +1,66 @@
// Copyright © 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.
using System;
using System.Diagnostics;
using CefSharp.Enums;
namespace CefSharp
{
/// <summary>
/// Class used to Represent a cookie.
/// The built in .Net Cookie class isn't used as some of it's properties have
/// internal setters
/// </summary>
[DebuggerDisplay("Domain = {Domain}, Path = {Path}, Name = {Name}, Secure = {Secure}, HttpOnly = {HttpOnly}," +
"Creation = {Creation}, Expires = {Expires}, LastAccess = {LastAccess}", Name = "Cookie")]
public sealed class Cookie
{
/// <summary>
/// The cookie name
/// </summary>
public string Name { get; set; }
/// <summary>
/// The cookie value.
/// </summary>
public string Value { get; set; }
/// <summary>
/// If domain is empty a host cookie will be created instead of a domain cookie. Domain cookies are stored with a leading "."
/// and are visible to sub-domains whereas host cookies are not.
/// </summary>
public string Domain { get; set; }
/// <summary>
/// Ss non-empty only URLs at or below the path will get the cookie value.
/// </summary>
public string Path { get; set; }
/// <summary>
/// If true the cookie will only be sent for HTTPS requests.
/// </summary>
public bool Secure { get; set; }
/// <summary>
/// Ss true the cookie will only be sent for HTTP requests.
/// </summary>
public bool HttpOnly { get; set; }
/// <summary>
/// Expires or null if no expiry
/// </summary>
public DateTime? Expires { get; set; }
/// <summary>
/// The cookie creation date. This is automatically populated by the system on cookie creation.
/// </summary>
public DateTime Creation { get; set; }
/// <summary>
/// The cookie last access date. This is automatically populated by the system on access.
/// </summary>
public DateTime LastAccess { get; set; }
/// <summary>
/// Same site.
/// </summary>
public CookieSameSite SameSite { get; set; }
/// <summary>
/// Priority
/// </summary>
public CookiePriority Priority { get; set; }
}
}

View file

@ -0,0 +1,92 @@
// 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>
/// <seealso cref="T:CefSharp.IApp"/>
public class DefaultApp : IApp
{
/// <summary>
/// Return the handler for functionality specific to the browser process. This method is called on multiple threads.
/// </summary>
/// <value>
/// The browser process handler.
/// </value>
public IBrowserProcessHandler BrowserProcessHandler { get; private set; }
/// <summary>
/// Gets or sets the schemes.
/// </summary>
/// <value>
/// The schemes.
/// </value>
public IEnumerable<CefCustomScheme> Schemes { get; private set; }
/// <summary>
/// Constructor.
/// </summary>
/// <param name="browserProcessHandler">The browser process handler.</param>
/// <param name="schemes">The schemes.</param>
public DefaultApp(IBrowserProcessHandler browserProcessHandler, IEnumerable<CefCustomScheme> schemes)
{
BrowserProcessHandler = browserProcessHandler;
Schemes = schemes;
}
/// <summary>
/// Provides an opportunity to register custom schemes. Do not keep a reference to the <paramref name="registrar"/> object. This
/// method is called on the main thread for each process and the registered schemes should be the same across all processes.
///
/// </summary>
/// <param name="registrar">scheme registra.</param>
void IApp.OnRegisterCustomSchemes(ISchemeRegistrar registrar)
{
OnRegisterCustomSchemes(registrar);
}
/// <summary>
/// Provides an opportunity to register custom schemes. Do not keep a reference to the <paramref name="registrar"/> object. This
/// method is called on the main thread for each process and the registered schemes should be the same across all processes.
///
/// </summary>
/// <param name="registrar">scheme registra.</param>
protected virtual void OnRegisterCustomSchemes(ISchemeRegistrar registrar)
{
//Possible we have duplicate scheme names, we'll only register the first one
//Keep a list so we don't call AddCustomScheme twice for the same scheme name
var registeredSchemes = new List<string>();
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;
}
//We've already registered this scheme name
if (registeredSchemes.Contains(scheme.SchemeName))
{
continue;
}
var success = registrar.AddCustomScheme(scheme.SchemeName, scheme.Options);
if (success)
{
registeredSchemes.Add(scheme.SchemeName);
}
else
{
var msg = "CefSchemeRegistrar::AddCustomScheme failed for schemeName:" + scheme.SchemeName;
//TODO: Log error
//LOG(ERROR) << StringUtils::ToNative(msg).ToString();
}
}
}
}
}

View file

@ -0,0 +1,228 @@
// Copyright © 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.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
namespace CefSharp
{
/// <summary>
/// DependencyChecker provides a known list of Cef/CefSharp dependencies and
/// provides helper methods to check for their existance.
/// </summary>
public static class DependencyChecker
{
/// <summary>
/// en-US Locales pak file location
/// </summary>
public const string LocalesPackFile = @"locales\en-US.pak";
/// <summary>
/// List of Cef Dependencies
/// </summary>
public static string[] CefDependencies =
{
// CEF core library
"libcef.dll",
// Unicode support
"icudtl.dat",
// V8 native mapping files, see
// https://groups.google.com/a/chromium.org/forum/#!topic/chromium-packagers/75J9Y1vIc_E
// http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=12580
// "natives_blob.bin" was removed
// https://bugs.chromium.org/p/v8/issues/detail?id=7624#c60
"snapshot_blob.bin",
"v8_context_snapshot.bin"
};
/// <summary>
/// List of Cef Resources (pack files)
/// </summary>
public static string[] CefResources =
{
// Pack Files
// Note: Contains WebKit image and inspector resources.
"devtools_resources.pak",
"cef.pak",
"cef_extensions.pak",
"cef_100_percent.pak",
"cef_200_percent.pak"
};
/// <summary>
/// List of Optional CEF Dependencies
/// </summary>
public static string[] CefOptionalDependencies =
{
// Angle and Direct3D support
// Note: Without these components HTML5 accelerated content like 2D canvas, 3D CSS and WebGL will not function.
"libEGL.dll",
"libGLESv2.dll",
"d3dcompiler_47.dll",
//Crashpad support
"chrome_elf.dll"
};
/// <summary>
/// List of CefSharp Dependencies
/// </summary>
public static string[] CefSharpDependencies =
{
"CefSharp.Core.dll",
"CefSharp.dll"
};
/// <summary>
/// List of CefSharp.BrowserSubprocess.exe dependencies.
/// </summary>
public static string[] BrowserSubprocessDependencies =
{
"CefSharp.BrowserSubprocess.Core.dll",
"CefSharp.Core.dll",
"CefSharp.dll",
"icudtl.dat",
"libcef.dll"
};
/// <summary>
/// CheckDependencies iterates through the list of Cef and CefSharp dependencines
/// relative to the path provided and returns a list of missing ones
/// </summary>
/// <param name="checkOptional">check to see if optional dependencies are present</param>
/// <param name="packLoadingDisabled">Is loading of pack files disabled?</param>
/// <param name="path">path to check for dependencies</param>
/// <param name="resourcesDirPath">The path to the resources directory, if empty the Executing Assembly path is used.</param>
/// <param name="browserSubProcessPath">The path to a separate executable that will be launched for sub-processes.</param>
/// <param name="localePackFile">The locale pack file e.g. <see cref="LocalesPackFile"/> </param>
/// <returns>List of missing dependencies, if all present an empty List will be returned</returns>
public static List<string> CheckDependencies(bool checkOptional, bool packLoadingDisabled, string path, string resourcesDirPath, string browserSubProcessPath, string localePackFile = LocalesPackFile)
{
var missingDependencies = new List<string>();
missingDependencies.AddRange(CheckDependencyList(path, CefDependencies));
if (!packLoadingDisabled)
{
missingDependencies.AddRange(CheckDependencyList(resourcesDirPath, CefResources));
}
if (checkOptional)
{
missingDependencies.AddRange(CheckDependencyList(path, CefOptionalDependencies));
}
missingDependencies.AddRange(CheckDependencyList(path, CefSharpDependencies));
if (!File.Exists(browserSubProcessPath))
{
missingDependencies.Add(browserSubProcessPath);
}
var browserSubprocessDir = Path.GetDirectoryName(browserSubProcessPath);
if (browserSubprocessDir == null)
{
missingDependencies.AddRange(BrowserSubprocessDependencies);
}
else
{
missingDependencies.AddRange(CheckDependencyList(browserSubprocessDir, BrowserSubprocessDependencies));
}
// If path is not rooted (doesn't start with a drive letter + folder)
// then make it relative to the executing assembly.
var localePath = Path.IsPathRooted(localePackFile) ? localePackFile : Path.Combine(path, localePackFile);
if (!File.Exists(localePath))
{
missingDependencies.Add(localePackFile);
}
return missingDependencies;
}
/// <summary>
/// Loop through dependencies and add to the returned missing dependency list if not found.
/// </summary>
/// <param name="dir">The directory of the dependencies, or the current directory if null.</param>
/// <param name="files">The dependencies to check.</param>
/// <returns>List of missing dependencies, if all present an empty List will be returned</returns>
private static List<string> CheckDependencyList(string dir, IEnumerable<string> files)
{
var missingDependencies = new List<string>();
foreach (var file in files)
{
var filePath = string.IsNullOrEmpty(dir) ? file : Path.Combine(dir, file);
if (!File.Exists(filePath))
{
missingDependencies.Add(filePath);
}
}
return missingDependencies;
}
/// <summary>
/// Checks if all Cef and CefSharp dependencies were found relative to the Executing Assembly.
/// Shortcut method that calls <see cref="CheckDependencies"/>, throws an Exception if not files are missing.
/// </summary>
/// <param name="locale">The locale, if empty then en-US will be used.</param>
/// <param name="localesDirPath">The path to the locales directory, if empty locales\ will be used.</param>
/// <param name="resourcesDirPath">The path to the resources directory, if empty the Executing Assembly path is used.</param>
/// <param name="packLoadingDisabled">Is loading of pack files disabled?</param>
/// <param name="browserSubProcessPath">The path to a separate executable that will be launched for sub-processes.</param>
/// <exception cref="Exception">Throw when not all dependencies are present</exception>
public static void AssertAllDependenciesPresent(string locale = null, string localesDirPath = null, string resourcesDirPath = null, bool packLoadingDisabled = false, string browserSubProcessPath = "CefSharp.BrowserSubProcess.exe")
{
string path;
Uri pathUri;
if (Uri.TryCreate(browserSubProcessPath, UriKind.Absolute, out pathUri) && pathUri.IsAbsoluteUri)
{
path = Path.GetDirectoryName(browserSubProcessPath);
}
else
{
var executingAssembly = Assembly.GetExecutingAssembly();
path = Path.GetDirectoryName(executingAssembly.Location);
}
if (string.IsNullOrEmpty(locale))
{
locale = "en-US";
}
if (string.IsNullOrEmpty(localesDirPath))
{
localesDirPath = @"locales";
}
if (string.IsNullOrEmpty(resourcesDirPath))
{
resourcesDirPath = path;
}
var missingDependencies = CheckDependencies(true, packLoadingDisabled, path, resourcesDirPath, browserSubProcessPath, Path.Combine(localesDirPath, locale + ".pak"));
if (missingDependencies.Count > 0)
{
var builder = new StringBuilder();
builder.AppendLine("Unable to locate required Cef/CefSharp dependencies:");
foreach (var missingDependency in missingDependencies)
{
builder.AppendLine("Missing:" + missingDependency);
}
builder.AppendLine("Executing Assembly Path:" + path);
throw new Exception(builder.ToString());
}
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,252 @@
// Copyright © 2020 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;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CefSharp.Callback;
using CefSharp.Internals;
using CefSharp.Internals.Tasks;
namespace CefSharp.DevTools
{
/// <summary>
/// DevTool Client
/// </summary>
public partial class DevToolsClient : IDevToolsMessageObserver, IDevToolsClient
{
//TODO: Message Id is now global, limits the number of messages to int.MaxValue
//Needs to be unique and incrementing per browser with the option to have multiple
//DevToolsClient instances per browser.
private static int lastMessageId = 0;
private readonly ConcurrentDictionary<int, SyncContextTaskCompletionSource<DevToolsMethodResponse>> queuedCommandResults = new ConcurrentDictionary<int, SyncContextTaskCompletionSource<DevToolsMethodResponse>>();
private IBrowser browser;
private IRegistration devToolsRegistration;
private bool devToolsAttached;
private SynchronizationContext syncContext;
/// <summary>
/// DevToolsEvent
/// </summary>
public EventHandler<DevToolsEventArgs> DevToolsEvent;
/// <summary>
/// Capture the current <see cref="SynchronizationContext"/> so
/// continuation executes on the original calling thread. If
/// <see cref="SynchronizationContext.Current"/> is null for
/// <see cref="ExecuteDevToolsMethodAsync(string, IDictionary{string, object})"/>
/// then the continuation will be run on the CEF UI Thread (by default
/// this is not the same as the WPF/WinForms UI Thread).
/// </summary>
public bool CaptureSyncContext { get; set; }
/// <summary>
/// When not null provided <see cref="SynchronizationContext"/>
/// will be used to run the contination. Defaults to null
/// Setting this property will change <see cref="CaptureSyncContext"/>
/// to false.
/// </summary>
public SynchronizationContext SyncContext
{
get { return syncContext; }
set
{
CaptureSyncContext = false;
syncContext = value;
}
}
/// <summary>
/// DevToolsClient
/// </summary>
/// <param name="browser">Browser associated with this DevTools client</param>
public DevToolsClient(IBrowser browser)
{
this.browser = browser;
CaptureSyncContext = true;
}
/// <summary>
/// Store a reference to the IRegistration that's returned when
/// you register an observer.
/// </summary>
/// <param name="devToolsRegistration">registration</param>
public void SetDevToolsObserverRegistration(IRegistration devToolsRegistration)
{
this.devToolsRegistration = devToolsRegistration;
}
/// <summary>
/// Execute a method call over the DevTools protocol. This method can be called on any thread.
/// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details
/// of supported methods and the expected <paramref name="parameters"/> dictionary contents.
/// </summary>
/// <param name="method">is the method name</param>
/// <param name="parameters">are the method parameters represented as a dictionary,
/// which may be empty.</param>
/// <returns>return a Task that can be awaited to obtain the method result</returns>
public async Task<DevToolsMethodResponse> ExecuteDevToolsMethodAsync(string method, IDictionary<string, object> parameters = null)
{
if (browser == null || browser.IsDisposed)
{
//TODO: Queue up commands where possible
return new DevToolsMethodResponse { Success = false };
}
var messageId = Interlocked.Increment(ref lastMessageId);
var taskCompletionSource = new SyncContextTaskCompletionSource<DevToolsMethodResponse>();
taskCompletionSource.SyncContext = CaptureSyncContext ? SynchronizationContext.Current : syncContext;
if (!queuedCommandResults.TryAdd(messageId, taskCompletionSource))
{
throw new DevToolsClientException(string.Format("Unable to add MessageId {0} to queuedCommandResults ConcurrentDictionary.", messageId));
}
var browserHost = browser.GetHost();
//Currently on CEF UI Thread we can directly execute
if (CefThread.CurrentlyOnUiThread)
{
var returnedMessageId = browserHost.ExecuteDevToolsMethod(messageId, method, parameters);
if (returnedMessageId == 0)
{
return new DevToolsMethodResponse { Success = false };
}
else if(returnedMessageId != messageId)
{
//For some reason our message Id's don't match
throw new DevToolsClientException(string.Format("Generated MessageId {0} doesn't match returned Message Id {1}", returnedMessageId, messageId));
}
}
//ExecuteDevToolsMethod can only be called on the CEF UI Thread
else if (CefThread.CanExecuteOnUiThread)
{
var returnedMessageId = await CefThread.ExecuteOnUiThread(() =>
{
return browserHost.ExecuteDevToolsMethod(messageId, method, parameters);
}).ConfigureAwait(false);
if (returnedMessageId == 0)
{
return new DevToolsMethodResponse { Success = false };
}
else if (returnedMessageId != messageId)
{
//For some reason our message Id's don't match
throw new DevToolsClientException(string.Format("Generated MessageId {0} doesn't match returned Message Id {1}", returnedMessageId, messageId));
}
}
else
{
throw new DevToolsClientException("Unable to invoke ExecuteDevToolsMethod on CEF UI Thread.");
}
return await taskCompletionSource.Task;
}
void IDisposable.Dispose()
{
DevToolsEvent = null;
devToolsRegistration?.Dispose();
devToolsRegistration = null;
browser = null;
}
void IDevToolsMessageObserver.OnDevToolsAgentAttached(IBrowser browser)
{
devToolsAttached = true;
}
void IDevToolsMessageObserver.OnDevToolsAgentDetached(IBrowser browser)
{
devToolsAttached = false;
}
void IDevToolsMessageObserver.OnDevToolsEvent(IBrowser browser, string method, Stream parameters)
{
var evt = DevToolsEvent;
//Only parse the data if we have an event handler
if (evt != null)
{
//TODO: Improve this
var memoryStream = new MemoryStream((int)parameters.Length);
parameters.CopyTo(memoryStream);
var paramsAsJsonString = Encoding.UTF8.GetString(memoryStream.ToArray());
evt(this, new DevToolsEventArgs(method, paramsAsJsonString));
}
}
bool IDevToolsMessageObserver.OnDevToolsMessage(IBrowser browser, Stream message)
{
return false;
}
void IDevToolsMessageObserver.OnDevToolsMethodResult(IBrowser browser, int messageId, bool success, Stream result)
{
var uiThread = CefThread.CurrentlyOnUiThread;
SyncContextTaskCompletionSource<DevToolsMethodResponse> taskCompletionSource = null;
if (queuedCommandResults.TryRemove(messageId, out taskCompletionSource))
{
var methodResult = new DevToolsMethodResponse
{
Success = success,
MessageId = messageId
};
//TODO: Improve this
var memoryStream = new MemoryStream((int)result.Length);
result.CopyTo(memoryStream);
methodResult.ResponseAsJsonString = Encoding.UTF8.GetString(memoryStream.ToArray());
Action execute = null;
if (success)
{
execute = () =>
{
taskCompletionSource.TrySetResult(methodResult);
};
}
else
{
execute = () =>
{
var errorObj = methodResult.DeserializeJson<DevToolsDomainErrorResponse>();
errorObj.MessageId = messageId;
//Make sure continuation runs on Thread Pool
taskCompletionSource.TrySetException(new DevToolsClientException("DevTools Client Error :" + errorObj.Message, errorObj));
};
}
var syncContext = taskCompletionSource.SyncContext;
if (syncContext == null)
{
execute();
}
else
{
syncContext.Post(new SendOrPostCallback((o) =>
{
execute();
}), null);
}
}
}
}
}

View file

@ -0,0 +1,58 @@
// Copyright © 2020 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.DevTools
{
/// <summary>
/// The exception that is thrown when there's a problem executing a DevTools protocol method.
/// </summary>
public class DevToolsClientException : Exception
{
/// <summary>
/// Get the Error Response
/// </summary>
public DevToolsDomainErrorResponse Response
{
get; private set;
}
/// <summary>
/// Initializes a new instance of the <see cref="DevToolsClientException"/> class with its message
/// string set to a default message.
/// </summary>
public DevToolsClientException() : base("Error occurred whilst executing DevTools protocol method")
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DevToolsClientException"/> class with a specified error message.
/// </summary>
/// <param name="message">message</param>
public DevToolsClientException(string message) : base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DevToolsClientException"/> class with a specified error message.
/// </summary>
/// <param name="message">message</param>
/// <param name="errorResponse">error response</param>
public DevToolsClientException(string message, DevToolsDomainErrorResponse errorResponse) : base(message)
{
Response = errorResponse;
}
/// <summary>
/// Initializes a new instance of the <see cref="DevToolsClientException"/> class with a specified error message
/// and an inner exception.
/// </summary>
/// <param name="message">message</param>
/// <param name="inner">inner exception</param>
public DevToolsClientException(string message, Exception inner) : base(message, inner)
{
}
}
}

View file

@ -0,0 +1,54 @@
// Copyright © 2020 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;
using System.Collections.Generic;
using System.Runtime.Serialization;
using CefSharp.DevTools.Browser;
namespace CefSharp.DevTools
{
public abstract class DevToolsDomainBase
{
#if NETCOREAPP
protected string EnumToString(Enum val)
{
return Internals.Json.JsonEnumConverterFactory.ConvertEnumToString(val);
}
protected IEnumerable<string> EnumToString(PermissionType[] values)
{
foreach (var val in values)
{
yield return Internals.Json.JsonEnumConverterFactory.ConvertEnumToString(val);
}
}
#else
protected string EnumToString(Enum val)
{
var memInfo = val.GetType().GetMember(val.ToString());
var dataMemberAttribute = (EnumMemberAttribute)Attribute.GetCustomAttribute(memInfo[0], typeof(EnumMemberAttribute), false);
return dataMemberAttribute.Value;
}
protected IEnumerable<string> EnumToString(PermissionType[] values)
{
foreach (var val in values)
{
var memInfo = val.GetType().GetMember(val.ToString());
var dataMemberAttribute = (EnumMemberAttribute)Attribute.GetCustomAttribute(memInfo[0], typeof(EnumMemberAttribute), false);
yield return dataMemberAttribute.Value;
}
}
#endif
protected string ToBase64String(byte[] bytes)
{
return Convert.ToBase64String(bytes);
}
}
}

View file

@ -0,0 +1,237 @@
// Copyright © 2020 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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
namespace CefSharp.DevTools
{
/// <summary>
/// Common Base class for DevTools Domain Model classes
/// </summary>
[DataContract]
public abstract class DevToolsDomainEntityBase
{
#if NETCOREAPP
internal static string EnumToString(Enum e)
{
var memberInfo = e.GetType().GetMember(e.ToString()).FirstOrDefault();
var enumMemberAttribute = (System.Text.Json.Serialization.JsonPropertyNameAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(System.Text.Json.Serialization.JsonPropertyNameAttribute), false);
return enumMemberAttribute.Name;
}
internal static string EnumToString(Array enumArray)
{
var returnValue = "[";
foreach (var e in enumArray)
{
var memberInfo = e.GetType().GetMember(e.ToString()).FirstOrDefault();
var enumMemberAttribute = (System.Text.Json.Serialization.JsonPropertyNameAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(System.Text.Json.Serialization.JsonPropertyNameAttribute), false);
returnValue += enumMemberAttribute.Name + ",";
}
returnValue += returnValue.Substring(0, returnValue.Length - 1) + "]";
return returnValue;
}
#else
internal static object StringToEnum(Type enumType, string input)
{
if (enumType.IsArray)
{
if (string.IsNullOrEmpty(input) || input == "[]" || input == "[ ]")
{
return null;
//return Array.CreateInstance(enumType.GetElementType(), 0);
}
var values = input.Substring(1, input.Length - 2).Split(',');
var returnValues = Array.CreateInstance(enumType.GetElementType(), values.Length);
for (int i = 0; i < values.Length; i++)
{
var str = values[i].Trim('\r', '\n', '"', ' ');
var enumVal = StringToEnumInternal(enumType.GetElementType(), str);
returnValues.SetValue(enumVal, i);
}
return returnValues;
}
if (enumType.IsGenericType && enumType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
if (string.IsNullOrEmpty(input))
{
return null;
}
enumType = Nullable.GetUnderlyingType(enumType);
}
return StringToEnumInternal(enumType, input);
}
private static object StringToEnumInternal(Type enumType, string input)
{
foreach (var name in Enum.GetNames(enumType))
{
var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single();
if (enumMemberAttribute.Value == input)
{
return Enum.Parse(enumType, name);
}
}
return (Enum.GetValues(enumType).GetValue(0));
}
internal static string EnumToString(Enum e)
{
var memberInfo = e.GetType().GetMember(e.ToString()).FirstOrDefault();
var enumMemberAttribute = (EnumMemberAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(EnumMemberAttribute), false);
return enumMemberAttribute.Value;
}
internal static string EnumToString(Array enumArray)
{
var returnValue = "[";
foreach (var e in enumArray)
{
var memberInfo = e.GetType().GetMember(e.ToString()).FirstOrDefault();
var enumMemberAttribute = (EnumMemberAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(EnumMemberAttribute), false);
returnValue += enumMemberAttribute.Value + ",";
}
returnValue += returnValue.Substring(0, returnValue.Length - 1) + "]";
return returnValue;
}
#endif
#if NETCOREAPP
public IDictionary<string, object> ToDictionary()
{
var dict = new Dictionary<string, object>();
var properties = GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var prop in properties)
{
var propertyAttribute = (System.Text.Json.Serialization.JsonPropertyNameAttribute)Attribute.GetCustomAttribute(prop, typeof(System.Text.Json.Serialization.JsonPropertyNameAttribute), false);
//Only add members that have JsonPropertyNameAttribute
if (propertyAttribute == null)
{
continue;
}
var propertyName = propertyAttribute.Name;
var propertyRequired = Attribute.IsDefined(prop, typeof(System.Diagnostics.CodeAnalysis.DisallowNullAttribute));
var propertyValue = prop.GetValue(this);
if (propertyRequired && propertyValue == null)
{
throw new DevToolsClientException(prop.Name + " is required");
}
//Not required and value null, don't add to dictionary
if (propertyValue == null)
{
continue;
}
var propertyValueType = propertyValue.GetType();
if (typeof(DevToolsDomainEntityBase).IsAssignableFrom(propertyValueType))
{
propertyValue = ((DevToolsDomainEntityBase)(propertyValue)).ToDictionary();
}
else if (propertyValueType.IsEnum)
{
propertyValue = EnumToString((Enum)propertyValue);
}
else if(propertyValueType.IsGenericType)
{
var nullableType = Nullable.GetUnderlyingType(propertyValueType);
if(nullableType != null && nullableType.IsEnum)
{
propertyValue = EnumToString((Enum)propertyValue);
}
}
else if(propertyValueType.IsArray && propertyValueType.GetElementType().IsEnum)
{
propertyValue = EnumToString((Array)propertyValue);
}
dict.Add(propertyName, propertyValue);
}
return dict;
}
#else
public IDictionary<string, object> ToDictionary()
{
var dict = new Dictionary<string, object>();
var properties = GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (var prop in properties)
{
var dataMemberAttribute = (DataMemberAttribute)Attribute.GetCustomAttribute(prop, typeof(DataMemberAttribute), false);
//Only add members that have DataMemberAttribute
if (dataMemberAttribute == null)
{
continue;
}
var propertyName = dataMemberAttribute.Name;
var propertyRequired = dataMemberAttribute.IsRequired;
var propertyValue = prop.GetValue(this);
if (propertyRequired && propertyValue == null)
{
throw new DevToolsClientException(prop.Name + " is required");
}
//Not required and value null, don't add to dictionary
if (propertyValue == null)
{
continue;
}
var propertyValueType = propertyValue.GetType();
if (typeof(DevToolsDomainEntityBase).IsAssignableFrom(propertyValueType))
{
propertyValue = ((DevToolsDomainEntityBase)(propertyValue)).ToDictionary();
}
dict.Add(propertyName, propertyValue);
}
return dict;
}
#endif
}
}

View file

@ -0,0 +1,41 @@
// Copyright © 2020 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.Runtime.Serialization;
namespace CefSharp.DevTools
{
/// <summary>
/// Error Message parsed from JSON
/// e.g. {"code":-32601,"message":"'Browser.getWindowForTarget' wasn't found"}
/// </summary>
public class DevToolsDomainErrorResponse
{
/// <summary>
/// Message Id
/// </summary>
[IgnoreDataMember]
public int MessageId { get; set; }
/// <summary>
/// Error Code
/// </summary>
[DataMember(Name = "code", IsRequired = true)]
public int Code
{
get;
set;
}
/// <summary>
/// Error Message
/// </summary>
[DataMember(Name = "message", IsRequired = true)]
public string Message
{
get;
set;
}
}
}

View file

@ -0,0 +1,15 @@
// Copyright © 2020 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.DevTools
{
[System.Runtime.Serialization.DataContractAttribute]
public abstract class DevToolsDomainResponseBase
{
public byte[] Convert(string data)
{
return System.Convert.FromBase64String(data);
}
}
}

View file

@ -0,0 +1,31 @@
// Copyright © 2020 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.DevTools
{
/// <summary>
/// DevTools Event EventAargs
/// </summary>
public class DevToolsEventArgs : EventArgs
{
/// <summary>
/// Method
/// </summary>
public string EventName { get; private set; }
/// <summary>
/// Event paramaters as Json string
/// </summary>
public string ParametersAsJsonString { get; private set; }
public DevToolsEventArgs(string eventName, string paramsAsJsonString)
{
EventName = eventName;
ParametersAsJsonString = paramsAsJsonString;
}
}
}

View file

@ -0,0 +1,61 @@
// Copyright © 2020 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.IO;
using System.Runtime.Serialization.Json;
using System.Text;
namespace CefSharp.DevTools
{
/// <summary>
/// DevTools Method Response
/// </summary>
public class DevToolsMethodResponse
{
/// <summary>
/// MessageId
/// </summary>
public int MessageId { get; set; }
/// <summary>
/// Success
/// </summary>
public bool Success { get; set; }
/// <summary>
/// Method Response as Json string
/// </summary>
public string ResponseAsJsonString { get; set; }
internal T DeserializeJson<T>()
{
if (Success)
{
#if NETCOREAPP
var options = new System.Text.Json.JsonSerializerOptions
{
//AllowTrailingCommas = true,
PropertyNameCaseInsensitive = true,
IgnoreNullValues = true,
//PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase
};
options.Converters.Add(new Internals.Json.JsonEnumConverterFactory());
return System.Text.Json.JsonSerializer.Deserialize<T>(ResponseAsJsonString, options);
#else
var bytes = Encoding.UTF8.GetBytes(ResponseAsJsonString);
using (var ms = new MemoryStream(bytes))
{
var dcs = new DataContractJsonSerializer(typeof(T));
return (T)dcs.ReadObject(ms);
}
#endif
}
throw new DevToolsClientException(ResponseAsJsonString);
}
}
}

View file

@ -0,0 +1,17 @@
// Copyright © 2020 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.Specialized;
namespace CefSharp.DevTools.Network
{
//TODO: Properly implement this type
public class Headers : NameValueCollection
{
public NameValueCollection ToDictionary()
{
return this;
}
}
}

View file

@ -0,0 +1,26 @@
// Copyright © 2020 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;
using System.Threading.Tasks;
namespace CefSharp.DevTools
{
/// <summary>
/// DevTools Client
/// </summary>
public interface IDevToolsClient
{
/// <summary>
/// Execute a method call over the DevTools protocol. This method can be called on any thread.
/// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details
/// of supported methods and the expected <paramref name="parameters"/> dictionary contents.
/// </summary>
/// <param name="method">is the method name</param>
/// <param name="parameters">are the method parameters represented as a dictionary,
/// which may be empty.</param>
/// <returns>return a Task that can be awaited to obtain the method result</returns>
Task<DevToolsMethodResponse> ExecuteDevToolsMethodAsync(string method, IDictionary<string, object> parameters = null);
}
}

View file

@ -0,0 +1,10 @@
// Copyright © 2020 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.DevTools.Tracing
{
public class MemoryDumpConfig
{
}
}

View file

@ -0,0 +1,138 @@
// Copyright © 2020 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;
using System.Threading.Tasks;
using CefSharp.DevTools;
using CefSharp.Internals;
using CefSharp.Web;
namespace CefSharp
{
/// <summary>
/// Extensions for accessing DevTools through <see cref="IBrowserHost"/>
/// </summary>
public static class DevToolsExtensions
{
/// <summary>
/// Execute a method call over the DevTools protocol. This is a more structured
/// version of SendDevToolsMessage.
/// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details
/// of supported methods and the expected <paramref name="paramsAsJson"/> dictionary contents.
/// See the SendDevToolsMessage documentation for additional usage information.
/// </summary>
/// <param name="messageId">is an incremental number that uniquely identifies the message (pass 0 to have the next number assigned
/// automatically based on previous values)</param>
/// <param name="method">is the method name</param>
/// <param name="parameters">are the method parameters represented as a <see cref="JsonString"/>,
/// which may be empty.</param>
/// <returns>return the assigned message Id if called on the CEF UI thread and the message was
/// successfully submitted for validation, otherwise 0</returns>
public static int ExecuteDevToolsMethod(this IBrowserHost browserHost, int messageId, string method, JsonString parameters)
{
WebBrowserExtensions.ThrowExceptionIfBrowserHostNull(browserHost);
var json = parameters == null ? null : parameters.Json;
return browserHost.ExecuteDevToolsMethod(messageId, method, json);
}
/// <summary>
/// Execute a method call over the DevTools protocol. This is a more structured
/// version of SendDevToolsMessage. <see cref="ExecuteDevToolsMethod"/> can only be called on the
/// CEF UI Thread, this method can be called on any thread.
/// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details
/// of supported methods and the expected <paramref name="parameters"/> dictionary contents.
/// See the SendDevToolsMessage documentation for additional usage information.
/// </summary>
/// <param name="browser">the browser instance</param>
/// <param name="messageId">is an incremental number that uniquely identifies the message (pass 0 to have the next number assigned
/// automatically based on previous values)</param>
/// <param name="method">is the method name</param>
/// <param name="parameters">are the method parameters represented as a dictionary,
/// which may be empty.</param>
/// <returns>return a Task that can be awaited to obtain the assigned message Id. If the message was
/// unsuccessfully submitted for validation, this value will be 0.</returns>
public static Task<int> ExecuteDevToolsMethodAsync(this IBrowser browser, int messageId, string method, IDictionary<string, object> parameters = null)
{
WebBrowserExtensions.ThrowExceptionIfBrowserNull(browser);
var browserHost = browser.GetHost();
WebBrowserExtensions.ThrowExceptionIfBrowserHostNull(browserHost);
if (CefThread.CurrentlyOnUiThread)
{
return Task.FromResult(browserHost.ExecuteDevToolsMethod(messageId, method, parameters));
}
if (CefThread.CanExecuteOnUiThread)
{
return CefThread.ExecuteOnUiThread(() =>
{
return browserHost.ExecuteDevToolsMethod(messageId, method, parameters);
});
}
//CEF returns 0 to signify failure, we'll do the same.
return Task.FromResult(0);
}
/// <summary>
/// Execute a method call over the DevTools protocol. This is a more structured
/// version of SendDevToolsMessage. <see cref="ExecuteDevToolsMethod"/> can only be called on the
/// CEF UI Thread, this method can be called on any thread.
/// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details
/// of supported methods and the expected <paramref name="parameters"/> dictionary contents.
/// See the SendDevToolsMessage documentation for additional usage information.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser instance</param>
/// <param name="messageId">is an incremental number that uniquely identifies the message (pass 0 to have the next number assigned
/// automatically based on previous values)</param>
/// <param name="method">is the method name</param>
/// <param name="parameters">are the method parameters represented as a dictionary,
/// which may be empty.</param>
/// <returns>return a Task that can be awaited to obtain the assigned message Id. If the message was
/// unsuccessfully submitted for validation, this value will be 0.</returns>
public static Task<int> ExecuteDevToolsMethodAsync(this IWebBrowser chromiumWebBrowser, int messageId, string method, IDictionary<string, object> parameters = null)
{
var browser = chromiumWebBrowser.GetBrowser();
return browser.ExecuteDevToolsMethodAsync(messageId, method, parameters);
}
/// <summary>
/// Gets a new Instance of the DevTools client for the chromiumWebBrowser
/// instance.
/// </summary>
/// <param name="chromiumWebBrowser">the chromiumWebBrowser instance</param>
/// <returns>DevToolsClient</returns>
public static DevToolsClient GetDevToolsClient(this IWebBrowser chromiumWebBrowser)
{
var browser = chromiumWebBrowser.GetBrowser();
return browser.GetDevToolsClient();
}
/// <summary>
/// Gets a new Instance of the DevTools client
/// </summary>
/// <param name="browser">the IBrowser instance</param>
/// <returns>DevToolsClient</returns>
public static DevToolsClient GetDevToolsClient(this IBrowser browser)
{
var browserHost = browser.GetHost();
WebBrowserExtensions.ThrowExceptionIfBrowserHostNull(browserHost);
var devToolsClient = new DevToolsClient(browser);
var observerRegistration = browserHost.AddDevToolsMessageObserver(devToolsClient);
devToolsClient.SetDevToolsObserverRegistration(observerRegistration);
return devToolsClient;
}
}
}

View file

@ -0,0 +1,146 @@
// Copyright © 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.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
namespace CefSharp
{
/// <summary>
/// Represents a node in the browser's DOM.
/// </summary>
public class DomNode : IDomNode
{
private readonly IDictionary<string, string> attributes;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="tagName">Name of the tag.</param>
/// <param name="attributes">The attributes.</param>
public DomNode(string tagName, IDictionary<string, string> attributes)
{
TagName = tagName;
this.attributes = attributes;
}
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>
/// A string that represents the current object.
/// </returns>
public override string ToString()
{
var sb = new StringBuilder();
if (attributes != null)
{
foreach (var pair in attributes)
{
sb.AppendFormat("{0}{1}:'{2}'", 0 < sb.Length ? ", " : String.Empty, pair.Key, pair.Value);
}
}
if (!String.IsNullOrWhiteSpace(TagName))
{
sb.Insert(0, String.Format("{0} ", TagName));
}
if (sb.Length < 1)
{
return base.ToString();
}
return sb.ToString();
}
/// <summary>
/// Get the value of an attribute.
/// </summary>
/// <param name="name">The name of the attribute value to get.</param>
/// <returns>
/// The attribute value if the name exists in the DomNode's attributes. Null if the name does not exist.
/// </returns>
public string this[string name]
{
get
{
if (attributes == null || attributes.Count < 1 || !attributes.ContainsKey(name))
{
return null;
}
return attributes[name];
}
}
/// <summary>
/// The name of the HTML element.
/// </summary>
/// <value>
/// The name of the tag.
/// </value>
public string TagName { get; private set; }
/// <summary>
/// Get a read only list of the attribute names.
/// </summary>
/// <value>
/// A list of names of the attributes.
/// </value>
public ReadOnlyCollection<string> AttributeNames
{
get
{
if (attributes == null)
{
return new ReadOnlyCollection<string>(new List<string>());
}
return Array.AsReadOnly<string>(attributes.Keys.ToArray());
}
}
/// <summary>
/// Determine if the DomNode has the requested attribute.
/// </summary>
/// <param name="attributeName">The name of the attribute value.</param>
/// <returns>
/// True if the attribute exists in the DomNode, false if it does not.
/// </returns>
public bool HasAttribute(string attributeName)
{
if (attributes == null)
{
return false;
}
return attributes.ContainsKey(attributeName);
}
/// <summary>
/// Gets the enumerator.
/// </summary>
/// <returns>
/// The enumerator.
/// </returns>
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
if (attributes == null)
{
return new Dictionary<string, string>().GetEnumerator();
}
return attributes.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

View file

@ -0,0 +1,99 @@
// Copyright © 2014 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>
/// Class used to represent a download item.
/// </summary>
public sealed class DownloadItem
{
/// <summary>
/// Returns true if this object is valid. Do not call any other methods if this function returns false.
/// </summary>
public bool IsValid { get; set; }
/// <summary>
/// Returns true if the download is in progress.
/// </summary>
public bool IsInProgress { get; set; }
/// <summary>
/// Returns true if the download is complete.
/// </summary>
public bool IsComplete { get; set; }
/// <summary>
/// Returns true if the download has been canceled or interrupted.
/// </summary>
public bool IsCancelled { get; set; }
/// <summary>
/// Returns a simple speed estimate in bytes/s.
/// </summary>
public Int64 CurrentSpeed { get; set; }
/// <summary>
/// Returns the rough percent complete or -1 if the receive total size is unknown.
/// </summary>
public int PercentComplete { get; set; }
/// <summary>
/// Returns the total number of bytes.
/// </summary>
public Int64 TotalBytes { get; set; }
/// <summary>
/// Returns the number of received bytes.
/// </summary>
public Int64 ReceivedBytes { get; set; }
/// <summary>
/// Returns the time that the download started
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// Returns the time that the download ended
/// </summary>
public DateTime? EndTime { get; set; }
/// <summary>
/// Returns the full path to the downloaded or downloading file.
/// </summary>
public string FullPath { get; set; }
/// <summary>
/// Returns the unique identifier for this download.
/// </summary>
public int Id { get; set; }
/// <summary>
/// Returns the URL.
/// </summary>
public string Url { get; set; }
/// <summary>
/// Returns the URL as it was before any redirects.
/// </summary>
public string OriginalUrl { get; set; }
/// <summary>
/// Returns the suggested file name.
/// </summary>
public string SuggestedFileName { get; set; }
/// <summary>
/// Returns the content disposition.
/// </summary>
public string ContentDisposition { get; set; }
/// <summary>
/// Returns the mime type.
/// </summary>
public string MimeType { get; set; }
}
}

View file

@ -0,0 +1,27 @@
// Copyright © 2014 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.Enums
{
/// <summary>
/// Describes how to interpret the alpha component of a pixel.
/// </summary>
public enum AlphaType
{
/// <summary>
/// No transparency. The alpha component is ignored.
/// </summary>
Opaque,
/// <summary>
/// Transparency with pre-multiplied alpha component.
/// </summary>
PreMultiplied,
/// <summary>
/// Transparency with post-multiplied alpha component.
/// </summary>
PostMultiplied
}
}

View file

@ -0,0 +1,32 @@
// Copyright © 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.
namespace CefSharp
{
/// <summary>
/// Lists the errors that can be reported during Widevine Content Decryption Module (CDM) registration.
/// </summary>
public enum CdmRegistrationErrorCode
{
/// <summary>
/// No error. Registration completed successfully.
/// </summary>
None,
/// <summary>
/// Required files or manifest contents are missing.
/// </summary>
IncorrectContents,
/// <summary>
/// The CDM is incompatible with the current Chromium version.
/// </summary>
Incompatible,
/// <summary>
/// CDM registration is not supported at this time.
/// </summary>
NotSupported,
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,38 @@
// Copyright © 2013 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>
/// Supported event bit flags.
/// </summary>
[FlagsAttribute]
public enum CefEventFlags : uint
{
None = 0,
CapsLockOn = 1 << 0,
ShiftDown = 1 << 1,
ControlDown = 1 << 2,
AltDown = 1 << 3,
LeftMouseButton = 1 << 4,
MiddleMouseButton = 1 << 5,
RightMouseButton = 1 << 6,
/// <summary>
/// Mac OS-X command key.
/// </summary>
CommandDown = 1 << 7,
NumLockOn = 1 << 8,
IsKeyPad = 1 << 9,
IsLeft = 1 << 10,
IsRight = 1 << 11,
AltGrDown = 1 << 12
}
}

View file

@ -0,0 +1,24 @@
// Copyright © 2018 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>
/// FileDialog Flags
/// </summary>
[Flags]
public enum CefFileDialogFlags
{
/// <summary>
/// Prompt to overwrite if the user selects an existing file with the Save dialog.
/// </summary>
OverwritePrompt = 0x01000000,
/// <summary>
/// Do not display read-only files.
/// </summary>
HideReadOnly = 0x02000000,
}
}

View file

@ -0,0 +1,29 @@
// Copyright © 2014 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
{
/// <summary>
/// CefFileDialogMode (Based on cef_file_dialog_mode_t)
/// </summary>
public enum CefFileDialogMode
{
/// <summary>
/// Requires that the file exists before allowing the user to pick it.
/// </summary>
Open,
/// <summary>
/// Like Open, but allows picking multiple files to open.
/// </summary>
OpenMultiple,
/// <summary>
/// Like Open, but selects a folder to open.
/// </summary>
OpenFolder,
/// <summary>
/// Allows picking a nonexistent file, and prompts to overwrite if the file already exists.
/// </summary>
Save
}
}

View file

@ -0,0 +1,21 @@
// Copyright © 2014 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
{
/// <summary>
/// Focus Source
/// </summary>
public enum CefFocusSource
{
/// <summary>
/// The source is explicit navigation via the API (LoadURL(), etc).
/// </summary>
FocusSourceNavigation = 0,
/// <summary>
/// The source is a system-generated focus event.
/// </summary>
FocusSourceSystem
}
}

View file

@ -0,0 +1,25 @@
// Copyright © 2013 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
{
/// <summary>
/// Supported JavaScript dialog types.
/// </summary>
public enum CefJsDialogType
{
/// <summary>
/// Alert Dialog
/// </summary>
Alert = 0,
/// <summary>
/// Confirm Dialog
/// </summary>
Confirm,
/// <summary>
/// Prompt Dialog
/// </summary>
Prompt
}
}

View file

@ -0,0 +1,58 @@
// Copyright © 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 CefMenuCommand
{
NotFound = -1,
// Navigation.
Back = 100,
Forward = 101,
Reload = 102,
ReloadNoCache = 103,
StopLoad = 104,
// Editing.
Undo = 110,
Redo = 111,
Cut = 112,
Copy = 113,
Paste = 114,
Delete = 115,
SelectAll = 116,
// Miscellaneous.
Find = 130,
Print = 131,
ViewSource = 132,
// Spell checking word correction suggestions.
SpellCheckSuggestion0 = 200,
SpellCheckSuggestion1 = 201,
SpellCheckSuggestion2 = 202,
SpellCheckSuggestion3 = 203,
SpellCheckSuggestion4 = 204,
SpellCheckLastSuggestion = 204,
SpellCheckNoSuggestions = 205,
AddToDictionary = 206,
/// <summary>
/// Custom menu items originating from the renderer process. For example, plugin placeholder menu items or Flash menu items.
/// This is the first entry
/// </summary>
CustomFirst = 220,
/// <summary>
/// Custom menu items originating from the renderer process. For example, plugin placeholder menu items or Flash menu items.
/// This is the last entry
/// </summary>
CustomLast = 250,
// All user-defined menu IDs should come between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges
// defined in the tools/gritsettings/resource_ids file.
UserFirst = 26500,
UserLast = 28500
}
}

View file

@ -0,0 +1,32 @@
// Copyright © 2014 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
{
/// <summary>
/// Margin type for PDF printing.
/// </summary>
public enum CefPdfPrintMarginType
{
/// <summary>
/// Default margins.
/// </summary>
Default,
/// <summary>
/// No margins.
/// </summary>
None,
/// <summary>
/// Minimum margins
/// </summary>
Minimum,
/// <summary>
/// Custom margins.
/// </summary>
Custom
}
}

View file

@ -0,0 +1,27 @@
// Copyright © 2014 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
{
/// <summary>
/// Return value types.
/// </summary>
public enum CefReturnValue
{
/// <summary>
/// Cancel immediately.
/// </summary>
Cancel = 0,
/// <summary>
/// Continue immediately.
/// </summary>
Continue,
/// <summary>
/// Continue asynchronously (usually via a callback).
/// </summary>
ContinueAsync
}
}

View file

@ -0,0 +1,25 @@
// Copyright © 2014 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
{
/// <summary>
/// Represents the state of a setting.
/// </summary>
public enum CefState
{
/// <summary>
/// Use the default state for the setting.
/// </summary>
Default = 0,
/// <summary>
/// Enable or allow the setting.
/// </summary>
Enabled,
/// <summary>
/// Disable or disallow the setting.
/// </summary>
Disabled,
}
}

View file

@ -0,0 +1,29 @@
// Copyright © 2014 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
{
/// <summary>
/// Process termination status values.
/// </summary>
public enum CefTerminationStatus
{
/// <summary>
/// Non-zero exit status.
/// </summary>
AbnormalTermination = 0,
/// <summary>
/// SIGKILL or task manager kill.
/// </summary>
ProcessWasKilled,
/// <summary>
/// Segmentation fault.
/// </summary>
ProcessCrashed,
/// <summary>
/// Out of memory. Some platforms may use ProcessCrashed instead.
/// </summary>
OutOfMemory
}
}

View file

@ -0,0 +1,59 @@
// Copyright © 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
{
/// <summary>
/// Managed enum for cef_thread_id_t/CefThreadId
/// </summary>
public enum CefThreadIds
{
// BROWSER PROCESS THREADS -- Only available in the browser process.
/// <summary>
/// The CEF UI thread in the browser. In CefSharp this is ALWAYS
/// separate from the application's main thread (and thus the main
/// WinForm UI thread).
/// </summary>
TID_UI,
/// <summary>
/// Used to interact with the database.
/// </summary>
TID_DB,
/// <summary>
/// Used to interact with the file system.
/// </summary>
TID_FILE,
/// <summary>
/// Used for file system operations that block user interactions.
/// Responsiveness of this thread affects users.
/// </summary>
TID_FILE_USER_BLOCKING,
/// <summary>
/// Used to launch and terminate browser processes.
/// </summary>
TID_PROCESS_LAUNCHER,
/// <summary>
/// Used to handle slow HTTP cache operations.
/// </summary>
TID_CACHE,
/// <summary>
/// Used to process IPC and network messages.
/// </summary>
TID_IO,
// RENDER PROCESS THREADS -- Only available in the render process.
/// <summary>
/// The main thread in the renderer. Used for all WebKit and V8 interaction.
/// </summary>
TID_RENDERER,
}
}

View file

@ -0,0 +1,97 @@
// Copyright © 2016 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>
///
/// Supported certificate status code values. See net\cert\cert_status_flags.h
/// for more information. CERT_STATUS_NONE is new in CEF because we use an
/// enum while cert_status_flags.h uses a typedef and static const variables.
/// </summary>
[Flags]
public enum CertStatus
{
/// <summary>
/// None
/// </summary>
None = 0,
/// <summary>
/// CommonNameInvalid
/// </summary>
CommonNameInvalid = 1 << 0,
/// <summary>
/// DateInvalid
/// </summary>
DateInvalid = 1 << 1,
/// <summary>
/// AuthorityInvalid
/// </summary>
AuthorityInvalid = 1 << 2,
// 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP).
/// <summary>
/// NoRevocation_Mechanism
/// </summary>
NoRevocation_Mechanism = 1 << 4,
/// <summary>
/// UnableToCheckRevocation
/// </summary>
UnableToCheckRevocation = 1 << 5,
/// <summary>
/// Revoked
/// </summary>
Revoked = 1 << 6,
/// <summary>
/// Invalid
/// </summary>
Invalid = 1 << 7,
/// <summary>
/// WeakSignatureAlgorithm
/// </summary>
WeakSignatureAlgorithm = 1 << 8,
// 1 << 9 was used for CERT_STATUS_NOT_IN_DNS
/// <summary>
/// NonUniqueName
/// </summary>
NonUniqueName = 1 << 10,
/// <summary>
/// WeakKey
/// </summary>
WeakKey = 1 << 11,
// 1 << 12 was used for CERT_STATUS_WEAK_DH_KEY
/// <summary>
/// PinnedKeyMissing
/// </summary>
PinnedKeyMissing = 1 << 13,
/// <summary>
/// NameConstraintViolation
/// </summary>
NameConstraintViolation = 1 << 14,
/// <summary>
/// ValidityTooLong
/// </summary>
ValidityTooLong = 1 << 15,
// Bits 16 to 31 are for non-error statuses.
/// <summary>
/// IsEv
/// </summary>
IsEv = 1 << 16,
/// <summary>
/// RevCheckingEnabled
/// </summary>
RevCheckingEnabled = 1 << 17,
// Bit 18 was CERT_STATUS_IS_DNSSEC
/// <summary>
/// Sha1SignaturePresent
/// </summary>
Sha1SignaturePresent = 1 << 19,
/// <summary>
/// CtComplianceFailed
/// </summary>
CtComplianceFailed = 1 << 20
}
}

View file

@ -0,0 +1,187 @@
// 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.
namespace CefSharp.Enums
{
/// <summary>
/// Enumerates the various representations of the ordering of audio channels.
/// Logged to UMA, so never reuse a value, always add new/greater ones!
/// See media\base\channel_layout.h
/// </summary>
public enum ChannelLayout
{
/// <summary>
/// None
/// </summary>
LayoutNone = 0,
/// <summary>
/// Unsupported
/// </summary>
LayoutUnsupported = 1,
/// <summary>
/// Front C
/// </summary>
LayoutMono = 2,
/// <summary>
/// Front L, Front R
/// </summary>
LayoutStereo = 3,
/// <summary>
/// Front L, Front R, Back C
/// </summary>
Layout2_1 = 4,
/// <summary>
/// Front L, Front R, Front C
/// </summary>
LayoutSurround = 5,
/// <summary>
/// Front L, Front R, Front C, Back C
/// </summary>
Layout4_0 = 6,
/// <summary>
/// Front L, Front R, Side L, Side R
/// </summary>
Layout2_2 = 7,
/// <summary>
/// Front L, Front R, Back L, Back R
/// </summary>
LayoutQuad = 8,
/// <summary>
/// Front L, Front R, Front C, Side L, Side R
/// </summary>
Layout5_0 = 9,
/// <summary>
/// Front L, Front R, Front C, LFE, Side L, Side R
/// </summary>
Layout5_1 = 10,
/// <summary>
/// Front L, Front R, Front C, Back L, Back R
/// </summary>
Layout5_0Back = 11,
/// <summary>
/// Front L, Front R, Front C, LFE, Back L, Back R
/// </summary>
Layout5_1Back = 12,
/// <summary>
/// Front L, Front R, Front C, Side L, Side R, Back L, Back R
/// </summary>
Layout7_0 = 13,
/// <summary>
/// Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
/// </summary>
Layout7_1 = 14,
/// <summary>
/// Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
/// </summary>
Layout7_1Wide = 15,
/// <summary>
/// Stereo L, Stereo R
/// </summary>
LayoutStereoDownMix = 16,
/// <summary>
/// Stereo L, Stereo R, LFE
/// </summary>
Layout2Point1 = 17,
/// <summary>
/// Stereo L, Stereo R, Front C, LFE
/// </summary>
Layout3_1 = 18,
/// <summary>
/// Stereo L, Stereo R, Front C, Rear C, LFE
/// </summary>
Layout4_1 = 19,
/// <summary>
/// Stereo L, Stereo R, Front C, Side L, Side R, Back C
/// </summary>
Layout6_0 = 20,
/// <summary>
/// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
/// </summary>
Layout6_0Front = 21,
/// <summary>
/// Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
/// </summary>
LayoutHexagonal = 22,
/// <summary>
/// Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
/// </summary>
Layout6_1 = 23,
/// <summary>
/// Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
/// </summary>
Layout6_1Back = 24,
/// <summary>
/// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
/// </summary>
Layout6_1Front = 25,
/// <summary>
/// Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
/// </summary>
Layout7_0Front = 26,
/// <summary>
/// Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
/// </summary>
Layout7_1WideBack = 27,
/// <summary>
/// Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
/// </summary>
LayoutOctagonal = 28,
/// <summary>
/// Channels are not explicitly mapped to speakers.
/// </summary>
LayoutDiscrete = 29,
/// <summary>
/// Front L, Front R, Front C. Front C contains the keyboard mic audio. This
/// layout is only intended for input for WebRTC. The Front C channel
/// is stripped away in the WebRTC audio input pipeline and never seen outside
/// of that.
/// </summary>
LayoutStereoKeyboardAndMic = 30,
/// <summary>
/// Front L, Front R, Side L, Side R, LFE
/// </summary>
Layout4_1QuadSize = 31,
/// <summary>
/// Actual channel layout is specified in the bitstream and the actual channel
/// count is unknown at Chromium media pipeline level (useful for audio
/// pass-through mode).
/// </summary>
LayoutBitstream = 32,
// Max value, must always equal the largest entry ever logged.
LayoutMax = LayoutBitstream
}
}

View file

@ -0,0 +1,21 @@
// Copyright © 2018 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.Enums
{
/// <summary>
/// Describes how to interpret the components of a pixel.
/// </summary>
public enum ColorType
{
/// <summary>
/// RGBA with 8 bits per pixel (32bits total).
/// </summary>
Rgba8888,
/// <summary>
/// BGRA with 8 bits per pixel (32bits total).
/// </summary>
Bgra8888
}
}

View file

@ -0,0 +1,29 @@
// Copyright © 2020 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.Enums
{
/// <summary>
/// Composition underline style.
/// </summary>
public enum CompositionUnderlineStyle
{
/// <summary>
/// Solid
/// </summary>
Solid,
/// <summary>
/// Dot
/// </summary>
Dot,
/// <summary>
/// Dash
/// </summary>
Dash,
/// <summary>
/// None
/// </summary>
None
}
}

View file

@ -0,0 +1,52 @@
// Copyright © 2016 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>
/// Supported context menu edit state bit flags.
/// </summary>
[Flags]
public enum ContextMenuEditState
{
/// <summary>
/// A binary constant representing the none flag.
/// </summary>
None = 0,
/// <summary>
/// A binary constant representing the can undo flag.
/// </summary>
CanUndo = 1 << 0,
/// <summary>
/// A binary constant representing the can redo flag.
/// </summary>
CanRedo = 1 << 1,
/// <summary>
/// A binary constant representing the can cut flag.
/// </summary>
CanCut = 1 << 2,
/// <summary>
/// A binary constant representing the can copy flag.
/// </summary>
CanCopy = 1 << 3,
/// <summary>
/// A binary constant representing the can paste flag.
/// </summary>
CanPaste = 1 << 4,
/// <summary>
/// A binary constant representing the can delete flag.
/// </summary>
CanDelete = 1 << 5,
/// <summary>
/// A binary constant representing the can select all flag.
/// </summary>
CanSelectAll = 1 << 6,
/// <summary>
/// A binary constant representing the can translate flag.
/// </summary>
CanTranslate = 1 << 7,
}
}

View file

@ -0,0 +1,60 @@
// Copyright © 2016 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>
/// Supported context menu media state bit flags.
/// </summary>
[Flags]
public enum ContextMenuMediaState
{
/// <summary>
/// None
/// </summary>
None = 0,
/// <summary>
/// Error
/// </summary>
Error = 1 << 0,
/// <summary>
/// Paused
/// </summary>
Paused = 1 << 1,
/// <summary>
/// Muted
/// </summary>
Muted = 1 << 2,
/// <summary>
/// Loop
/// </summary>
Loop = 1 << 3,
/// <summary>
/// CanSave
/// </summary>
CanSave = 1 << 4,
/// <summary>
/// HasAudio
/// </summary>
HasAudio = 1 << 5,
/// <summary>
/// HasVideo
/// </summary>
HasVideo = 1 << 6,
/// <summary>
/// ControlRootElement
/// </summary>
ControlRootElement = 1 << 7,
/// <summary>
/// CanPrint
/// </summary>
CanPrint = 1 << 8,
/// <summary>
/// CanRotate
/// </summary>
CanRotate = 1 << 9,
}
}

View file

@ -0,0 +1,37 @@
// Copyright © 2016 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
{
/// <summary>
/// Supported context menu media types.
/// </summary>
public enum ContextMenuMediaType
{
/// <summary>
/// No special node is in context.
/// </summary>
None,
/// <summary>
/// An image node is selected.
/// </summary>
Image,
/// <summary>
/// A video node is selected.
/// </summary>
Video,
/// <summary>
/// An audio node is selected.
/// </summary>
Audio,
/// <summary>
/// A file node is selected.
/// </summary>
File,
/// <summary>
/// A plugin node is selected.
/// </summary>
Plugin,
}
}

View file

@ -0,0 +1,44 @@
// Copyright © 2016 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>
/// ContextMenuType
/// </summary>
[Flags]
public enum ContextMenuType
{
/// <summary>
/// No node is selected.
/// </summary>
None = 0,
/// <summary>
/// The top page is selected.
/// </summary>
Page = 1 << 0,
/// <summary>
/// A subframe page is selected.
/// </summary>
Frame = 1 << 1,
/// <summary>
/// A link is selected.
/// </summary>
Link = 1 << 2,
/// <summary>
/// A media node is selected.
/// </summary>
Media = 1 << 3,
/// <summary>
/// There is a textual or mixed selection that is selected.
/// </summary>
Selection = 1 << 4,
/// <summary>
/// An editable element is selected.
/// </summary>
Editable = 1 << 5,
}
}

View file

@ -0,0 +1,25 @@
// Copyright © 2020 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.Enums
{
/// <summary>
/// Cookie priority values.
/// </summary>
public enum CookiePriority
{
/// <summary>
/// Low Priority
/// </summary>
Low = -1,
/// <summary>
/// Medium Priority
/// </summary>
Medium = 0,
/// <summary>
/// High Priority
/// </summary>
High = 1,
}
}

View file

@ -0,0 +1,33 @@
// Copyright © 2020 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.Enums
{
/// <summary>
/// Cookie same site values.
/// </summary>
///<remarks>
/// See https://source.chromium.org/chromium/chromium/src/+/master:net/cookies/cookie_constants.h
///</remarks>
public enum CookieSameSite
{
/// <summary>
/// Unspecified
/// </summary>
Unspecified = 0,
/// <summary>
/// Cookies will be sent in all contexts, i.e sending cross-origin is allowed.
/// None used to be the default value, but recent browser versions made Lax the default value to have reasonably robust defense against some classes of cross-site request forgery (CSRF) attacks.
/// </summary>
NoRestriction,
/// <summary>
/// Cookies are allowed to be sent with top-level navigations and will be sent along with GET request initiated by third party website. This is the default value in modern browsers.
/// </summary>
LaxMode,
/// <summary>
/// Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites.
/// </summary>
StrictMode
}
}

View file

@ -0,0 +1,213 @@
// Copyright © 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.Enums
{
/// <summary>
/// Cursor type values.
/// </summary>
public enum CursorType
{
/// <summary>
/// Pointer
/// </summary>
Pointer = 0,
/// <summary>
/// An enum constant representing the cross option.
/// </summary>
Cross,
/// <summary>
/// An enum constant representing the hand option.
/// </summary>
Hand,
/// <summary>
/// An enum constant representing the beam option.
/// </summary>
IBeam,
/// <summary>
/// An enum constant representing the wait option.
/// </summary>
Wait,
/// <summary>
/// An enum constant representing the help option.
/// </summary>
Help,
/// <summary>
/// An enum constant representing the east resize option.
/// </summary>
EastResize,
/// <summary>
/// An enum constant representing the north resize option.
/// </summary>
NorthResize,
/// <summary>
/// An enum constant representing the northeast resize option.
/// </summary>
NortheastResize,
/// <summary>
/// An enum constant representing the northwest resize option.
/// </summary>
NorthwestResize,
/// <summary>
/// An enum constant representing the south resize option.
/// </summary>
SouthResize,
/// <summary>
/// An enum constant representing the southeast resize option.
/// </summary>
SoutheastResize,
/// <summary>
/// An enum constant representing the southwest resize option.
/// </summary>
SouthwestResize,
/// <summary>
/// An enum constant representing the west resize option.
/// </summary>
WestResize,
/// <summary>
/// An enum constant representing the north south resize option.
/// </summary>
NorthSouthResize,
/// <summary>
/// An enum constant representing the east west resize option.
/// </summary>
EastWestResize,
/// <summary>
/// An enum constant representing the northeast southwest resize option.
/// </summary>
NortheastSouthwestResize,
/// <summary>
/// An enum constant representing the northwest southeast resize option.
/// </summary>
NorthwestSoutheastResize,
/// <summary>
/// An enum constant representing the column resize option.
/// </summary>
ColumnResize,
/// <summary>
/// An enum constant representing the row resize option.
/// </summary>
RowResize,
/// <summary>
/// An enum constant representing the middle panning option.
/// </summary>
MiddlePanning,
/// <summary>
/// An enum constant representing the east panning option.
/// </summary>
EastPanning,
/// <summary>
/// An enum constant representing the north panning option.
/// </summary>
NorthPanning,
/// <summary>
/// An enum constant representing the northeast panning option.
/// </summary>
NortheastPanning,
/// <summary>
/// An enum constant representing the northwest panning option.
/// </summary>
NorthwestPanning,
/// <summary>
/// An enum constant representing the south panning option.
/// </summary>
SouthPanning,
/// <summary>
/// An enum constant representing the southeast panning option.
/// </summary>
SoutheastPanning,
/// <summary>
/// An enum constant representing the southwest panning option.
/// </summary>
SouthwestPanning,
/// <summary>
/// An enum constant representing the west panning option.
/// </summary>
WestPanning,
/// <summary>
/// An enum constant representing the move option.
/// </summary>
Move,
/// <summary>
/// An enum constant representing the vertical text option.
/// </summary>
VerticalText,
/// <summary>
/// An enum constant representing the cell option.
/// </summary>
Cell,
/// <summary>
/// An enum constant representing the context menu option.
/// </summary>
ContextMenu,
/// <summary>
/// An enum constant representing the alias option.
/// </summary>
Alias,
/// <summary>
/// An enum constant representing the progress option.
/// </summary>
Progress,
/// <summary>
/// An enum constant representing the no drop option.
/// </summary>
NoDrop,
/// <summary>
/// An enum constant representing the copy option.
/// </summary>
Copy,
/// <summary>
/// An enum constant representing the none option.
/// </summary>
None,
/// <summary>
/// An enum constant representing the not allowed option.
/// </summary>
NotAllowed,
/// <summary>
/// An enum constant representing the zoom in option.
/// </summary>
ZoomIn,
/// <summary>
/// An enum constant representing the zoom out option.
/// </summary>
ZoomOut,
/// <summary>
/// An enum constant representing the grab option.
/// </summary>
Grab,
/// <summary>
/// An enum constant representing the grabbing option.
/// </summary>
Grabbing,
/// <summary>
/// An enum constant representing the MiddlePanningVertical option.
/// </summary>
MiddlePanningVertical,
/// <summary>
/// An enum constant representing the MiddlePanningHorizontal option.
/// </summary>
MiddlePanningHorizontal,
/// <summary>
/// An enum constant representing the custom option.
/// </summary>
Custom,
/// <summary>
/// DndNone
/// </summary>
DndNone,
/// <summary>
/// DndMove
/// </summary>
DndMove,
/// <summary>
/// DndCopy
/// </summary>
DndCopy,
/// <summary>
/// DndLink
/// </summary>
DndLink
}
}

View file

@ -0,0 +1,48 @@
// Copyright © 2014 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.Enums
{
/// <summary>
/// "Verb" of a drag-and-drop operation as negotiated between the source and destination.
/// </summary>
[Flags]
public enum DragOperationsMask : uint
{
/// <summary>
/// None
/// </summary>
None = 0,
/// <summary>
/// Copy
/// </summary>
Copy = 1,
/// <summary>
/// Link
/// </summary>
Link = 2,
/// <summary>
/// Generic
/// </summary>
Generic = 4,
/// <summary>
/// Private
/// </summary>
Private = 8,
/// <summary>
/// Move
/// </summary>
Move = 16,
/// <summary>
/// Delete
/// </summary>
Delete = 32,
/// <summary>
/// Every drag operation.
/// </summary>
Every = uint.MaxValue
}
}

View file

@ -0,0 +1,28 @@
// Copyright © 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
{
/// <summary>
/// Return values for IResponseFilter
/// </summary>
public enum FilterStatus
{
/// <summary>
/// Some or all of the pre-filter data was read successfully but more data is
/// needed in order to continue filtering (filtered output is pending).
/// </summary>
NeedMoreData,
/// <summary>
/// Some or all of the pre-filter data was read successfully and all available filtered output has been written.
/// </summary>
Done,
/// <summary>
/// An error occurred during filtering.
/// </summary>
Error
}
}

View file

@ -0,0 +1,36 @@
// Copyright © 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
{
/// <summary>
/// Values that represent key event types.
/// </summary>
public enum KeyEventType
{
/// <summary>
/// Notification that a key transitioned from "up" to "down".
/// </summary>
RawKeyDown = 0,
/// <summary>
/// Notification that a key was pressed. This does not necessarily correspond
/// to a character depending on the key and language. Use KEYEVENT_CHAR for
/// character input.
/// </summary>
KeyDown,
/// <summary>
/// Notification that a key was released.
/// </summary>
KeyUp,
/// <summary>
/// Notification that a character was typed. Use this for text input. Key
/// down events may generate 0, 1, or more than one character event depending
/// on the key, locale, and operating system.
/// </summary>
Char
}
}

View file

@ -0,0 +1,33 @@
// Copyright © 2014 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
{
/// <summary>
/// KeyType Enum.
/// Maps to https://magpcss.org/ceforum/apidocs3/projects/(default)/cef_key_event_type_t.html
/// </summary>
public enum KeyType
{
/// <summary>
/// Notification that a key transitioned from"up" to"down".
/// </summary>
RawKeyDown = 0,
/// <summary>
/// Notification that a key was pressed. This does not necessarily correspond to a character depending on the key and language.
/// Use <seealso cref="Char"/> for character input.
/// </summary>
KeyDown,
/// <summary>
/// Notification that a key was released.
/// </summary>
KeyUp,
/// <summary>
/// Notification that a character was typed. Use this for text input. Key
/// down events may generate 0, 1, or more than one character event depending
/// on the key, locale, and operating system.
/// </summary>
Char,
};
}

View file

@ -0,0 +1,47 @@
// Copyright © 2014 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
{
/// <summary>
/// LogSeverity
/// </summary>
public enum LogSeverity
{
/// <summary>
/// Default logging (currently Info logging)
/// </summary>
Default = 0,
/// <summary>
/// Verbose logging.
/// </summary>
Verbose,
/// <summary>
/// Info logging
/// </summary>
Info,
/// <summary>
/// Warning logging
/// </summary>
Warning,
/// <summary>
/// Error logging
/// </summary>
Error,
/// <summary>
/// Fatal logging.
/// </summary>
Fatal,
/// <summary>
/// Disable logging to file for all messages, and to stderr for messages with severity less than FATAL.
/// </summary>
Disable = 99
};
}

View file

@ -0,0 +1,37 @@
// Copyright © 2013 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
{
/// <summary>
/// Supported menu item types.
/// </summary>
public enum MenuItemType
{
/// <summary>
/// An enum constant representing the none option.
/// </summary>
None = 0,
/// <summary>
/// An enum constant representing the command option.
/// </summary>
Command,
/// <summary>
/// An enum constant representing the check option.
/// </summary>
Check,
/// <summary>
/// An enum constant representing the radio option.
/// </summary>
Radio,
/// <summary>
/// An enum constant representing the separator option.
/// </summary>
Separator,
/// <summary>
/// An enum constant representing the sub menu option.
/// </summary>
SubMenu
}
}

View file

@ -0,0 +1,25 @@
// Copyright © 2013 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
{
/// <summary>
/// Values that represent mouse button types.
/// </summary>
public enum MouseButtonType
{
/// <summary>
/// Left Mouse Button
/// </summary>
Left = 0,
/// <summary>
/// Middle Mouse Button
/// </summary>
Middle,
/// <summary>
/// Right Mouse Button
/// </summary>
Right
}
}

View file

@ -0,0 +1,21 @@
// Copyright © 2013 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
{
/// <summary>
/// Paint element types.
/// </summary>
public enum PaintElementType
{
/// <summary>
/// An enum constant representing the view option.
/// </summary>
View = 0,
/// <summary>
/// An enum constant representing the popup option.
/// </summary>
Popup
};
}

View file

@ -0,0 +1,32 @@
// Copyright © 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
{
/// <summary>
/// Plugin policies supported by IPluginHandler.OnBeforePluginLoad.
/// </summary>
public enum PluginPolicy
{
/// <summary>
/// Allow the content
/// </summary>
Allow,
/// <summary>
/// Allow important content and block unimportant content based on heuristics. The user can manually load blocked content.
/// </summary>
DetectImportant,
/// <summary>
/// Block the content. The user can manually load blocked content.
/// </summary>
Block,
/// <summary>
/// Disable the content. The user cannot load disabled content.
/// </summary>
Disable
}
}

View file

@ -0,0 +1,33 @@
// 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.
namespace CefSharp.Enums
{
/// <summary>
/// The device type that caused the event.
/// </summary>
public enum PointerType
{
/// <summary>
/// An enum constant representing the touch option.
/// </summary>
Touch = 0,
/// <summary>
/// An enum constant representing the mouse option.
/// </summary>
Mouse,
/// <summary>
/// An enum constant representing the pen option.
/// </summary>
Pen,
/// <summary>
/// An enum constant representing the eraser option.
/// </summary>
Eraser,
/// <summary>
/// An enum constant representing the unknown option.
/// </summary>
Unknown
}
}

View file

@ -0,0 +1,25 @@
// Copyright © 2014 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
{
/// <summary>
/// Post data elements may represent either bytes or files.
/// </summary>
public enum PostDataElementType
{
/// <summary>
/// An enum constant representing the empty option.
/// </summary>
Empty = 0,
/// <summary>
/// An enum constant representing the bytes option.
/// </summary>
Bytes,
/// <summary>
/// An enum constant representing the file option.
/// </summary>
File
}
}

View file

@ -0,0 +1,73 @@
// Copyright © 2016 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
{
/// <summary>
/// Policy for how the Referrer HTTP header value will be sent during navigation.
/// If the `--no-referrers` command-line flag is specified then the policy value
/// will be ignored and the Referrer value will never be sent.
/// Must be kept synchronized with net::URLRequest::ReferrerPolicy from Chromium.
/// </summary>
public enum ReferrerPolicy
{
/// <summary>
/// Clear the referrer header if the header value is HTTPS but the request
/// destination is HTTP. This is the default behavior.
/// </summary>
ClearReferrerOnTransitionFromSecureToInsecure,
/// <summary>
/// Default which is equivalent to <see cref="ClearReferrerOnTransitionFromSecureToInsecure"/>
/// </summary>
Default = ClearReferrerOnTransitionFromSecureToInsecure,
/// <summary>
/// A slight variant on <see cref="ClearReferrerOnTransitionFromSecureToInsecure"/>:
/// If the request destination is HTTP, an HTTPS referrer will be cleared. If
/// the request's destination is cross-origin with the referrer (but does not
/// downgrade), the referrer's granularity will be stripped down to an origin
/// rather than a full URL. Same-origin requests will send the full referrer.
/// </summary>
ReduceReferrerGranularityOnTransitionCrossOrigin,
/// <summary>
/// Strip the referrer down to an origin when the origin of the referrer is
/// different from the destination's origin.
/// </summary>
OriginOnlyOnTransitionCrossOrigin,
/// <summary>
/// Never change the referrer.
/// </summary>
NeverClearReferrer,
/// <summary>
/// Strip the referrer down to the origin regardless of the redirect location.
/// </summary>
Origin,
/// <summary>
/// Clear the referrer when the request's referrer is cross-origin with the
/// request's destination.
/// </summary>
ClearReferrerOnTransitionCrossOrigin,
/// <summary>
/// Strip the referrer down to the origin, but clear it entirely if the
/// referrer value is HTTPS and the destination is HTTP.
/// </summary>
OriginClearOnTransitionFromSecureToInsecure,
/// <summary>
/// Always clear the referrer regardless of the request destination.
/// </summary>
NoReferrer,
/// <summary>
/// Always the last value in this enumeration.
/// </summary>
LastValue = NoReferrer,
}
}

View file

@ -0,0 +1,85 @@
// Copyright © 2016 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
{
/// <summary>
/// Resource type for a request.
/// </summary>
public enum ResourceType
{
/// <summary>
/// Top level page.
/// </summary>
MainFrame = 0,
/// <summary>
/// Frame or iframe.
/// </summary>
SubFrame,
/// <summary>
/// CSS stylesheet.
/// </summary>
Stylesheet,
/// <summary>
/// External script.
/// </summary>
Script,
/// <summary>
/// Image (jpg/gif/png/etc).
/// </summary>
Image,
/// <summary>
/// Font.
/// </summary>
FontResource,
/// <summary>
/// Some other subresource. This is the default type if the actual type is unknown.
/// </summary>
SubResource,
/// <summary>
/// Object (or embed) tag for a plugin, or a resource that a plugin requested.
/// </summary>
Object,
/// <summary>
/// Media resource.
/// </summary>
Media,
/// <summary>
/// Main resource of a dedicated worker.
/// </summary>
Worker,
/// <summary>
/// Main resource of a shared worker.
/// </summary>
SharedWorker,
/// <summary>
/// Explicitly requested prefetch.
/// </summary>
Prefetch,
/// <summary>
/// Favicon.
/// </summary>
Favicon,
/// <summary>
/// XMLHttpRequest.
/// </summary>
Xhr,
/// <summary>
/// A request for a ping
/// </summary>
Ping,
/// <summary>
/// Main resource of a service worker.
/// </summary>
ServiceWorker,
/// <summary>
/// A report of Content Security Policy violations.
/// </summary>
CspReport,
/// <summary>
/// A resource that a plugin requested.
/// </summary>
PluginResource
}
}

View file

@ -0,0 +1,94 @@
// 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;
namespace CefSharp.Enums
{
/// <summary>
/// Configuration options for registering a custom scheme.
/// These values are used when calling AddCustomScheme.
/// </summary>
[Flags]
public enum SchemeOptions
{
/// <summary>
/// Register scheme without options set
/// </summary>
None = 0,
/// <summary>
/// If Standard is set the scheme will be treated as a
/// standard scheme. Standard schemes are subject to URL canonicalization and
/// parsing rules as defined in the Common Internet Scheme Syntax RFC 1738
/// Section 3.1 available at http://www.ietf.org/rfc/rfc1738.txt
///
/// In particular, the syntax for standard scheme URLs must be of the form:
/// <pre>
/// [scheme]://[username]:[password]@[host]:[port]/[url-path]
/// </pre> Standard scheme URLs must have a host component that is a fully
/// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and
/// Section 2.1 of RFC 1123. These URLs will be canonicalized to
/// "scheme://host/path" in the simplest case and
/// "scheme://username:password@host:port/path" in the most explicit case. For
/// example, "scheme:host/path" and "scheme:///host/path" will both be
/// canonicalized to "scheme://host/path". The origin of a standard scheme URL
/// is the combination of scheme, host and port (i.e., "scheme://host:port" in
/// the most explicit case).
///
/// For non-standard scheme URLs only the "scheme:" component is parsed and
/// canonicalized. The remainder of the URL will be passed to the handler as-
/// is. For example, "scheme:///some%20text" will remain the same. Non-standard
/// scheme URLs cannot be used as a target for form submission.
/// </summary>
Standard = 1 << 0,
/// <summary>
/// If Local is set the scheme will be treated with the same
/// security rules as those applied to "file" URLs. Normal pages cannot link to
/// or access local URLs. Also, by default, local URLs can only perform
/// XMLHttpRequest calls to the same URL (origin + path) that originated the
/// request. To allow XMLHttpRequest calls from a local URL to other URLs with
/// the same origin set the CefSettings.FileAccessFromFileUrlsAllowed
/// value to true. To allow XMLHttpRequest calls from a local URL to all
/// origins set the CefSettings.UniversalAccessFromFileUrlsAllowed value
/// to true.
/// </summary>
Local = 1 << 1,
/// <summary>
/// If DisplayIsolated is set the scheme can only be
/// displayed from other content hosted with the same scheme. For example,
/// pages in other origins cannot create iframes or hyperlinks to URLs with the
/// scheme. For schemes that must be accessible from other schemes don't set
/// this, set CorsEnabled, and use CORS "Access-Control-Allow-Origin" headers
/// to further restrict access.
/// </summary>
DisplayIsolated = 1 << 2,
/// <summary>
/// If Secure is set the scheme will be treated with the same
/// security rules as those applied to "https" URLs. For example, loading this
/// scheme from other secure schemes will not trigger mixed content warnings.
/// </summary>
Secure = 1 << 3,
/// <summary>
/// If CorsEnabled is set the scheme can be sent CORS requests.
/// This value should be set in most cases where Standard is set.
/// </summary>
CorsEnabled = 1 << 4,
/// <summary>
/// If CspBypassing is set the scheme can bypass Content-Security-Policy (CSP) checks.
/// This value should not be set in most cases where Standard is set.
/// </summary>
CspBypassing = 1 << 5,
/// <summary>
/// If FetchEnabled is set the scheme can perform Fetch API requests.
/// </summary>
FetchEnabled = 1 << 6,
}
}

View file

@ -0,0 +1,26 @@
// Copyright © 2016 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
{
/// <summary>
/// Supported SSL content status flags. See content/public/common/ssl_status.h
/// for more information.
/// </summary>
public enum SslContentStatus
{
/// <summary>
/// HTTP page, or HTTPS page with no insecure content..
/// </summary>
NormalContent = 0,
/// <summary>
/// HTTPS page containing "displayed" HTTP resources (e.g. images, CSS).
/// </summary>
DisplayedInsecureContent = 1 << 0,
/// <summary>
/// HTTPS page containing "executed" HTTP resources (i.e. script)
/// </summary>
RanInsecureContent = 1 << 1,
}
}

View file

@ -0,0 +1,46 @@
// Copyright © 2016 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
{
/// <summary>
/// Supported SSL version values. See net/ssl/ssl_connection_status_flags.h
/// for more information.
/// </summary>
public enum SslVersion
{
/// <summary>
/// Unknown SSL version.
/// </summary>
Unknown = 0,
/// <summary>
/// An enum constant representing the ssl 2 option.
/// </summary>
Ssl2 = 1,
/// <summary>
/// An enum constant representing the ssl 3 option.
/// </summary>
Ssl3 = 2,
/// <summary>
/// An enum constant representing the TLS 1.0 option.
/// </summary>
Tls1 = 3,
/// <summary>
/// An enum constant representing the TLS 1.1 option.
/// </summary>
Tls1_1 = 4,
/// <summary>
/// An enum constant representing the TLS 1.2 option.
/// </summary>
Tls1_2 = 5,
/// <summary>
/// An enum constant representing the TLS 1.3 option.
/// </summary>
Tls1_3 = 6,
/// <summary>
/// An enum constant representing the QUIC option.
/// </summary>
Quic = 7,
}
}

View file

@ -0,0 +1,55 @@
// 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.
namespace CefSharp.Enums
{
/// <summary>
/// Input mode of a virtual keyboard. These constants match their equivalents
/// in Chromium's text_input_mode.h and should not be renumbered.
/// See https://html.spec.whatwg.org/#input-modalities:-the-inputmode-attribute
/// </summary>
public enum TextInputMode
{
/// <summary>
/// An enum constant representing the default option.
/// </summary>
Default = 0,
/// <summary>
/// An enum constant representing the none option.
/// </summary>
None,
/// <summary>
/// An enum constant representing the text option.
/// </summary>
Text,
/// <summary>
/// An enum constant representing the tel option.
/// </summary>
Tel,
/// <summary>
/// An enum constant representing the URL option.
/// </summary>
Url,
/// <summary>
/// An enum constant representing the mail option.
/// </summary>
EMail,
/// <summary>
/// An enum constant representing the numeric option.
/// </summary>
Numeric,
/// <summary>
/// An enum constant representing the decimal option.
/// </summary>
Decimal,
/// <summary>
/// An enum constant representing the search option.
/// </summary>
Search,
/// <summary>
/// An enum constant representing the Maximum option.
/// </summary>
Max = Search
}
}

View file

@ -0,0 +1,29 @@
// 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.
namespace CefSharp.Enums
{
/// <summary>
/// Touch Event Type
/// </summary>
public enum TouchEventType
{
/// <summary>
/// An enum constant representing the released option.
/// </summary>
Released = 0,
/// <summary>
/// An enum constant representing the pressed option.
/// </summary>
Pressed,
/// <summary>
/// An enum constant representing the moved option.
/// </summary>
Moved,
/// <summary>
/// An enum constant representing the cancelled option.
/// </summary>
Cancelled
}
}

View file

@ -0,0 +1,105 @@
// Copyright © 2014 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>
/// Transition type for a request. Made up of one source value and 0 or more qualifiers.
/// </summary>
[Flags]
public enum TransitionType : uint
{
/// <summary>
/// Source is a link click or the JavaScript window.open function. This is
/// also the default value for requests like sub-resource loads that are not navigations.
/// </summary>
LinkClicked = 0,
/// <summary>
/// Source is some other "explicit" navigation action such as creating a new
/// browser or using the LoadURL function. This is also the default value
/// for navigations where the actual type is unknown.
/// </summary>
Explicit = 1,
/// <summary>
/// Source is a subframe navigation. This is any content that is automatically
/// loaded in a non-toplevel frame. For example, if a page consists of several
/// frames containing ads, those ad URLs will have this transition type.
/// The user may not even realize the content in these pages is a separate
/// frame, so may not care about the URL.
/// </summary>
AutoSubFrame = 3,
/// <summary>
/// Source is a subframe navigation explicitly requested by the user that will
/// generate new navigation entries in the back/forward list. These are
/// probably more important than frames that were automatically loaded in
/// the background because the user probably cares about the fact that this
/// link was loaded.
/// </summary>
ManualSubFrame = 4,
/// <summary>
/// Source is a form submission by the user. NOTE: In some situations
/// submitting a form does not result in this transition type. This can happen
/// if the form uses a script to submit the contents.
/// </summary>
FormSubmit = 7,
/// <summary>
/// Source is a "reload" of the page via the Reload function or by re-visiting
/// the same URL. NOTE: This is distinct from the concept of whether a
/// particular load uses "reload semantics" (i.e. bypasses cached data).
/// </summary>
Reload = 8,
/// <summary>
/// General mask defining the bits used for the source values.
/// </summary>
SourceMask = 0xFF,
/// <summary>
/// Attempted to visit a URL but was blocked.
/// </summary>
Blocked = 0x00800000,
/// <summary>
/// Used the Forward or Back function to navigate among browsing history.
/// </summary>
ForwardBack = 0x01000000,
/// <summary>
/// The beginning of a navigation chain.
/// </summary>
ChainStart = 0x10000000,
/// <summary>
/// The last transition in a redirect chain.
/// </summary>
ChainEnd = 0x20000000,
/// <summary>
/// Redirects caused by JavaScript or a meta refresh tag on the page.
/// </summary>
ClientRedirect = 0x40000000,
/// <summary>
/// Redirects sent from the server by HTTP headers.
/// </summary>
ServerRedirect = 0x80000000,
/// <summary>
/// Used to test whether a transition involves a redirect.
/// </summary>
IsRedirect = 0xC0000000,
/// <summary>
/// General mask defining the bits used for the qualifiers.
/// </summary>
QualifierMask = 0xFFFFFF00
};
}

View file

@ -0,0 +1,74 @@
// Copyright © 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>
/// Flags used to customize the behavior of CefURLRequest.
/// </summary>
[Flags]
public enum UrlRequestFlags : int
{
/// <summary>
/// Default behavior.
/// </summary>
None = 0,
/// <summary>
/// If set the cache will be skipped when handling the request. Setting this
/// value is equivalent to specifying the "Cache-Control: no-cache" request
/// header. Setting this value in combination with OnlyFromCache will
/// cause the request to fail.
/// </summary>
SkipCache = 1 << 0,
/// <summary>
/// If set the request will fail if it cannot be served from the cache (or some
/// equivalent local store). Setting this value is equivalent to specifying the
/// "Cache-Control: only-if-cached" request header. Setting this value in
/// combination with SkipCache or DisableCache will cause the
/// request to fail.
/// </summary>
OnlyFromCache = 1 << 1,
/// <summary>
/// If set the cache will not be used at all. Setting this value is equivalent
/// to specifying the "Cache-Control: no-store" request header. Setting this
/// value in combination with OnlyFromCache will cause the request to
/// fail.
/// </summary>
DisableCache = 1 << 2,
/// <summary>
/// If set user name, password, and cookies may be sent with the request, and
/// cookies may be saved from the response.
/// </summary>
AllowStoredCredentials = 1 << 3,
/// <summary>
/// If set upload progress events will be generated when a request has a body.
/// </summary>
ReportUploadProgress = 1 << 4,
/// <summary>
/// If set the CefURLRequestClient::OnDownloadData method will not be called.
/// </summary>
NoDownloadData = 1 << 5,
/// <summary>
/// If set 5XX redirect errors will be propagated to the observer instead of
/// automatically re-tried. This currently only applies for requests
/// originated in the browser process.
/// </summary>
NoRetryOn5XX = 1 << 6,
/// <summary>
/// If set 3XX responses will cause the fetch to halt immediately rather than
/// continue through the redirect.
/// </summary>
StopOnRedirect = 1 << 7
}
}

View file

@ -0,0 +1,33 @@
// Copyright © 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
{
/// <summary>
/// Flags that represent CefURLRequest status.
/// </summary>
public enum UrlRequestStatus
{
/// <summary>
/// Unknown status.
/// </summary>
Unknown = 0,
/// <summary>
/// Request succeeded.
/// </summary>
Success,
/// <summary>
/// An IO request is pending, and the caller will be informed when it is completed.
/// </summary>
IoPending,
/// <summary>
/// Request was canceled programatically.
/// </summary>
Canceled,
/// <summary>
/// Request failed for some reason.
/// </summary>
Failed
}
}

View file

@ -0,0 +1,49 @@
// Copyright © 2018 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.Enums
{
/// <summary>
/// Value types supported by <see cref="IValue"/>
/// </summary>
public enum ValueType
{
/// <summary>
/// Invalid type
/// </summary>
Invalid = 0,
/// <summary>
/// Null
/// </summary>
Null = 1,
/// <summary>
/// Boolean
/// </summary>
Bool = 2,
/// <summary>
/// Integer
/// </summary>
Int = 3,
/// <summary>
/// Double
/// </summary>
Double = 4,
/// <summary>
/// String
/// </summary>
String = 5,
/// <summary>
/// Binary
/// </summary>
Binary = 6,
/// <summary>
/// Dictionary
/// </summary>
Dictionary = 7,
/// <summary>
/// List
/// </summary>
List = 8
}
}

Some files were not shown because too many files have changed in this diff Show more