mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-04-29 17:49:43 +00:00
- Added BrowserWindow.AddExtension, RemoveExtension, GetExtensions support. Not yet tested
This commit is contained in:
@@ -2318,9 +2318,19 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the Chrome extension</param>
|
||||
/// <returns></returns>
|
||||
public static string AddExtension(string path)
|
||||
public static Task<string> AddExtensionAsync(string path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("browserWindow-addExtension-completed", (extensionname) => {
|
||||
BridgeConnector.Socket.Off("browserWindow-addExtension-completed");
|
||||
|
||||
taskCompletionSource.SetResult(extensionname.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserWindowAddExtension", path);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2330,7 +2340,7 @@ namespace ElectronNET.API
|
||||
/// <param name="name">Name of the Chrome extension to remove</param>
|
||||
public static void RemoveExtension(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
BridgeConnector.Socket.Emit("browserWindowRemoveExtension", name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2338,9 +2348,20 @@ namespace ElectronNET.API
|
||||
/// Note: This API cannot be called before the ready event of the app module is emitted.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, ChromeExtensionInfo> GetExtensions()
|
||||
public static Task<ChromeExtensionInfo[]> GetExtensionsAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var taskCompletionSource = new TaskCompletionSource<ChromeExtensionInfo[]>();
|
||||
|
||||
BridgeConnector.Socket.On("browserWindow-getExtensions-completed", (extensionslist) => {
|
||||
BridgeConnector.Socket.Off("browserWindow-getExtensions-completed");
|
||||
var chromeExtensionInfos = ((JArray)extensionslist).ToObject<ChromeExtensionInfo[]>();
|
||||
|
||||
taskCompletionSource.SetResult(chromeExtensionInfos);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserWindowGetExtensions");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,30 +9,20 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public class ChromeExtensionInfo
|
||||
{
|
||||
private string _name;
|
||||
private string _version;
|
||||
|
||||
|
||||
internal ChromeExtensionInfo(string name, string version)
|
||||
public ChromeExtensionInfo(string name, string version)
|
||||
{
|
||||
_name = name;
|
||||
_version = version;
|
||||
Name = name;
|
||||
Version = version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the Chrome extension
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
}
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Version of the Chrome extension
|
||||
/// </summary>
|
||||
public string Version
|
||||
{
|
||||
get => _version;
|
||||
}
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user