Skip to content

Commit d802fe0

Browse files
nornagonzcbenz
authored andcommitted
fix: [extensions] some chrome.extension APIs (electron#21804)
1 parent ebe8bdd commit d802fe0

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

chromium_src/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ static_library("chrome") {
233233

234234
if (enable_electron_extensions) {
235235
sources += [
236+
"//chrome/renderer/extensions/extension_hooks_delegate.cc",
237+
"//chrome/renderer/extensions/extension_hooks_delegate.h",
236238
"//chrome/renderer/extensions/tabs_hooks_delegate.cc",
237239
"//chrome/renderer/extensions/tabs_hooks_delegate.h",
238240
]

shell/common/extensions/api/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ group("extensions_features") {
3434
# Private Targets
3535

3636
generated_json_strings("generated_api_json_strings") {
37-
sources = [ "tabs.json" ]
37+
sources = [
38+
"extension.json",
39+
"tabs.json",
40+
]
3841

3942
configs = [ "//build/config:precompiled_headers" ]
4043
bundle_name = "Electron"

shell/common/extensions/api/_api_features.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@
33
"channel": "stable",
44
"extension_types": ["extension"],
55
"contexts": ["blessed_extension"]
6+
},
7+
"extension": {
8+
"channel": "stable",
9+
"extension_types": ["extension"],
10+
"contexts": ["blessed_extension"]
11+
},
12+
"extension.getURL": {
13+
"contexts": ["blessed_extension", "unblessed_extension", "content_script"]
614
}
715
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
[
6+
{
7+
"namespace": "extension",
8+
"description": "The <code>chrome.extension</code> 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 <a href='messaging'>Message Passing</a>.",
9+
"compiler_options": {
10+
"implemented_in": "chrome/browser/extensions/api/module/module.h"
11+
},
12+
"properties": {
13+
},
14+
"functions": [
15+
{
16+
"name": "getURL",
17+
"deprecated": "Please use $(ref:runtime.getURL).",
18+
"nocompile": true,
19+
"type": "function",
20+
"description": "Converts a relative path within an extension install directory to a fully-qualified URL.",
21+
"parameters": [
22+
{
23+
"type": "string",
24+
"name": "path",
25+
"description": "A path to a resource within an extension expressed relative to its install directory."
26+
}
27+
],
28+
"returns": {
29+
"type": "string",
30+
"description": "The fully-qualified URL to the resource."
31+
}
32+
}
33+
],
34+
"events": [
35+
]
36+
}
37+
]

shell/renderer/extensions/electron_extensions_dispatcher_delegate.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <set>
99
#include <string>
1010

11+
#include "chrome/renderer/extensions/extension_hooks_delegate.h"
1112
#include "chrome/renderer/extensions/tabs_hooks_delegate.h"
1213
#include "extensions/renderer/bindings/api_bindings_system.h"
1314
#include "extensions/renderer/lazy_background_page_native_handler.h"
@@ -45,6 +46,9 @@ void ElectronExtensionsDispatcherDelegate::InitializeBindingsSystem(
4546
extensions::Dispatcher* dispatcher,
4647
extensions::NativeExtensionBindingsSystem* bindings_system) {
4748
extensions::APIBindingsSystem* bindings = bindings_system->api_system();
49+
bindings->GetHooksForAPI("extension")
50+
->SetDelegate(std::make_unique<extensions::ExtensionHooksDelegate>(
51+
bindings_system->messaging_service()));
4852
bindings->GetHooksForAPI("tabs")->SetDelegate(
4953
std::make_unique<extensions::TabsHooksDelegate>(
5054
bindings_system->messaging_service()));

0 commit comments

Comments
 (0)