commit
a52285596e
14 changed files with 89 additions and 144 deletions
|
@ -9,8 +9,6 @@ const bindings = process.atomBinding('app');
|
||||||
const downloadItemBindings = process.atomBinding('download_item');
|
const downloadItemBindings = process.atomBinding('download_item');
|
||||||
const app = bindings.app;
|
const app = bindings.app;
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
app.__proto__ = EventEmitter.prototype;
|
app.__proto__ = EventEmitter.prototype;
|
||||||
|
|
||||||
app.setApplicationMenu = function(menu) {
|
app.setApplicationMenu = function(menu) {
|
||||||
|
@ -57,10 +55,8 @@ app.getAppPath = function() {
|
||||||
// Routes the events to webContents.
|
// Routes the events to webContents.
|
||||||
var ref1 = ['login', 'certificate-error', 'select-client-certificate'];
|
var ref1 = ['login', 'certificate-error', 'select-client-certificate'];
|
||||||
var fn = function(name) {
|
var fn = function(name) {
|
||||||
return app.on(name, function() {
|
return app.on(name, function(event, webContents, ...args) {
|
||||||
var args, event, webContents;
|
return webContents.emit.apply(webContents, [name, event].concat(args));
|
||||||
event = arguments[0], webContents = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
|
||||||
return webContents.emit.apply(webContents, [name, event].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var i, len;
|
var i, len;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const app = require('electron').app;
|
const app = require('electron').app;
|
||||||
const BrowserWindow = require('electron').BrowserWindow;
|
const BrowserWindow = require('electron').BrowserWindow;
|
||||||
const binding = process.atomBinding('dialog');
|
const binding = process.atomBinding('dialog');
|
||||||
const v8Util = process.atomBinding('v8_util');
|
const v8Util = process.atomBinding('v8_util');
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
var includes = [].includes;
|
var includes = [].includes;
|
||||||
|
|
||||||
var fileDialogProperties = {
|
var fileDialogProperties = {
|
||||||
|
@ -41,9 +42,8 @@ var checkAppInitialized = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
showOpenDialog: function() {
|
showOpenDialog: function(...args) {
|
||||||
var args, callback, options, prop, properties, ref1, value, window, wrappedCallback;
|
var callback, options, prop, properties, ref1, value, window, wrappedCallback;
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
checkAppInitialized();
|
checkAppInitialized();
|
||||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
|
@ -79,9 +79,9 @@ module.exports = {
|
||||||
} : null;
|
} : null;
|
||||||
return binding.showOpenDialog(String(options.title), String(options.defaultPath), options.filters, properties, window, wrappedCallback);
|
return binding.showOpenDialog(String(options.title), String(options.defaultPath), options.filters, properties, window, wrappedCallback);
|
||||||
},
|
},
|
||||||
showSaveDialog: function() {
|
|
||||||
var args, callback, options, ref1, window, wrappedCallback;
|
showSaveDialog: function(...args) {
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
var callback, options, ref1, window, wrappedCallback;
|
||||||
checkAppInitialized();
|
checkAppInitialized();
|
||||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
|
@ -103,9 +103,9 @@ module.exports = {
|
||||||
} : null;
|
} : null;
|
||||||
return binding.showSaveDialog(String(options.title), String(options.defaultPath), options.filters, window, wrappedCallback);
|
return binding.showSaveDialog(String(options.title), String(options.defaultPath), options.filters, window, wrappedCallback);
|
||||||
},
|
},
|
||||||
showMessageBox: function() {
|
|
||||||
var args, callback, flags, i, j, len, messageBoxType, options, ref1, ref2, ref3, text, window;
|
showMessageBox: function(...args) {
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
var callback, flags, i, j, len, messageBoxType, options, ref1, ref2, ref3, text, window;
|
||||||
checkAppInitialized();
|
checkAppInitialized();
|
||||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
|
@ -154,9 +154,8 @@ module.exports = {
|
||||||
flags = options.noLink ? messageBoxOptions.noLink : 0;
|
flags = options.noLink ? messageBoxOptions.noLink : 0;
|
||||||
return binding.showMessageBox(messageBoxType, options.buttons, options.defaultId, options.cancelId, flags, options.title, options.message, options.detail, options.icon, window, callback);
|
return binding.showMessageBox(messageBoxType, options.buttons, options.defaultId, options.cancelId, flags, options.title, options.message, options.detail, options.icon, window, callback);
|
||||||
},
|
},
|
||||||
showErrorBox: function() {
|
|
||||||
var args;
|
showErrorBox: function(...args) {
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return binding.showErrorBox.apply(binding, args);
|
return binding.showErrorBox.apply(binding, args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,18 +2,14 @@
|
||||||
|
|
||||||
const ipcMain = require('electron').ipcMain;
|
const ipcMain = require('electron').ipcMain;
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// The history operation in renderer is redirected to browser.
|
// The history operation in renderer is redirected to browser.
|
||||||
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function() {
|
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function(event, method, ...args) {
|
||||||
var args, event, method, ref;
|
var ref;
|
||||||
event = arguments[0], method = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
|
||||||
return (ref = event.sender)[method].apply(ref, args);
|
return (ref = event.sender)[method].apply(ref, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() {
|
ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function(event, method, ...args) {
|
||||||
var args, event, method, ref;
|
var ref;
|
||||||
event = arguments[0], method = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
|
||||||
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
|
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ const Menu = require('electron').Menu;
|
||||||
const binding = process.atomBinding('web_contents');
|
const binding = process.atomBinding('web_contents');
|
||||||
const debuggerBinding = process.atomBinding('debugger');
|
const debuggerBinding = process.atomBinding('debugger');
|
||||||
|
|
||||||
let slice = [].slice;
|
let slice = [].slice;
|
||||||
let nextId = 0;
|
let nextId = 0;
|
||||||
|
|
||||||
let getNextId = function() {
|
let getNextId = function() {
|
||||||
|
@ -74,13 +74,11 @@ let wrapWebContents = function(webContents) {
|
||||||
webContents.setMaxListeners(0);
|
webContents.setMaxListeners(0);
|
||||||
|
|
||||||
// WebContents::send(channel, args..)
|
// WebContents::send(channel, args..)
|
||||||
webContents.send = function() {
|
webContents.send = function(channel, ...args) {
|
||||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
|
||||||
var channel = arguments[0];
|
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
throw new Error('Missing required channel argument');
|
throw new Error('Missing required channel argument');
|
||||||
}
|
}
|
||||||
return this._send(channel, slice.call(args));
|
return this._send(channel, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The navigation controller.
|
// The navigation controller.
|
||||||
|
@ -99,8 +97,7 @@ let wrapWebContents = function(webContents) {
|
||||||
|
|
||||||
// Mapping webFrame methods.
|
// Mapping webFrame methods.
|
||||||
for (let method of webFrameMethods) {
|
for (let method of webFrameMethods) {
|
||||||
webContents[method] = function() {
|
webContents[method] = function(...args) {
|
||||||
let args = Array.prototype.slice.call(arguments);
|
|
||||||
this.send('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, args);
|
this.send('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -152,30 +149,26 @@ let wrapWebContents = function(webContents) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// This error occurs when host could not be found.
|
// This error occurs when host could not be found.
|
||||||
webContents.on('did-fail-provisional-load', function() {
|
webContents.on('did-fail-provisional-load', function(...args) {
|
||||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
|
|
||||||
// Calling loadURL during this event might cause crash, so delay the event
|
// Calling loadURL during this event might cause crash, so delay the event
|
||||||
// until next tick.
|
// until next tick.
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
this.emit.apply(this, ['did-fail-load'].concat(slice.call(args)));
|
this.emit.apply(this, ['did-fail-load'].concat(args));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delays the page-title-updated event to next tick.
|
// Delays the page-title-updated event to next tick.
|
||||||
webContents.on('-page-title-updated', function() {
|
webContents.on('-page-title-updated', function(...args) {
|
||||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
this.emit.apply(this, ['page-title-updated'].concat(slice.call(args)));
|
this.emit.apply(this, ['page-title-updated'].concat(args));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Deprecated.
|
// Deprecated.
|
||||||
deprecate.rename(webContents, 'loadUrl', 'loadURL');
|
deprecate.rename(webContents, 'loadUrl', 'loadURL');
|
||||||
deprecate.rename(webContents, 'getUrl', 'getURL');
|
deprecate.rename(webContents, 'getUrl', 'getURL');
|
||||||
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function() {
|
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function(...args) {
|
||||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
return this.emit.apply(this, ['page-title-set'].concat(args));
|
||||||
return this.emit.apply(this, ['page-title-set'].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
return webContents.printToPDF = function(options, callback) {
|
return webContents.printToPDF = function(options, callback) {
|
||||||
var printingSetting;
|
var printingSetting;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const ipcMain = require('electron').ipcMain;
|
const ipcMain = require('electron').ipcMain;
|
||||||
const webContents = require('electron').webContents;
|
const webContents = require('electron').webContents;
|
||||||
|
|
||||||
|
@ -136,9 +138,8 @@ var createGuest = function(embedder, params) {
|
||||||
|
|
||||||
// Dispatch events to embedder.
|
// Dispatch events to embedder.
|
||||||
fn = function(event) {
|
fn = function(event) {
|
||||||
return guest.on(event, function() {
|
return guest.on(event, function(_, ...args) {
|
||||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + guest.viewInstanceId, event].concat(args));
|
||||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + guest.viewInstanceId, event].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
|
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
|
||||||
|
@ -154,9 +155,8 @@ var createGuest = function(embedder, params) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Autosize.
|
// Autosize.
|
||||||
guest.on('size-changed', function() {
|
guest.on('size-changed', function(_, ...args) {
|
||||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + guest.viewInstanceId].concat(args));
|
||||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + guest.viewInstanceId].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const ipcMain = require('electron').ipcMain;
|
const ipcMain = require('electron').ipcMain;
|
||||||
const BrowserWindow = require('electron').BrowserWindow;
|
const BrowserWindow = require('electron').BrowserWindow;
|
||||||
|
|
||||||
var hasProp = {}.hasOwnProperty;
|
var hasProp = {}.hasOwnProperty;
|
||||||
var slice = [].slice;
|
|
||||||
var frameToGuest = {};
|
var frameToGuest = {};
|
||||||
|
|
||||||
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
||||||
|
@ -81,9 +82,8 @@ var createGuest = function(embedder, url, frameName, options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Routed window.open messages.
|
// Routed window.open messages.
|
||||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function() {
|
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function(event, ...args) {
|
||||||
var args, event, frameName, options, url;
|
var frameName, options, url;
|
||||||
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
|
||||||
url = args[0], frameName = args[1], options = args[2];
|
url = args[0], frameName = args[1], options = args[2];
|
||||||
options = mergeBrowserWindowOptions(event.sender, options);
|
options = mergeBrowserWindowOptions(event.sender, options);
|
||||||
event.sender.emit('new-window', event, url, frameName, 'new-window', options);
|
event.sender.emit('new-window', event, url, frameName, 'new-window', options);
|
||||||
|
@ -99,9 +99,8 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function(event, guest
|
||||||
return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1.destroy() : void 0;
|
return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1.destroy() : void 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function() {
|
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function(event, guestId, method, ...args) {
|
||||||
var args, guestId, method, ref1;
|
var ref1;
|
||||||
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
|
||||||
return event.returnValue = (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0;
|
return event.returnValue = (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -117,8 +116,7 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function(event,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function() {
|
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function(event, guestId, method, ...args) {
|
||||||
var args, guestId, method, ref1, ref2;
|
var ref1, ref2;
|
||||||
guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
|
||||||
return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0;
|
return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const Module = require('module');
|
const Module = require('module');
|
||||||
const v8 = require('v8');
|
const v8 = require('v8');
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// We modified the original process.argv to let node.js load the atom.js,
|
// We modified the original process.argv to let node.js load the atom.js,
|
||||||
// we need to restore it here.
|
// we need to restore it here.
|
||||||
process.argv.splice(1, 1);
|
process.argv.splice(1, 1);
|
||||||
|
@ -28,9 +28,7 @@ globalPaths.push(path.join(__dirname, 'api', 'exports'));
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// Redirect node's console to use our own implementations, since node can not
|
// Redirect node's console to use our own implementations, since node can not
|
||||||
// handle console output when running as GUI program.
|
// handle console output when running as GUI program.
|
||||||
var consoleLog = function() {
|
var consoleLog = function(...args) {
|
||||||
var args;
|
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return process.log(util.format.apply(util, args) + "\n");
|
return process.log(util.format.apply(util, args) + "\n");
|
||||||
};
|
};
|
||||||
var streamWrite = function(chunk, encoding, callback) {
|
var streamWrite = function(chunk, encoding, callback) {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
const v8Util = process.atomBinding('v8_util');
|
const v8Util = process.atomBinding('v8_util');
|
||||||
|
|
||||||
class CallbacksRegistry {
|
class CallbacksRegistry {
|
||||||
|
@ -46,16 +44,14 @@ class CallbacksRegistry {
|
||||||
return (ref = this.callbacks[id]) != null ? ref : function() {};
|
return (ref = this.callbacks[id]) != null ? ref : function() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
call() {
|
call(id, ...args) {
|
||||||
var args, id, ref;
|
var ref;
|
||||||
id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
return (ref = this.get(id)).call.apply(ref, [global].concat(args));
|
||||||
return (ref = this.get(id)).call.apply(ref, [global].concat(slice.call(args)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply() {
|
apply(id, ...args) {
|
||||||
var args, id, ref;
|
var ref;
|
||||||
id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
return (ref = this.get(id)).apply.apply(ref, [global].concat(args));
|
||||||
return (ref = this.get(id)).apply.apply(ref, [global].concat(slice.call(args)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(id) {
|
remove(id) {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
// Deprecate a method.
|
// Deprecate a method.
|
||||||
var deprecate,
|
const deprecate = function(oldName, newName, fn) {
|
||||||
slice = [].slice;
|
|
||||||
|
|
||||||
deprecate = function(oldName, newName, fn) {
|
|
||||||
var warned;
|
var warned;
|
||||||
warned = false;
|
warned = false;
|
||||||
return function() {
|
return function() {
|
||||||
|
@ -64,10 +61,7 @@ deprecate.property = function(object, property, method) {
|
||||||
deprecate.event = function(emitter, oldName, newName, fn) {
|
deprecate.event = function(emitter, oldName, newName, fn) {
|
||||||
var warned;
|
var warned;
|
||||||
warned = false;
|
warned = false;
|
||||||
return emitter.on(newName, function() {
|
return emitter.on(newName, function(...args) {
|
||||||
var args;
|
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
|
|
||||||
// there is listeners for old API.
|
// there is listeners for old API.
|
||||||
if (this.listenerCount(oldName) > 0) {
|
if (this.listenerCount(oldName) > 0) {
|
||||||
if (!(warned || process.noDeprecation)) {
|
if (!(warned || process.noDeprecation)) {
|
||||||
|
@ -77,7 +71,7 @@ deprecate.event = function(emitter, oldName, newName, fn) {
|
||||||
if (fn != null) {
|
if (fn != null) {
|
||||||
return fn.apply(this, arguments);
|
return fn.apply(this, arguments);
|
||||||
} else {
|
} else {
|
||||||
return this.emit.apply(this, [oldName].concat(slice.call(args)));
|
return this.emit.apply(this, [oldName].concat(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const binding = process.atomBinding('ipc');
|
const binding = process.atomBinding('ipc');
|
||||||
const v8Util = process.atomBinding('v8_util');
|
const v8Util = process.atomBinding('v8_util');
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// Created by init.js.
|
// Created by init.js.
|
||||||
const ipcRenderer = v8Util.getHiddenValue(global, 'ipc');
|
const ipcRenderer = v8Util.getHiddenValue(global, 'ipc');
|
||||||
|
|
||||||
ipcRenderer.send = function() {
|
ipcRenderer.send = function(...args) {
|
||||||
var args;
|
return binding.send('ipc-message', args);
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return binding.send('ipc-message', slice.call(args));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.sendSync = function() {
|
ipcRenderer.sendSync = function(...args) {
|
||||||
var args;
|
return JSON.parse(binding.sendSync('ipc-message-sync', args));
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return JSON.parse(binding.sendSync('ipc-message-sync', slice.call(args)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.sendToHost = function() {
|
ipcRenderer.sendToHost = function(...args) {
|
||||||
var args;
|
return binding.send('ipc-message-host', args);
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return binding.send('ipc-message-host', slice.call(args));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ipcRenderer;
|
module.exports = ipcRenderer;
|
||||||
|
|
|
@ -2,18 +2,14 @@ const ipcRenderer = require('electron').ipcRenderer;
|
||||||
const deprecate = require('electron').deprecate;
|
const deprecate = require('electron').deprecate;
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// This module is deprecated, we mirror everything from ipcRenderer.
|
// This module is deprecated, we mirror everything from ipcRenderer.
|
||||||
deprecate.warn('ipc module', 'require("electron").ipcRenderer');
|
deprecate.warn('ipc module', 'require("electron").ipcRenderer');
|
||||||
|
|
||||||
// Routes events of ipcRenderer.
|
// Routes events of ipcRenderer.
|
||||||
var ipc = new EventEmitter;
|
var ipc = new EventEmitter;
|
||||||
|
|
||||||
ipcRenderer.emit = function() {
|
ipcRenderer.emit = function(channel, event, ...args) {
|
||||||
var channel = arguments[0];
|
ipc.emit.apply(ipc, [channel].concat(args));
|
||||||
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
|
||||||
ipc.emit.apply(ipc, [channel].concat(slice.call(args)));
|
|
||||||
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments);
|
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
const remote = require('electron').remote;
|
const remote = require('electron').remote;
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// Cache browser window visibility
|
// Cache browser window visibility
|
||||||
var _isVisible = true;
|
var _isVisible = true;
|
||||||
var _isMinimized = false;
|
var _isMinimized = false;
|
||||||
|
@ -73,10 +71,8 @@ var BrowserWindowProxy = (function() {
|
||||||
return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', this.guestId, message, targetOrigin, location.origin);
|
return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', this.guestId, message, targetOrigin, location.origin);
|
||||||
};
|
};
|
||||||
|
|
||||||
BrowserWindowProxy.prototype["eval"] = function() {
|
BrowserWindowProxy.prototype["eval"] = function(...args) {
|
||||||
var args;
|
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript'].concat(args));
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript'].concat(slice.call(args)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return BrowserWindowProxy;
|
return BrowserWindowProxy;
|
||||||
|
@ -223,16 +219,12 @@ ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function(event, sourceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Forward history operations to browser.
|
// Forward history operations to browser.
|
||||||
var sendHistoryOperation = function() {
|
var sendHistoryOperation = function(...args) {
|
||||||
var args;
|
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_NAVIGATION_CONTROLLER'].concat(args));
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_NAVIGATION_CONTROLLER'].concat(slice.call(args)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var getHistoryOperation = function() {
|
var getHistoryOperation = function(...args) {
|
||||||
var args;
|
return ipcRenderer.sendSync.apply(ipcRenderer, ['ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER'].concat(args));
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
||||||
return ipcRenderer.sendSync.apply(ipcRenderer, ['ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER'].concat(slice.call(args)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.history.back = function() {
|
window.history.back = function() {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
const webFrame = require('electron').webFrame;
|
const webFrame = require('electron').webFrame;
|
||||||
|
|
||||||
var slice = [].slice;
|
var requestId= 0;
|
||||||
var requestId = 0;
|
|
||||||
|
|
||||||
var WEB_VIEW_EVENTS = {
|
var WEB_VIEW_EVENTS = {
|
||||||
'load-commit': ['url', 'isMainFrame'],
|
'load-commit': ['url', 'isMainFrame'],
|
||||||
|
@ -41,11 +42,10 @@ var DEPRECATED_EVENTS = {
|
||||||
'page-title-updated': 'page-title-set'
|
'page-title-updated': 'page-title-set'
|
||||||
};
|
};
|
||||||
|
|
||||||
var dispatchEvent = function() {
|
var dispatchEvent = function(webView, eventName, eventKey, ...args) {
|
||||||
var args, domEvent, eventKey, eventName, f, i, j, len, ref1, webView;
|
var domEvent, f, i, j, len, ref1;
|
||||||
webView = arguments[0], eventName = arguments[1], eventKey = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
|
||||||
if (DEPRECATED_EVENTS[eventName] != null) {
|
if (DEPRECATED_EVENTS[eventName] != null) {
|
||||||
dispatchEvent.apply(null, [webView, DEPRECATED_EVENTS[eventName], eventKey].concat(slice.call(args)));
|
dispatchEvent.apply(null, [webView, DEPRECATED_EVENTS[eventName], eventKey].concat(args));
|
||||||
}
|
}
|
||||||
domEvent = new Event(eventName);
|
domEvent = new Event(eventName);
|
||||||
ref1 = WEB_VIEW_EVENTS[eventKey];
|
ref1 = WEB_VIEW_EVENTS[eventKey];
|
||||||
|
@ -61,22 +61,19 @@ var dispatchEvent = function() {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
registerEvents: function(webView, viewInstanceId) {
|
registerEvents: function(webView, viewInstanceId) {
|
||||||
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function() {
|
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function(event, eventName, ...args) {
|
||||||
var eventName = arguments[1];
|
return dispatchEvent.apply(null, [webView, eventName, eventName].concat(args));
|
||||||
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
|
||||||
return dispatchEvent.apply(null, [webView, eventName, eventName].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function() {
|
|
||||||
var channel = arguments[1];
|
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function(event, channel, ...args) {
|
||||||
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
|
||||||
var domEvent = new Event('ipc-message');
|
var domEvent = new Event('ipc-message');
|
||||||
domEvent.channel = channel;
|
domEvent.channel = channel;
|
||||||
domEvent.args = slice.call(args);
|
domEvent.args = args;
|
||||||
return webView.dispatchEvent(domEvent);
|
return webView.dispatchEvent(domEvent);
|
||||||
});
|
});
|
||||||
return ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId, function() {
|
|
||||||
var args, domEvent, f, i, j, len, ref1;
|
return ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId, function(event, ...args) {
|
||||||
args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
var domEvent, f, i, j, len, ref1;
|
||||||
domEvent = new Event('size-changed');
|
domEvent = new Event('size-changed');
|
||||||
ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight'];
|
ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight'];
|
||||||
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
|
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
|
||||||
|
|
|
@ -10,7 +10,6 @@ const guestViewInternal = require('./guest-view-internal');
|
||||||
const webViewConstants = require('./web-view-constants');
|
const webViewConstants = require('./web-view-constants');
|
||||||
|
|
||||||
var hasProp = {}.hasOwnProperty;
|
var hasProp = {}.hasOwnProperty;
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// ID generator.
|
// ID generator.
|
||||||
var nextId = 0;
|
var nextId = 0;
|
||||||
|
@ -392,9 +391,8 @@ var registerWebViewElement = function() {
|
||||||
|
|
||||||
// Forward proto.foo* method calls to WebViewImpl.foo*.
|
// Forward proto.foo* method calls to WebViewImpl.foo*.
|
||||||
createBlockHandler = function(m) {
|
createBlockHandler = function(m) {
|
||||||
return function() {
|
return function(...args) {
|
||||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
const internal = v8Util.getHiddenValue(this, 'internal');
|
||||||
var internal = v8Util.getHiddenValue(this, 'internal');
|
|
||||||
if (internal.webContents) {
|
if (internal.webContents) {
|
||||||
return internal.webContents[m].apply(internal.webContents, args);
|
return internal.webContents[m].apply(internal.webContents, args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -407,11 +405,9 @@ var registerWebViewElement = function() {
|
||||||
proto[m] = createBlockHandler(m);
|
proto[m] = createBlockHandler(m);
|
||||||
}
|
}
|
||||||
createNonBlockHandler = function(m) {
|
createNonBlockHandler = function(m) {
|
||||||
return function() {
|
return function(...args) {
|
||||||
var args, internal;
|
const internal = v8Util.getHiddenValue(this, 'internal');
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args));
|
||||||
internal = v8Util.getHiddenValue(this, 'internal');
|
|
||||||
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(slice.call(args)));
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
for (j = 0, len1 = nonblockMethods.length; j < len1; j++) {
|
for (j = 0, len1 = nonblockMethods.length; j < len1; j++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue