• Home
Name Date Size #Lines LOC

..--

BUILD.gnD12-May-20241 KiB4034

README.txtD12-May-20243.2 KiB6755

_api_features.jsonD12-May-20241.3 KiB4339

_permission_features.jsonD12-May-20241.1 KiB3733

README.txt

1This directory provides API definitions for CEF. Some extensions are implemented
2using Mojo and others use an older JSON-based format.
3
4  <api> is the name of the API definition (e.g. 'alarms').
5  <class> is the name of the class implementation (e.g. 'AlarmManager').
6
7To add a new extension API implemented only in CEF ***:
8
91. Add libcef/common/extensions/api/<api>.idl or .json file which defines the
10   API.
112. Add <api>.idl or .json to the 'schema_sources' list in
12   libcef/common/extensions/api/BUILD.gn. Serialization code will be
13   generated based on this list in step 4.
143. Add libcef/browser/extensions/api/<api>/<api>_api.[h|cc] class implementation
15   files and associated entries to the 'libcef_static' target in BUILD.gn.
164. Run the cef_create_projects script and build to generate the
17   cef/libcef/common/extensions/api/<api>.h file and other serialization code
18   required by the extensions system.
195. Add an entry in the libcef/common/extensions/api/_*_features.json files if
20   necessary [1].
216. Add an entry in the libcef/common/extensions/api/*_manifest_overlay.json
22   files if necessary [2].
237. Call `<class>::GetInstance();` or `<class>Factory::GetFactoryInstance();` [3]
24   from EnsureBrowserContextKeyedServiceFactoriesBuilt in
25   libcef/browser/extensions/browser_context_keyed_service_factories.cc.
268. Call `DependsOn(<class>Factory::GetInstance());` from
27   CefExtensionSystemFactory::CefExtensionSystemFactory in
28   libcef/browser/extensions/extension_system_factory.cc if necessary [3].
29
30*** Note that CEF does not currently expose its own Mojo APIs. Related code is
31commented out in:
32  cef/BUILD.gn
33  cef/libcef/common/extensions/api/BUILD.gn
34  CefExtensionsBrowserClient::RegisterExtensionFunctions
35  CefExtensionsClient::IsAPISchemaGenerated
36  CefExtensionsClient::GetAPISchema
37
38To add a new extension API implemented in Chrome:
39
401. Register the API in libcef/browser/extensions/chrome_api_registration.cc
412. Perform steps 5 through 8 above.
42
43See https://www.chromium.org/developers/design-documents/mojo for more
44information.
45
46[1] A feature can optionally express requirements for where it can be accessed.
47    See the _api_features.json and _permission_features.json files for
48    additional details. For Chrome extensions this should match the definitions
49    in the chrome/common/extensions/api/_*_features.json files.
50
51[2] Service Manifest InterfaceProviderSpecs control interfaces exposed between
52    processes. Mojo interfaces exposed at the frame level are controlled by the
53    "navigation:frame" dictionary. Those exposed at the process level are
54    controlled by the "service_manager:connector" dictionary. Failure to specify
55    this correctly may result in a console error like the following:
56
57      InterfaceProviderSpec "navigation:frame" prevented service:
58      service:content_renderer from binding interface:
59      mojom::Foo exposed by: service:content_browser
60
61[3] Some Mojo APIs use singleton Factory objects that create a one-to-one
62    relationship between a service and a BrowserContext. This is used primarily
63    to control shutdown/destruction order and implementors must explicitly state
64    which services are depended on. See comments in
65    components/keyed_service/content/browser_context_keyed_service_factory.h
66    for additional details.
67