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,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 for visiting cookie values.
/// The methods of this class will always be called on the IO thread.
/// If there are no cookies then Visit will never be called, you must implement
/// Dispose to handle this scenario.
/// </summary>
public interface ICookieVisitor : IDisposable
{
/// <summary>
/// Method that will be called once for each cookie. This method may never be called if no cookies are found.
/// </summary>
/// <param name="cookie">cookie</param>
/// <param name="count">is the 0-based index for the current cookie.</param>
/// <param name="total">is the total number of cookies.</param>
/// <param name="deleteCookie">Set to true to delete the cookie currently being visited.</param>
/// <returns>Return false to stop visiting cookies otherwise true</returns>
bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie);
}
}

View file

@ -0,0 +1,25 @@
// 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>
/// Callback interface for IBrowserHost.GetNavigationEntries.
/// The methods of this class will be called on the CEF UI thread.
/// </summary>
public interface INavigationEntryVisitor : IDisposable
{
/// <summary>
/// Method that will be executed.
/// </summary>
/// <param name="entry">if the navigationEntry will be invalid then </param>
/// <param name="current">is true if this entry is the currently loaded navigation entry</param>
/// <param name="index">is the 0-based index of this entry</param>
/// <param name="total">is the total number of entries.</param>
/// <returns>Return true to continue visiting entries or false to stop.</returns>
bool Visit(NavigationEntry entry, bool current, int index, int total);
}
}

View file

@ -0,0 +1,20 @@
// 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>
/// Implement this interface to receive string values asynchronously.
/// </summary>
public interface IStringVisitor : IDisposable
{
/// <summary>
/// Method that will be executed.
/// </summary>
/// <param name="str">string (result of async execution)</param>
void Visit(string str);
}
}

View file

@ -0,0 +1,26 @@
// 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 for visiting web plugin information.
/// The methods of this class will be called on the CEF UI thread,
/// which by default is not the same as your application UI
/// </summary>
public interface IWebPluginInfoVisitor : IDisposable
{
/// <summary>
/// Method that will be called once for each plugin.
/// This method may never be called if no plugins are found.
/// </summary>
/// <param name="plugin">plugin information</param>
/// <param name="count">is the 0-based index for the current plugin</param>
/// <param name="total">total is the total number of plugins.</param>
/// <returns>Return false to stop visiting plugins otherwise true</returns>
bool Visit(WebPluginInfo plugin, int count, int total);
}
}

View file

@ -0,0 +1,62 @@
// 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>
/// Cookie Visitor implementation that uses a TaskCompletionSource
/// to return a List of cookies
/// </summary>
public class TaskCookieVisitor : ICookieVisitor
{
private readonly TaskCompletionSource<List<Cookie>> taskCompletionSource;
private List<Cookie> list;
/// <summary>
/// Default constructor
/// </summary>
public TaskCookieVisitor()
{
taskCompletionSource = new TaskCompletionSource<List<Cookie>>();
list = new List<Cookie>();
}
bool ICookieVisitor.Visit(Cookie cookie, int count, int total, ref bool deleteCookie)
{
list.Add(cookie);
if (count == (total - 1))
{
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread
taskCompletionSource.TrySetResultAsync(list);
}
return true;
}
void IDisposable.Dispose()
{
if (list != null && list.Count == 0)
{
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread
taskCompletionSource.TrySetResultAsync(list);
}
list = null;
}
/// <summary>
/// Task that can be awaited for the result to be retrieved async
/// </summary>
public Task<List<Cookie>> Task
{
get { return taskCompletionSource.Task; }
}
}
}

View file

@ -0,0 +1,57 @@
// 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>
/// A <see cref="INavigationEntryVisitor"/> that uses a TaskCompletionSource
/// to simplify things
/// </summary>
public class TaskNavigationEntryVisitor : INavigationEntryVisitor
{
private TaskCompletionSource<List<NavigationEntry>> taskCompletionSource;
private List<NavigationEntry> list;
/// <summary>
/// Default constructor
/// </summary>
public TaskNavigationEntryVisitor()
{
taskCompletionSource = new TaskCompletionSource<List<NavigationEntry>>();
list = new List<NavigationEntry>();
}
bool INavigationEntryVisitor.Visit(NavigationEntry entry, bool current, int index, int total)
{
list.Add(entry);
return true;
}
void IDisposable.Dispose()
{
if (list != null)
{
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread
taskCompletionSource.TrySetResultAsync(list);
}
list = null;
taskCompletionSource = null;
}
/// <summary>
/// Task that can be awaited for the result to be retrieved async
/// </summary>
public Task<List<NavigationEntry>> Task
{
get { return taskCompletionSource.Task; }
}
}
}

View file

@ -0,0 +1,49 @@
// 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;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// A <see cref="IStringVisitor"/> that uses a TaskCompletionSource
/// to simplify things
/// </summary>
public class TaskStringVisitor : IStringVisitor
{
private readonly TaskCompletionSource<string> taskCompletionSource;
/// <summary>
/// Default constructor
/// </summary>
public TaskStringVisitor()
{
taskCompletionSource = new TaskCompletionSource<string>();
}
/// <summary>
/// Method that will be executed.
/// </summary>
/// <param name="str">string (result of async execution)</param>
void IStringVisitor.Visit(string str)
{
taskCompletionSource.TrySetResultAsync(str);
}
/// <summary>
/// Task that can be awaited for the result to be retrieved async
/// </summary>
public Task<string> Task
{
get { return taskCompletionSource.Task; }
}
void IDisposable.Dispose()
{
}
}
}

View file

@ -0,0 +1,54 @@
// 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;
using CefSharp.Internals;
namespace CefSharp
{
/// <summary>
/// Provides a visitor implementation of <see cref="IWebPluginInfoVisitor"/>
/// </summary>
public class TaskWebPluginInfoVisitor : IWebPluginInfoVisitor
{
private TaskCompletionSource<List<WebPluginInfo>> taskCompletionSource;
private List<WebPluginInfo> list;
/// <summary>
/// Default constructor
/// </summary>
public TaskWebPluginInfoVisitor()
{
taskCompletionSource = new TaskCompletionSource<List<WebPluginInfo>>();
list = new List<WebPluginInfo>();
}
bool IWebPluginInfoVisitor.Visit(WebPluginInfo plugin, int count, int total)
{
list.Add(plugin);
//Return true to keep visiting plugins
return true;
}
/// <summary>
/// Task that can be awaited for the result to be retrieved async
/// </summary>
public Task<List<WebPluginInfo>> Task
{
get { return taskCompletionSource.Task; }
}
void IDisposable.Dispose()
{
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread
taskCompletionSource.TrySetResultAsync(list);
list = null;
taskCompletionSource = null;
}
}
}