chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.28k stars 458 forks source link

Add support for chrome extensions #1947

Closed magreenblatt closed 3 years ago

magreenblatt commented 8 years ago

Original report by me.


Chrome supports an extension system [1] which generally functions as follows:

  1. Load a pre-packaged .crx file (zip archive) that contains the extension source code.
  2. Run the extension in an isolated JavaScript context.
  3. Expose chrome.* JavaScript APIs [2] that the extension can use to perform actions, show UI and interact with other browser content.

CEF will add support for Chrome extensions as a multi-step process:

  1. Add support for loading and running existing chrome extensions (note: they will not work until the required JavaScript APIs have been implemented).
  2. Incrementally implement JavaScript APIs over time.

The first round of implementation will include:

Other APIs under consideration for early implementation include:

Any APIs that require user interface components, such as Browser Action, will be implemented as new CEF APIs that the client application will be responsible for implementing.

This is expected to be a long term project.

[1] https://developer.chrome.com/extensions

[2] https://developer.chrome.com/extensions/api_index

magreenblatt commented 8 years ago

Original comment by Czarek Tomczak (Bitbucket: Czarek, GitHub: Czarek).


You might consider mocking some of the APIs that are non-essential, but which would stop the extension from working. For example when Browser Action is implemented, you could mock the Page Action API which is related and many extensions that use Browser Action may use Page Action as well. Page Action API is not essential for an extension, it would still work fine if the API was mocked.

The Cookies API seem to be important to be implemented in early stages. This API was available since early Chrome v5 and we know that all websites use cookies.

If there was a way to gather statistics about Chrome Extensions to get know which APIs are most commonly used and implement them first, so that CEF supports greatest number of extensions with the least amount of work. Maybe some scraper that downloads all Chrome extensions, unpacks the crx (zip) files and analyzes the source code.

magreenblatt commented 8 years ago

This link lists the most popular chrome extensions: https://chrome.google.com/webstore/category/popular

It seems reasonable to evaluate the top 10 or 20 for API usage (search the code for instances of chrome. and then match to the JavaScript API docs).

magreenblatt commented 8 years ago

Original comment by Eivind Arvesen (Bitbucket: eivind88).


Both Vivaldi and Opera is built on Chromium and supports Chrome-extensions. Thus, they must have implemented the API.

Both Vivaldi and Opera make their source code available (though Vivaldi does not include code for the GUI).

Would it be possible to reach out to them or to use some of their code?

Edit: It seems Opera uses an adaptor to install extensions.

magreenblatt commented 8 years ago

The Chromium code base has multiple layers. CEF currently uses the Content API layer. Chrome, Vivaldi and Opera use the chrome/ layer which sits on top of the Content API later. Extension support is implemented in the chrome/ layer. Consequently it's not a question of missing code but instead an architectural issue that needs to be resolved. We want to do this selectively to avoid exposing untested code paths in CEF.

magreenblatt commented 8 years ago

Depend directly on chrome targets and unfork code in master revision 3cc539b (bb).

magreenblatt commented 8 years ago

Move chrome members to BrowserProcess and add ProfileManager support in master revision f4425a9 (bb).

magreenblatt commented 8 years ago

Unfork streamsPrivate API and add resourcesPrivate and tabs zoom APIs required by the PDF extension in master revision 5732a8d (bb).

magreenblatt commented 8 years ago

Original comment by Bruno Clementino (Bitbucket: brunojclementino, GitHub: brunojclementino).


No estimate of when the extension support possible?

magreenblatt commented 8 years ago

Unfork chome code related to extensions and pepper plugins in master revision 5444c38 (bb).

magreenblatt commented 8 years ago

No estimate of when the extension support possible?

No estimates are available at this time.

magreenblatt commented 8 years ago

Create a PrefServiceSyncable as required by Chrome in master revision ae74d73 (bb) and 2840 branch revision d3b835e (bb).

magreenblatt commented 7 years ago

Issue #1815 was marked as a duplicate of this issue.

magreenblatt commented 7 years ago

The process for adding extension support is documented at https://bitbucket.org/chromiumembedded/cef/src/master/libcef/common/extensions/api/README.txt?at=master&fileviewer=file-view-default.

For example, compare the tabs API implementation in Chrome and CEF. The Chrome implementation of GetTabById uses the Browser and TabStripModel objects that do not exist in CEF. This code can be converted to the CEF equivalent that uses CefBrowserHostImpl.

Similar conversions will be required when implementing other extension APIs.

magreenblatt commented 7 years ago

Master revision 9cff99d (bb) adds support for loading extensions.

magreenblatt commented 7 years ago

Support for Chrome Alarms Extension API added in master revision dddfce4 (bb). This is a good example of how to enable support for APIs implemented at the /extensions layer (versus the /chrome layer).

magreenblatt commented 7 years ago

Original comment by Andrew Warnick (Bitbucket: AWarnick-ADSI).


How much trouble would it be to merge this into the Chrome 61 branch? We have a customer who desperately needs to run an extension.

magreenblatt commented 7 years ago

Support for Chrome Storage Extension API (chrome.storage.local and chrome.storage.sync) added in master revision d8a602e (bb) and 3202 branch revision ff8b4aa (bb).

magreenblatt commented 7 years ago

@AWarnick-ADSI 61 is currently stable so it will only receive bug fixes. The extension changes will be available in 62 and later.

magreenblatt commented 7 years ago

Original comment by fengxingren (Bitbucket: fengxingren, GitHub: fengxingren).


out\Debug_GN_x86\cefclient.exe crashed when launched with "--single-process --load-extension=set_page_color". would it be possible to support extensions in single process mode? thanks.

magreenblatt commented 7 years ago

@fengxingren there are no plans to support single-process mode.

magreenblatt commented 7 years ago

Original comment by fengxingren (Bitbucket: fengxingren, GitHub: fengxingren).


@magreenblatt Thanks for your reply. As I understand it, the extension process is like the devtool process, and the latter can be supported in single-process mode. So How much trouble would it be to support it? Or is it just technically not feasible? I want to use the React Developer Tools extension within CEF3 in single-process mode. It would be appreciated if you could give me some suggestions about how to implement the extension support of single-process mode.

magreenblatt commented 7 years ago

To support the React Developer Tools extension (v2.5.1) we need to add:

magreenblatt commented 7 years ago

chrome.tabs.create added in master revision 607a1d9 (bb) and 3202 branch revision 531f5a3 (bb).

magreenblatt commented 6 years ago

Original comment by Andrew Warnick (Bitbucket: AWarnick-ADSI).


I noticed this message in the client app: "Cannot mix --load-extension and --request-context-per-browser"

We use different request contexts in most browsers. I assume that's going to be a problem. Are you able to explain why, and is there a possibility of a work-around?

magreenblatt commented 6 years ago

@AWarnick-ADSI Extensions need to be registered in each RequestContext separately. The restriction in cefclient is just to simplify the sample application implementation.

magreenblatt commented 6 years ago

Original comment by vinnyq12 (Bitbucket: vinnyq12).


Hi, is there somewhere I can view the status of extension support? What is and isn't supported yet etc. Thanks.

magreenblatt commented 6 years ago

@vinnyq12 Load chrome://extensions-support in CEF to see the list of supported Chrome APIs.

magreenblatt commented 5 years ago

Original comment by Kevin Flabbergasted (Bitbucket: kabone76, GitHub: kabone76).


Hi, is there any news for: chrome.runtime

Or will I need to implement?

magreenblatt commented 5 years ago

Original comment by Artur Chudzik (Bitbucket: arturchudzik).


Hello, is there any progress with chrome.webRequest API?

magreenblatt commented 5 years ago

Original comment by Himan Yukubov (Bitbucket: Radzhab, GitHub: Radzhab).


same question

magreenblatt commented 5 years ago

Original comment by Alexander Guettler (Bitbucket: xforce, GitHub: xforce).


I will be going to work on additional extension API support very soon.

magreenblatt commented 5 years ago

Original comment by Artur Chudzik (Bitbucket: arturchudzik).


@xforce_dev any news? :)

magreenblatt commented 5 years ago

Original comment by Alexander Guettler (Bitbucket: xforce, GitHub: xforce).


@arturchudzik I still plan on working on this, there were just a few things that came up which are a bit more important in my opinion, also wanted to submit some of the other things I had floating around in my custom cef version before doing new things, then there is this Viz change that kind of blew up a bit and required quite some time. I am getting closer to have my current backlog clear to pursue new things though and this was the first thing that I wanted to start with next.

magreenblatt commented 5 years ago

Original comment by Michael Bragilevsky (Bitbucket: Michael Bragilevsky).


Hello, is there any intention to support IETab extension ?

magreenblatt commented 4 years ago

Original comment by yfc (Bitbucket: yfc, GitHub: yfc).


Hi, is there any news for: chrome.runtime getURL, sendMessage and I18n?

magreenblatt commented 4 years ago

Original comment by Marcus Paulo (Bitbucket: MrMarcus, GitHub: MrMarcus).


Hello, anyone have an example to install chrome extensions in CEF? I’m using CEFSharp, if anyone have a C# example…

Tks.

magreenblatt commented 4 years ago

Original comment by James Bright (Bitbucket: James Bright).


How to load “Windows 10 Accounts“ chrome extension in CEF?

This extension allows Microsoft users to connect via Azure and Microsoft websites

magreenblatt commented 3 years ago

Original comment by Jorge R Lima (Bitbucket: limanima, GitHub: limanima).


I need exactly the same thing as James Bright.

“How to load “Windows 10 Accounts“ chrome extension in CEF?”

It seems that the “runtime” api is not yet supported, is this true?

“chrome://extensions-support” is not showing that API.

magreenblatt commented 3 years ago

We will most likely not be supporting additional extension APIs with the current (Alloy) runtime. Extensions will be fully supported with the Chrome runtime. See issue #2969.

magreenblatt commented 3 years ago

Original comment by xuyoucai (Bitbucket: xuyoucai, GitHub: xuyoucai).


Hello, Is it possible to support tabCapture extension ?

magreenblatt commented 3 years ago

We will not be supporting additional Chrome extension APIs with the current (Alloy) runtime beyond what is required by the PDF viewer extension. See issue #3048 which takes this a step further by proposing complete removal of this functionality from the Alloy runtime in the future.

magreenblatt commented 3 years ago

Original comment by Jason Mah (Bitbucket: Jason Mah).


Hi, I am new to CefSharp project and have limited knowledge on extensions.

Appreciate if you can advise if it is possible to enable Aspera Connect extension (which is supported by Chrome browser) on CefSharp browser control?

Thank you.

Regards,

Jason Mah

magreenblatt commented 2 years ago

Original comment by Kevin Dyer (Bitbucket: Kevin Dyer).


Hello,

Does the extension mechanism support Manifest V3? If yes, what rulesets are supported? I have an extension that I would like to use that replaces the /favicon.ico requests with a redirections to an image bundled within the extension to prevent ZTNA from denying access and this uses a redirect in the ruleset to perform the function.

Regards,

Kevin Dyer

magreenblatt commented 7 years ago
magreenblatt commented 3 years ago