Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
add webFrame api for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed May 4, 2016
1 parent 5b6bcd3 commit f7260ee
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 11 deletions.
4 changes: 4 additions & 0 deletions atom/atom_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@

<include name="IDR_ATOM_EXTENSION_API_JSON_IPC" file="common\api\resources\ipc.json" type="BINDATA" />

<include name="IDR_ATOM_EXTENSION_API_JSON_WEB_FRAME" file="common\api\resources\web_frame.json" type="BINDATA" />

<include name="IDR_ATOM_IPC_BINDINGS_JS" file="common\api\resources\ipc_bindings.js" type="BINDATA" />

<include name="IDR_ATOM_PRIVACY_BINDINGS_JS" file="common\api\resources\privacy_bindings.js" type="BINDATA" />

<include name="IDR_ATOM_TABS_BINDINGS_JS" file="common\api\resources\tabs_bindings.js" type="BINDATA" />

<include name="IDR_ATOM_WEB_FRAME_BINDINGS_JS" file="common\api\resources\web_frame_bindings.js" type="BINDATA" />

<include name="IDR_ATOM_WINDOWS_BINDINGS_JS" file="common\api\resources\windows_bindings.js" type="BINDATA" />
</includes>
</release>
Expand Down
10 changes: 10 additions & 0 deletions atom/common/api/resources/_api_features.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"unblessed_extension"
]
},
"webFrame": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"],
"contexts": [
"blessed_web_page",
"content_script",
"blessed_extension",
"unblessed_extension"
]
},
"tabs": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"],
Expand Down
7 changes: 0 additions & 7 deletions atom/common/api/resources/ipc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Note: Many of these functions and events are implemented by hand and should
// not elicit any code generation from the schema compiler. These items are
// marked "nocompile."
[
{
"namespace": "ipc",
Expand Down
8 changes: 4 additions & 4 deletions atom/common/api/resources/ipc_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ if (!atom.v8_util.getHiddenValue(atom, 'ipcRenderer')) {

var ipcRenderer = new EventEmitter;

ipcRenderer.send = function() {
ipcRenderer.send = function () {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return ipc.send('ipc-message', slice.call(args));
};

ipcRenderer.sendSync = function() {
ipcRenderer.sendSync = function () {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return JSON.parse(ipc.sendSync('ipc-message-sync', slice.call(args)));
};

ipcRenderer.sendToHost = function() {
ipcRenderer.sendToHost = function () {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return ipc.send('ipc-message-host', slice.call(args));
};

ipcRenderer.emit = function() {
ipcRenderer.emit = function () {
arguments[1].sender = ipcRenderer;
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments);
};
Expand Down
63 changes: 63 additions & 0 deletions atom/common/api/resources/web_frame.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[
{
"namespace": "webFrame",
"description": "none",
"functions": [
{
"name": "setSpellCheckProvider",
"nocompile": true,
"type": "function",
},
{
"name": "setZoomFactor",
"nocompile": true,
"type": "function"
},
{
"name": "getZoomFactor",
"nocompile": true,
"type": "function"
},
{
"name": "setZoomLevel",
"nocompile": true,
"type": "function"
},
{
"name": "getZoomLevel",
"nocompile": true,
"type": "function"
},
{
"name": "setZoomLevelLimits",
"nocompile": true,
"type": "function"
},
{
"name": "setSpellCheckProvider",
"nocompile": true,
"type": "function"
},
{
"name": "registerURLSchemeAsBypassingCSP",
"nocompile": true,
"type": "function"
},
{
"name": "registerURLSchemeAsPrivileged",
"nocompile": true,
"type": "function"
},
{
"name": "insertText",
"nocompile": true,
"type": "function"
},
{
"name": "executeJavaScript",
"nocompile": true,
"type": "function"
}
]
}
]
17 changes: 17 additions & 0 deletions atom/common/api/resources/web_frame_bindings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var atom = requireNative('atom').GetBinding();
var webFrame = atom.web_frame.webFrame;

var binding = {
setZoomFactor: webFrame.setZoomFactor.bind(webFrame),
getZoomFactor: webFrame.getZoomFactor.bind(webFrame),
setZoomLevel: webFrame.setZoomLevel.bind(webFrame),
getZoomLevel: webFrame.getZoomLevel.bind(webFrame),
setZoomLevelLimits: webFrame.setZoomLevelLimits.bind(webFrame),
setSpellCheckProvider: webFrame.setSpellCheckProvider.bind(webFrame),
registerURLSchemeAsBypassingCSP: webFrame.registerURLSchemeAsBypassingCSP.bind(webFrame),
registerURLSchemeAsPrivileged: webFrame.registerURLSchemeAsPrivileged.bind(webFrame),
insertText: webFrame.insertText.bind(webFrame),
executeJavaScript: webFrame.executeJavaScript.bind(webFrame)
}

exports.binding = binding
1 change: 1 addition & 0 deletions atom/common/extensions/atom_extensions_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ base::StringPiece AtomExtensionsClient::GetAPISchema(
void AtomExtensionsClient::RegisterAPISchemaResources(
ExtensionAPI* api) const {
api->RegisterSchemaResource("ipc", IDR_ATOM_EXTENSION_API_JSON_IPC);
api->RegisterSchemaResource("webFrame", IDR_ATOM_EXTENSION_API_JSON_WEB_FRAME);
api->RegisterSchemaResource("commands", IDR_EXTENSION_API_JSON_COMMANDS);
api->RegisterSchemaResource("declarativeContent",
IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void AtomExtensionsDispatcherDelegate::PopulateSourceMap(
source_map->RegisterSource("event_emitter", IDR_ATOM_EVENT_EMITTER_JS);
source_map->RegisterSource("ipc_utils", IDR_ATOM_IPC_INTERNAL_JS);
source_map->RegisterSource("ipc", IDR_ATOM_IPC_BINDINGS_JS);
source_map->RegisterSource("webFrame",
IDR_ATOM_WEB_FRAME_BINDINGS_JS);
source_map->RegisterSource("browserAction",
IDR_ATOM_BROWSER_ACTION_BINDINGS_JS);
source_map->RegisterSource("privacy", IDR_ATOM_PRIVACY_BINDINGS_JS);
Expand Down
4 changes: 4 additions & 0 deletions extensions.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
'atom/common/api/resources/ipc_utils.js',
'atom/common/api/resources/privacy_bindings.js',
'atom/common/api/resources/tabs_bindings.js',
'atom/common/api/resources/web_frame.json',
'atom/common/api/resources/web_frame_bindings.js',
'atom/common/api/resources/windows_bindings.js',
],
'actions': [
Expand All @@ -63,6 +65,8 @@
'atom/common/api/resources/ipc_utils.js',
'atom/common/api/resources/privacy_bindings.js',
'atom/common/api/resources/tabs_bindings.js',
'atom/common/api/resources/web_frame.json',
'atom/common/api/resources/web_frame_bindings.js',
'atom/common/api/resources/windows_bindings.js',
],
'outputs': [
Expand Down

0 comments on commit f7260ee

Please sign in to comment.