[PR #311] [MERGED] Support of AddExtension, RemoveExtension, GetExtensions #1136

Open
opened 2026-01-29 16:57:42 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ElectronNET/Electron.NET/pull/311
Author: @Daddoon
Created: 9/26/2019
Status: Merged
Merged: 11/27/2019
Merged by: @GregorBiswanger

Base: masterHead: master


📝 Commits (6)

  • ba64639 - Added AddExtension, RemoveExtension and GetExtensions methods body
  • 8b66bdd - Added BrowserWindow.AddExtension, RemoveExtension, GetExtensions support. Not yet tested
  • a781234 - Removed not existent parameter in method declaration of browserWindowGetExtensions in browserWindows.ts
  • a32b50f - Fixed / Updated API for Chrome extensions
  • 8bf10c3 - Added XML documentation on ChromeExtensionInfo constructor
  • 28be0dd - Removed unused variable from a previous attempt.

📊 Changes

5 files changed (+353 additions, -213 deletions)

View changed files

📝 ElectronNET.API/BrowserWindow.cs (+53 -0)
ElectronNET.API/Entities/ChromeExtensionInfo.cs (+33 -0)
📝 ElectronNET.Host/api/browserWindows.js (+244 -212)
📝 ElectronNET.Host/api/browserWindows.js.map (+1 -1)
📝 ElectronNET.Host/api/browserWindows.ts (+22 -0)

📄 Description

This PR add the support of:

  • BrowserWindow.AddExtension
  • BrowserWindow.RemoveExtension
  • BrowserWindow.GetExtensions

I have tested the code on my side by loading the updated ElectronNET.CLI, and tested with the following sample test in Startup.cs:

        public async void ElectronBootstrap()
        {
            var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
            {
                Width = 1152,
                Height = 940,
                Show = false
            });

            await browserWindow.WebContents.Session.ClearCacheAsync();

            browserWindow.OnReadyToShow += async () =>
            {
                browserWindow.Show();

                await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"Chrome Extensions test");

                //Test for webextensions
                string extensionName = await BrowserWindow.AddExtensionAsync(@"C:/2Bee/Sources/ElectronNET/Electron.NET/ElectronNET.WebApp/wwwroot/chromextensions/iframe_listener");
                await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"AddExtension: Loaded extension is {extensionName}");

                var extensionsList = await BrowserWindow.GetExtensionsAsync();
                var extensionListString = string.Join(", ", extensionsList.Select(p => $"Name: {p.Name}, Version: {p.Version}"));

                await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"GetExtensionsAsync: Results are: {extensionListString}");

                BrowserWindow.RemoveExtension(extensionName);

                var extensionsListAfterRemove = await BrowserWindow.GetExtensionsAsync();
                var extensionListAfterRemoveString = string.Join(", ", extensionsListAfterRemove.Select(p => $"Name: {p.Name}, Version: {p.Version}"));

                await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"GetExtensionsAsync after remove extension: Results are: {extensionListAfterRemoveString}");
            };
            browserWindow.SetTitle(Configuration["DemoTitleInSettings"]);
        }

Attached here, a little Chrome extension created from a Mozilla WebExtension i created for my plugin BlazorMobile. Actually, the running code in this extension should not work as it's specific for a special expected environment, but the goal here is just to test that the Chrome extension load in Electron.

chromextensions.zip

Of course update the AddExtensionAsync with a valid extension folder on your side.
The shown dialog should validate the expected behaviors, according to the method call orders and expected return values.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ElectronNET/Electron.NET/pull/311 **Author:** [@Daddoon](https://github.com/Daddoon) **Created:** 9/26/2019 **Status:** ✅ Merged **Merged:** 11/27/2019 **Merged by:** [@GregorBiswanger](https://github.com/GregorBiswanger) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (6) - [`ba64639`](https://github.com/ElectronNET/Electron.NET/commit/ba64639c1d4b868bd5286e99308493745e971c86) - Added AddExtension, RemoveExtension and GetExtensions methods body - [`8b66bdd`](https://github.com/ElectronNET/Electron.NET/commit/8b66bdd7cbcc8f4d5800ba4df0cd2d1268c0b78b) - Added BrowserWindow.AddExtension, RemoveExtension, GetExtensions support. Not yet tested - [`a781234`](https://github.com/ElectronNET/Electron.NET/commit/a781234d05096958fdfef2998fabc11aa547c7bd) - Removed not existent parameter in method declaration of browserWindowGetExtensions in browserWindows.ts - [`a32b50f`](https://github.com/ElectronNET/Electron.NET/commit/a32b50f86fc1db618a6cd4a962fbd8e9106d4741) - Fixed / Updated API for Chrome extensions - [`8bf10c3`](https://github.com/ElectronNET/Electron.NET/commit/8bf10c370c04b90b92db82df92aaf62d69f4de6f) - Added XML documentation on ChromeExtensionInfo constructor - [`28be0dd`](https://github.com/ElectronNET/Electron.NET/commit/28be0dd209ccf18d7c59ed005a055864c4196007) - Removed unused variable from a previous attempt. ### 📊 Changes **5 files changed** (+353 additions, -213 deletions) <details> <summary>View changed files</summary> 📝 `ElectronNET.API/BrowserWindow.cs` (+53 -0) ➕ `ElectronNET.API/Entities/ChromeExtensionInfo.cs` (+33 -0) 📝 `ElectronNET.Host/api/browserWindows.js` (+244 -212) 📝 `ElectronNET.Host/api/browserWindows.js.map` (+1 -1) 📝 `ElectronNET.Host/api/browserWindows.ts` (+22 -0) </details> ### 📄 Description This PR add the support of: - **BrowserWindow.AddExtension** - **BrowserWindow.RemoveExtension** - **BrowserWindow.GetExtensions** I have tested the code on my side by loading the updated ElectronNET.CLI, and tested with the following sample test in **Startup.cs**: ```csharp public async void ElectronBootstrap() { var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Width = 1152, Height = 940, Show = false }); await browserWindow.WebContents.Session.ClearCacheAsync(); browserWindow.OnReadyToShow += async () => { browserWindow.Show(); await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"Chrome Extensions test"); //Test for webextensions string extensionName = await BrowserWindow.AddExtensionAsync(@"C:/2Bee/Sources/ElectronNET/Electron.NET/ElectronNET.WebApp/wwwroot/chromextensions/iframe_listener"); await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"AddExtension: Loaded extension is {extensionName}"); var extensionsList = await BrowserWindow.GetExtensionsAsync(); var extensionListString = string.Join(", ", extensionsList.Select(p => $"Name: {p.Name}, Version: {p.Version}")); await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"GetExtensionsAsync: Results are: {extensionListString}"); BrowserWindow.RemoveExtension(extensionName); var extensionsListAfterRemove = await BrowserWindow.GetExtensionsAsync(); var extensionListAfterRemoveString = string.Join(", ", extensionsListAfterRemove.Select(p => $"Name: {p.Name}, Version: {p.Version}")); await Electron.Dialog.ShowMessageBoxAsync(browserWindow, $"GetExtensionsAsync after remove extension: Results are: {extensionListAfterRemoveString}"); }; browserWindow.SetTitle(Configuration["DemoTitleInSettings"]); } ``` Attached here, a little Chrome extension created from a Mozilla WebExtension i created for my plugin BlazorMobile. Actually, the running code in this extension should not work as it's specific for a special expected environment, but the goal here is just to test that the Chrome extension load in Electron. [chromextensions.zip](https://github.com/ElectronNET/Electron.NET/files/3658672/chromextensions.zip) Of course update the **AddExtensionAsync** with a valid extension folder on your side. The shown dialog should validate the expected behaviors, according to the method call orders and expected return values. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 16:57:42 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1136