Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for chrome extensions #1947

Closed
magreenblatt opened this issue Jul 13, 2016 · 45 comments
Closed

Add support for chrome extensions #1947

magreenblatt opened this issue Jul 13, 2016 · 45 comments
Labels
enhancement Enhancement request Framework Related to framework code or APIs

Comments

@magreenblatt
Copy link
Collaborator

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:

  • Extension - The chrome.extension API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing.
  • Runtime - Use the chrome.runtime API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.
  • Storage - Use the chrome.storage API to store, retrieve, and track changes to user data.
  • Tabs - Use the chrome.tabs API to interact with the browser's tab system. You can use this API to create, modify, and rearrange tabs in the browser. (For CEF this will operate on browser windows instead of "tabs".)
  • Web Navigation - Use the chrome.webNavigation API to receive notifications about the status of navigation requests in-flight.
  • Web Request - Use the chrome.webRequest API to observe and analyze traffic and to intercept, block, or modify requests in-flight.
  • Windows - Use the chrome.windows API to interact with browser windows. You can use this API to create, modify, and rearrange windows in the browser. (For CEF this will operate on browser windows instead of "tabs".)

Other APIs under consideration for early implementation include:

  • Browser Action - Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.
  • Context Menus - Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
  • DevTools - A DevTools extension adds functionality to the Chrome DevTools. It can add new UI panels and sidebars, interact with the inspected page, get information about network requests, and more.
  • I18n - Use the chrome.i18n infrastructure to implement internationalization across your whole app or extension.

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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


No estimate of when the extension support possible?

@magreenblatt
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

No estimate of when the extension support possible?

No estimates are available at this time.

@magreenblatt
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

  • set component to "Framework"

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

  • Add CefRequestContext::LoadExtension, CefExtension, CefExtensionHandler and related methods/interfaces.
  • Add chrome://extensions-support that lists supported Chrome APIs.
  • Add CefBrowserHost::SetAutoResizeEnabled and CefDisplayHandler::OnAutoResize to support browser resize based on preferred web contents size.
  • views: Add support for custom CefMenuButton popups.
  • cefclient: Run with --load-extension=set_page_color command-line flag for an extension loading example. Add --use-views on Windows and Linux for an even better example.

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

  • chrome.browserAction
    • setIcon
    • setPopup
  • chrome.devtools
    • inspectedWindow.eval
    • inspectedWindow.tabId
    • panels.create
    • network.onNavigated.addListener
    • network.onNavigated.removeListener
    • panels.themeName
  • chrome.runtime
    • getURL
    • connect
    • onConnect.addListener
    • onMessage.addListener
    • sendMessage

@magreenblatt
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@magreenblatt
Copy link
Collaborator Author

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


Hi, is there any news for:
chrome.runtime

  • getURL
  • connect
  • onConnect.addListener
  • onMessage.addListener
  • sendMessage

Or will I need to implement?

@magreenblatt
Copy link
Collaborator Author

Original comment by Artur Chudzik (Bitbucket: arturchudzik).


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

@magreenblatt
Copy link
Collaborator Author

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


same question

@magreenblatt
Copy link
Collaborator Author

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


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

@magreenblatt
Copy link
Collaborator Author

Original comment by Artur Chudzik (Bitbucket: arturchudzik).


@xforce_dev any news? :)

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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


Hello, is there any intention to support IETab extension ?

@magreenblatt
Copy link
Collaborator Author

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


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

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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


Hello, Is it possible to support tabCapture extension ?

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

  • changed state from "new" to "wontfix"

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

filipnavara pushed a commit to emclient/cef that referenced this issue Dec 26, 2023
…1947)

- Supports chrome.storage.local and chrome.storage.sync
- chrome.storage.sync behaves identically to chrome.storage.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement request Framework Related to framework code or APIs
Projects
None yet
Development

No branches or pull requests

1 participant