You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a tracking issue for the work remaining to migrate our Chrome Extensions support away from our ad-hoc polyfills to the official //extensions code in Chromium.
Reacted by Leon Heess, Eryk Rakowski, David Wheatley, Jeremy Spiegel, Linus Groh, Hursh Agrawal, Motin, Wojciech Jeremy Połowniak, Jack Collins, Filip Oščádal and 35 more
Reacted by David Wheatley, Hursh Agrawal, Jack Collins, Wojciech Jeremy Połowniak, jianzhiyao, Kevin Hernandez, kanjieater, Sam Maddock, Leon Heess, Johannes Millan and 7 more
Reacted by Eryk Rakowski, David Wheatley, Hursh Agrawal, Wojciech Jeremy Połowniak, jianzhiyao, Kevin Hernandez, kanjieater, Sam Maddock, Leon Heess, Harsil Patel and 8 more
Reacted by Leon Heess, Johannes Millan, Quang Lam, David Wheatley, Numaan Ashraf, Cory Simmons, Clement Braman and Taeheon Kim
Building on the API that @samuelmaddock suggested in #17440, here's a draft to be evolved as requirements become evident.
interfaceExtension{id: string,path: string,manifest: chrome.Manifest}classSession{/** Emitted when extension is installed and ready. */on(event: 'extension-ready',listener: (event: Event,extension: Extension)=>void): this;/** Loads an extension from the filesystem. * The returned promise is fulfilled when the extension has been successfully loaded, * or rejected with an error if the extension could not be successfully loaded. */loadExtension(path: string): Promise<Extension>;removeExtension(extensionId: string): void;enableExtension(extensionId: string): void;disableExtension(extensionId: string): void;getExtension(extensionId: string): Extension;getAllExtensions(): Extension[];}
//extensions doesn't distinguish between devtools extensions and non-devtools extensions. We can deprecate these functions and delegate them to defaultSession.loadExtension &c. to avoid breaking users without warning.
BrowserWindow.addExtension
BrowserWindow.removeExtension
BrowserWindow.getExtensions
Extensions are session-specific, so these APIs should move to Session. We can deprecate these functions and delegate them to the default session in the interim.
@nornagon How chrome.tabs related functions will be handled? Could I listen for example to chrome.tabs.create? I suggest adding for example a extensions-tabs-create event which is fired when an extension calls a chrome.tabs.create function to the Session class. Also, I've been implementing my own extensions system and I think that the extensionsRenderer object might be interesting for you as it handles UI related events such as the aforementioned API or chrome.browserAction.onClicked etc.
Reacted by Wojciech Jeremy Połowniak and Spike O'Carroll
A lot of the chrome.tabs APIs don't make a lot of sense in an Electron context (e.g. chrome.tabs.getAllInWindow), so I don't think it makes sense for us to implement the full API. In general we aren't aiming to support every Chrome extension, only just enough to support the most common use cases (in particular, devtools extensions like React Devtools, and the internal PDF viewer extension). We probably want to make sure it's possible for apps to add custom implementations for APIs we don't support, e.g. through preload scripts.
Do you have a particular use-case in mind for the chrome.tabs.create API?
@nornagon What bothers me now is how injecting preload scripts into the background pages would work? Will be there a session.setBackgroundPreloads API or something? Also, content scripts execute in isolated worlds, so how would I know in which world there's a chrome object?
Yes, it should be possible to inject preload scripts into background pages. session.setPreloads should do it. I think the easiest way to extend our current preload API would be to add a way for a preload script to know what kind of world it's being injected into (e.g. a global.electron.worldType variable or similar). Ideally we'd extend the preload API so you could specify a different script for each world type.
this is just off the top of my head though, I think that there are quite a few more that may be supported already (e.g. i think most of the things in this list should work?) and there may be some restrictions on some of these APIs that I don't recall. I'll do a more thorough investigation soon and add this list to the docs at some point.
Ultimately though, we are not interested in maintaining anything close to feature parity with Chrome extensions. Our goal is to support devtools extensions (which we already do to some extent, so this will be maintaining roughly the same level of support) and to enable internal extensions like the PDF viewer. There are many concepts in Chrome's extensions API which do not map well to Electron—things like tabs, windows, the omnibox, sync profiles and so on—and it would be far too much effort to hook and expose all of these to app authors.
@nornagon Thanks for your great and hard work on it! I would be very grateful if chrome.extension.getBackgroundPage and chrome.extension.getViews would be also supported since it's very hard to actually implement this in JS by using only IPC. Or I would also appreciate if you could at least guide me how these APIs could be implemented.
There are potentially breaking changes being introduced with the planned deprecation of Electron's current extension support in #21812. Projects adding additional Chrome APIs using the existing extensions implementation would likely cease to function.
I alerted @nornagon to this problem and he mentioned investigating whether it would be possible to support both implementations.
As far as I know, @nornagon is the only contributor actively working on the new extensions system implementation. Based on his work in #21779, it would likely be a considerable effort to support all Chrome APIs. I would encourage folks with an interest in this to start investigating solutions using the new extensions system.
I noticed that the web_request.json file is missing. Maybe that's the problem?
The base //extensions implementation provides some APIs out of the box, web_request.json is one of those. We'll need to search through the chrome codebase to see how it's interacting with the webRequest API, then do the same in electron.
I've found this to happen when not loading a directory containing a manifest.json file. If there's a version subdirectory within extensions\aeblfdkhhhdcdjpifhhbdiojplfjncoa, try loading that directly.
Unfortunately, there's a problem with their background.js causing Electron to crash. When I removed the file from manifest.json, it worked. I can't tell what's wrong with the file since it's uglified and big.
EDIT: Sorry, that's not a problem with the JS file, but it seems that Electron doesn't support multiple background scripts. If I remove one, it works.
@mitermayer this work is available in v9.x.y. Basic unpacked extensions can be loaded into a session. However, not all extension APIs are available or function properly. @sentialx and I have been contributing recently to fix some of these issues.
Since Electron applications aren't constrained to the same tabbed browser model as traditional web browsers, some APIs such as chrome.tabs are intentionally left incomplete.
If you're looking to use any extension in the Chrome webstore, there's still much work to be done. And as @nornagon mentioned, this will fall outside of officially maintained support.
@mitermayer
I don't know the official "stable blockers" described by the Electron team, but for me and probably for anyone who wants to support Chrome extensions in their app is:
no session property in the e.sender object received through an ipc message, it makes it impossible to identify the session when messaging
crash when loading for example 1Password X and probably many others
no way to add additional properties to Tab object like selected or highlighted.
To clarify, it is not the intention of the Electron team to support loading arbitrary extensions from the Chrome Web Store. Our main goals with this effort are to:
Reduce our maintenance burden by aligning with Chrome's architecture,
Maintain & improve support for devtools extensions, and
Provide a more solid base on which app developers can build.
I think we still have some work to go with (3), but since supporting non-devtools extensions is a new feature, a few rough edges there aren't a stable blocker for us.
Reacted by Sam Maddock, Spike O'Carroll, Eryk Rakowski, Andrii Oriekhov and Kristóf Marussy
Hi, I'm trying to find a way to activate the 'chrome.runtime' within the Electron browser, currently the chrome object is empty.
Could somebody advise on the best way to do this?
edit: I read above that I need to load an extension, could I load in the cryptoTokenExtension that comes bundled in Chrome? is there a way to import that?
I'm closing this as extensions support has landed and seems to be working fairly well, and as such there's not much use for a general-purpose tracking issue any more.
Reacted by Eryk Rakowski, Andrii Oriekhov, Cory Simmons, psytron, Khashayar, francescopugini, supersu, Mr Beedell, Roke Julian Lockhart, JustAnotherJavaProgrammer and Jake
Activity
nornagon commentedon Jul 25, 2019
Building on the API that @samuelmaddock suggested in #17440, here's a draft to be evolved as requirements become evident.
nornagon commentedon Jul 26, 2019
To remove in the new world:
BrowserWindow.addDevToolsExtensionBrowserWindow.removeDevToolsExtensionBrowserWindow.getDevToolsExtensions//extensions doesn't distinguish between devtools extensions and non-devtools extensions. We can deprecate these functions and delegate them to
defaultSession.loadExtension&c. to avoid breaking users without warning.BrowserWindow.addExtensionBrowserWindow.removeExtensionBrowserWindow.getExtensionsExtensions are session-specific, so these APIs should move to
Session. We can deprecate these functions and delegate them to the default session in the interim.sentialx commentedon Jul 28, 2019
@nornagon How
chrome.tabsrelated functions will be handled? Could I listen for example tochrome.tabs.create? I suggest adding for example aextensions-tabs-createevent which is fired when an extension calls achrome.tabs.createfunction to theSessionclass. Also, I've been implementing my own extensions system and I think that theextensionsRendererobject might be interesting for you as it handles UI related events such as the aforementioned API orchrome.browserAction.onClickedetc.nornagon commentedon Jul 29, 2019
A lot of the
chrome.tabsAPIs don't make a lot of sense in an Electron context (e.g.chrome.tabs.getAllInWindow), so I don't think it makes sense for us to implement the full API. In general we aren't aiming to support every Chrome extension, only just enough to support the most common use cases (in particular, devtools extensions like React Devtools, and the internal PDF viewer extension). We probably want to make sure it's possible for apps to add custom implementations for APIs we don't support, e.g. through preload scripts.Do you have a particular use-case in mind for the
chrome.tabs.createAPI?sentialx commentedon Jul 29, 2019
I'm making a web browser with multi-window and tabs support, so it would be nice to at least extend the
chromeapis in background and content scripts.sentialx commentedon Jul 29, 2019
@nornagon What bothers me now is how injecting preload scripts into the background pages would work? Will be there a
session.setBackgroundPreloadsAPI or something? Also, content scripts execute in isolated worlds, so how would I know in which world there's achromeobject?nornagon commentedon Jul 29, 2019
Yes, it should be possible to inject preload scripts into background pages. session.setPreloads should do it. I think the easiest way to extend our current preload API would be to add a way for a preload script to know what kind of world it's being injected into (e.g. a
global.electron.worldTypevariable or similar). Ideally we'd extend the preload API so you could specify a different script for each world type.kinop112365362 commentedon Aug 6, 2019
Is there a guide to participating in the contributing code, about Google's extensions? @nornagon
MarshallOfSound commentedon Jan 14, 2020
What happens if you load the same extension id with a different version, does it replace the old one, or fail, or something else ❓
sentialx commentedon Jan 17, 2020
Is there a list of supported
chromeAPIs in the new extensions implementation?nornagon commentedon Jan 17, 2020
Not yet but there should be! So far I think the list is something like:
chrome.runtime.*chrome.extension.getURL(and maybe a couple of otherchrome.extensionAPIs?)chrome.tabs.executeScript- limited support, requires specifying tabIdchrome.tabs.sendMessagechrome.devtools.*for devtools extensionschrome.storage.local.*this is just off the top of my head though, I think that there are quite a few more that may be supported already (e.g. i think most of the things in this list should work?) and there may be some restrictions on some of these APIs that I don't recall. I'll do a more thorough investigation soon and add this list to the docs at some point.
Ultimately though, we are not interested in maintaining anything close to feature parity with Chrome extensions. Our goal is to support devtools extensions (which we already do to some extent, so this will be maintaining roughly the same level of support) and to enable internal extensions like the PDF viewer. There are many concepts in Chrome's extensions API which do not map well to Electron—things like tabs, windows, the omnibox, sync profiles and so on—and it would be far too much effort to hook and expose all of these to app authors.
sentialx commentedon Jan 17, 2020
@nornagon Thanks for your great and hard work on it! I would be very grateful if
chrome.extension.getBackgroundPageandchrome.extension.getViewswould be also supported since it's very hard to actually implement this in JS by using only IPC. Or I would also appreciate if you could at least guide me how these APIs could be implemented.nornagon commentedon Jan 17, 2020
those seem plausibly doable! i'll look into it.
spikecodes commentedon Jan 18, 2020
Super excited about this!
samuelmaddock commentedon Jan 20, 2020
cc @sentialx @alexstrat @stewartlord @Thomas101
There are potentially breaking changes being introduced with the planned deprecation of Electron's current extension support in #21812. Projects adding additional Chrome APIs using the existing extensions implementation would likely cease to function.
I alerted @nornagon to this problem and he mentioned investigating whether it would be possible to support both implementations.
As far as I know, @nornagon is the only contributor actively working on the new extensions system implementation. Based on his work in #21779, it would likely be a considerable effort to support all Chrome APIs. I would encourage folks with an interest in this to start investigating solutions using the new extensions system.
34 remaining items
sentialx commentedon Mar 7, 2020
I noticed that the
web_request.jsonfile is missing. Maybe that's the problem?samuelmaddock commentedon Mar 7, 2020
The base
//extensionsimplementation provides some APIs out of the box,web_request.jsonis one of those. We'll need to search through the chrome codebase to see how it's interacting with thewebRequestAPI, then do the same in electron.sentialx commentedon Mar 7, 2020
Unfortunately, there's a problem with their
background.jscausing Electron to crash. When I removed the file from manifest.json, it worked. I can't tell what's wrong with the file since it's uglified and big.EDIT: Sorry, that's not a problem with the JS file, but it seems that Electron doesn't support multiple background scripts. If I remove one, it works.
sentialx commentedon Mar 7, 2020
Sometimes I get an error related to the messaging:
For example in the Tampermonkey popup page, which also doesn't really display. The scripts load but nothing adds to the popup's
<body>.mitermayer commentedon Apr 13, 2020
What are the remaining blockers for this issue? Would love to contribute in any way to help push this along
samuelmaddock commentedon Apr 13, 2020
@mitermayer this work is available in v9.x.y. Basic unpacked extensions can be loaded into a session. However, not all extension APIs are available or function properly. @sentialx and I have been contributing recently to fix some of these issues.
Since Electron applications aren't constrained to the same tabbed browser model as traditional web browsers, some APIs such as
chrome.tabsare intentionally left incomplete.There are a few projects made to fill this gap:
If you're looking to use any extension in the Chrome webstore, there's still much work to be done. And as @nornagon mentioned, this will fall outside of officially maintained support.
sentialx commentedon Apr 13, 2020
@mitermayer
I don't know the official "stable blockers" described by the Electron team, but for me and probably for anyone who wants to support Chrome extensions in their app is:
sessionproperty in thee.senderobject received through an ipc message, it makes it impossible to identify the session when messagingselectedorhighlighted.The rest can be implemented easily in JS.
nornagon commentedon Apr 13, 2020
To clarify, it is not the intention of the Electron team to support loading arbitrary extensions from the Chrome Web Store. Our main goals with this effort are to:
I think we still have some work to go with (3), but since supporting non-devtools extensions is a new feature, a few rough edges there aren't a stable blocker for us.
sentialx commentedon Apr 25, 2020
Another thing that makes it difficult are CORS errors when extensions are trying to do an XHR request.

I made a temporary workaround here.
GoldSmyth commentedon Nov 4, 2020
Hi, I'm trying to find a way to activate the 'chrome.runtime' within the Electron browser, currently the chrome object is empty.
Could somebody advise on the best way to do this?
edit: I read above that I need to load an extension, could I load in the cryptoTokenExtension that comes bundled in Chrome? is there a way to import that?
Any help appreciated
Electron v9.3.1 Chrome v83.0.4103.122
sentialx commentedon Nov 4, 2020
@GoldSmyth You can download the extension from here: https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/resources/cryptotoken/
GoldSmyth commentedon Nov 4, 2020
Thank you, this solved the issue I was having!
corysimmons commentedon Nov 9, 2020
Bump?
nornagon commentedon Nov 10, 2020
I'm closing this as extensions support has landed and seems to be working fairly well, and as such there's not much use for a general-purpose tracking issue any more.