return appPath;
};
-
// Routes the events to webContents.
-
ref1 = ['login', 'certificate-error', 'select-client-certificate'];
fn = function(name) {
return app.on(name, function() {
fn(name);
}
-
// Deprecated.
app.getHomeDir = deprecate('app.getHomeDir', 'app.getPath', function() {
deprecate.event(app, 'select-certificate', 'select-client-certificate');
-
// Wrappers for native classes.
-
wrapDownloadItem = function(downloadItem) {
// downloadItem is an EventEmitter.
downloadItemBindings._setWrapDownloadItem(wrapDownloadItem);
-
// Only one App object pemitted.
-
module.exports = app;
autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native');
-
// Deprecated.
-
deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL');
-
-
module.exports = autoUpdater;
});
};
-
// Start an instance of the installed app.
-
exports.processStart = function(callback) {
return spawnUpdate(['--processStart', exeName], true, function() {});
};
-
// Download the releases specified by the URL and write new results to stdout.
-
exports.download = function(updateURL, callback) {
return spawnUpdate(['--download', updateURL], false, function(error, stdout) {
var error1, json, ref, ref1, update;
// Update the application to the latest remote version specified by URL.
-
exports.update = function(updateURL, callback) {
return spawnUpdate(['--update', updateURL], false, callback);
};
// Is the Update.exe installed with the current application?
-
exports.supported = function() {
var error1;
try {
}
};
-
// Helpers.
BrowserWindow.prototype.loadURL = function() {
return this.webContents.inspectServiceWorker();
};
-
// Deprecated.
deprecate.member(BrowserWindow, 'undo', 'webContents');
parseArgs = function(window, options, callback) {
if (!(window === null || (window != null ? window.constructor : void 0) === BrowserWindow)) {
-
// Shift.
callback = options;
options = window;
window = null;
}
if ((callback == null) && typeof options === 'function') {
-
// Shift.
callback = options;
options = null;
}
};
-
// Mark standard asynchronous functions.
-
ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog'];
for (j = 0, len = ref1.length; j < len; j++) {
api = ref1[j];
// Import common modules.
-
common.defineProperties(exports);
Object.defineProperties(exports, {
ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain;
-
// This module is deprecated, we mirror everything from ipcMain.
-
deprecate.warn('ipc module', 'require("electron").ipcMain');
module.exports = ipcMain;
nextCommandId = 0;
-
// Maps role to methods of webContents
-
rolesMap = {
undo: 'undo',
redo: 'redo',
close: 'close'
};
-
// Maps methods that should be called directly on the BrowserWindow instance
-
methodInBrowserWindow = {
minimize: true,
close: true
bindings = process.atomBinding('menu');
-
// Automatically generated radio menu item's group id.
-
nextGroupId = 0;
-
// Search between seperators to find a radio menu item and return its group id,
-
-
// otherwise generate a group id.
-
generateGroupId = function(items, pos) {
var i, item, j, k, ref1, ref2, ref3;
if (pos > 0) {
return ++nextGroupId;
};
-
// Returns the index of item according to |id|.
-
indexOfItemById = function(items, id) {
var i, item, j, len;
for (i = j = 0, len = items.length; j < len; i = ++j) {
return -1;
};
-
// Returns the index of where to insert the item according to |position|.
-
indexToInsertByPosition = function(items, position) {
var id, insertIndex, query, ref1;
if (!position) {
Menu.prototype.popup = function(window, x, y) {
if ((window != null ? window.constructor : void 0) !== BrowserWindow) {
-
// Shift.
y = x;
x = window;
this.insertSubMenu(pos, item.commandId, item.label, item.submenu);
break;
case 'radio':
-
// Grouping radio menu items.
item.overrideReadOnlyProperty('groupId', generateGroupId(this.items, pos));
if ((base = this.groupsMap)[name = item.groupId] == null) {
// Force menuWillShow to be called
-
Menu.prototype._callMenuWillShow = function() {
var item, j, len, ref1, ref2, results;
if ((ref1 = this.delegate) != null) {
if (item.position) {
insertIndex = indexToInsertByPosition(positionedTemplate, item.position);
} else {
-
// If no |position| is specified, insert after last item.
insertIndex++;
}
ipcMain = require('electron').ipcMain;
-
// The history operation in renderer is redirected to browser.
-
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function() {
var args, event, method, ref;
event = arguments[0], method = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
protocol = process.atomBinding('protocol').protocol;
-
// Warn about removed APIs.
-
logAndThrow = function(callback, message) {
console.error(message);
if (callback) {
PERSIST_PERFIX = 'persist:';
-
// Returns the Session from |partition| string.
-
exports.fromPartition = function(partition) {
if (partition == null) {
partition = '';
}
};
-
// Returns the default session.
-
Object.defineProperty(exports, 'defaultSession', {
enumerable: true,
get: function() {
});
wrapSession = function(session) {
-
// session is an EventEmitter.
return session.__proto__ = EventEmitter.prototype;
};
Tray.prototype.__proto__ = EventEmitter.prototype;
Tray.prototype._init = function() {
-
// Deprecated.
deprecate.rename(this, 'popContextMenu', 'popUpContextMenu');
deprecate.event(this, 'clicked', 'click');
];
wrapWebContents = function(webContents) {
-
// webContents is an EventEmitter.
var controller, method, name, ref1;
webContents.__proto__ = EventEmitter.prototype;
url = require('url');
-
// Mapping between hostname and file path.
-
hostPathMap = {};
hostPathMapNextKey = 0;
return hostPathMap[host];
};
-
// Cache extensionInfo.
-
extensionInfoMap = {};
getExtensionInfoFromPath = function(srcDirectory) {
}
};
-
// The loaded extensions cache and its persistent path.
-
loadedExtensions = null;
-
loadedExtensionsPath = null;
-
// Persistent loaded extensions.
-
app = electron.app;
app.on('will-quit', function() {
}
});
-
// We can not use protocol or BrowserWindow until app is ready.
-
app.once('ready', function() {
var BrowserWindow, chromeExtensionHandler, e, error1, i, init, len, protocol, srcDirectory;
protocol = electron.protocol, BrowserWindow = electron.BrowserWindow;
return JSON.stringify(opt1) === JSON.stringify(opt2);
};
-
// A queue for holding all requests from renderer process.
-
requestsQueue = [];
ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureWindow, captureScreen, thumbnailSize, id) {
});
desktopCapturer.emit = function(event, name, sources) {
-
// Receiving sources result from main process, now send them back to renderer.
var captureScreen, captureWindow, handledRequest, i, len, ref, ref1, ref2, request, result, source, thumbnailSize, unhandledRequestsQueue;
handledRequest = requestsQueue.shift(0);
ref = require('electron'), ipcMain = ref.ipcMain, webContents = ref.webContents;
-
// Doesn't exist in early initialization.
-
webViewManager = null;
supportedWebViewEvents = ['load-commit', 'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', 'did-get-response-details', 'did-get-redirect-request', 'dom-ready', 'console-message', 'devtools-opened', 'devtools-closed', 'devtools-focused', 'new-window', 'will-navigate', 'did-navigate', 'did-navigate-in-page', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-updated', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen', 'media-started-playing', 'media-paused', 'found-in-page', 'did-change-theme-color'];
reverseEmbedderElementsMap = {};
-
// Moves the last element of array to the first one.
-
moveLastToFirst = function(list) {
return list.unshift(list.pop());
};
-
// Generate guestInstanceId.
-
getNextInstanceId = function(webContents) {
return ++nextInstanceId;
};
-
// Create a new guest instance.
-
createGuest = function(embedder, params) {
var destroy, destroyEvents, event, fn, guest, i, id, j, len, len1, listeners;
if (webViewManager == null) {
return id;
};
-
// Attach the guest to an element of embedder.
-
attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) {
var guest, key, oldGuestInstanceId, ref1, webPreferences;
guest = guestInstances[guestInstanceId].guest;
return reverseEmbedderElementsMap[guestInstanceId] = key;
};
-
// Destroy an existing guest instance.
-
destroyGuest = function(embedder, id) {
var key;
webViewManager.removeGuest(embedder, id);
return (ref1 = guestInstances[id]) != null ? ref1.guest.setAllowTransparency(allowtransparency) : void 0;
});
-
// Returns WebContents from its guest id.
-
exports.getGuest = function(id) {
var ref1;
return (ref1 = guestInstances[id]) != null ? ref1.guest : void 0;
};
-
// Returns the embedder of the guest.
-
exports.getEmbedder = function(id) {
var ref1;
return (ref1 = guestInstances[id]) != null ? ref1.embedder : void 0;
frameToGuest = {};
-
// Copy attribute of |parent| to |child| if it is not defined in |child|.
-
mergeOptions = function(child, parent) {
var key, value;
for (key in parent) {
return child;
};
-
// Merge |options| with the |embedder|'s window's options.
-
mergeBrowserWindowOptions = function(embedder, options) {
if (embedder.browserWindowOptions != null) {
return options;
};
-
// Create a new guest created by |embedder| with |options|.
-
createGuest = function(embedder, url, frameName, options) {
var closedByEmbedder, closedByUser, guest, guestId, ref1;
guest = frameToGuest[frameName];
return guest.id;
};
-
// Routed window.open messages.
-
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function() {
var args, event, frameName, options, url;
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
Module = require('module');
-
// We modified the original process.argv to let node.js load the atom.js,
-
-
// we need to restore it here.
-
process.argv.splice(1, 1);
// Clear search paths.
});
}
-
// Don't quit on fatal error.
-
process.on('uncaughtException', function(error) {
// Do nothing if the user has a custom uncaught exception handler.
return dialog.showErrorBox('A JavaScript error occurred in the main process', message);
});
-
// Emit 'exit' event on quit.
-
app = require('electron').app;
app.on('quit', function(event, exitCode) {
return process.emit('exit', exitCode);
});
-
// Map process.exit to app.exit, which quits gracefully.
-
process.exit = app.exit;
-
// Load the RPC server.
-
require('./rpc-server');
-
// Load the guest view manager.
-
require('./guest-view-manager');
require('./guest-window-manager');
// Now we try to load app's package.json.
-
packageJson = null;
searchPaths = ['app', 'app.asar', 'default_app'];
throw new Error("Unable to find a valid app");
}
-
// Set application's version.
-
if (packageJson.version != null) {
app.setVersion(packageJson.version);
}
-
// Set application's name.
-
if (packageJson.productName != null) {
app.setName(packageJson.productName);
} else if (packageJson.name != null) {
app.setName(packageJson.name);
}
-
// Set application's desktop name.
-
if (packageJson.desktopName != null) {
app.setDesktopName(packageJson.desktopName);
} else {
app.setDesktopName((app.getName()) + ".desktop");
}
-
// Chrome 42 disables NPAPI plugins by default, reenable them here
-
app.commandLine.appendSwitch('enable-npapi');
-
// Set the user path according to application's name.
-
app.setPath('userData', path.join(app.getPath('appData'), app.getName()));
app.setPath('userCache', path.join(app.getPath('cache'), app.getName()));
app.setAppPath(packagePath);
-
// Load the chrome extension support.
-
require('./chrome-extension');
-
// Load internal desktop-capturer module.
-
require('./desktop-capturer');
-
// Set main startup script of the app.
-
mainStartupScript = packageJson.main || 'index.js';
-
// Finally load app's main.js and transfer control to C++.
-
Module._load(path.join(packagePath, mainStartupScript), Module, true);
}
};
-
// Clear all references to objects refrenced by the WebContents.
ObjectsRegistry.prototype.clear = function(webContentsId) {
var count, id, ref;
return delete this.owners[webContentsId];
};
-
// Private: Saves the object into storage and assigns an ID for it.
ObjectsRegistry.prototype.saveToStorage = function(object) {
var id;
return id;
};
-
// Private: Dereference the object from store.
ObjectsRegistry.prototype.dereference = function(id, count) {
var pointer;
IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap;
-
// Convert a real value into meta data.
-
valueToMeta = function(sender, value, optimizeSimpleObject) {
var el, field, i, len, meta, name;
if (optimizeSimpleObject == null) {
return meta;
};
-
// Convert object to meta by value.
-
plainObjectToMeta = function(obj) {
return Object.getOwnPropertyNames(obj).map(function(name) {
return {
});
};
-
// Convert Error into meta data.
-
exceptionToMeta = function(error) {
return {
type: 'exception',
};
};
-
// Convert array of meta data from renderer into array of real values.
-
unwrapArgs = function(sender, args) {
var metaToValue;
metaToValue = function(meta) {
return returnValue;
};
case 'function':
-
// Cache the callbacks in renderer.
if (!sender.callbacks) {
sender.callbacks = new IDWeakMap;
}
};
-
// Send by BrowserWindow when its render view is deleted.
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
return objectsRegistry.clear(id);
}
CallbacksRegistry.prototype.add = function(callback) {
-
// The callback is already added.
var filenameAndLine, id, location, match, ref, regexp, stackString, x;
id = v8Util.getHiddenValue(callback, 'callbackId');
if (process.platform === 'linux' && process.type === 'renderer') {
-
// On Linux we could not access clipboard in renderer process.
module.exports = require('electron').remote.clipboard;
} else {
-
// Deprecate a method.
var deprecate,
slice = [].slice;
};
};
-
// The method is renamed.
-
deprecate.rename = function(object, oldName, newName) {
var newMethod, warned;
warned = false;
}
};
-
// Forward the method to member.
-
deprecate.member = function(object, method, member) {
var warned;
warned = false;
};
};
-
// Deprecate a property.
-
deprecate.property = function(object, property, method) {
return Object.defineProperty(object, property, {
get: function() {
});
};
-
// Deprecate an event.
-
deprecate.event = function(emitter, oldName, newName, fn) {
var warned;
warned = false;
});
};
-
// Print deprecation warning.
-
deprecate.warn = function(oldName, newName) {
return deprecate.log(oldName + " is deprecated. Use " + newName + " instead.");
};
-
// Print deprecation message.
-
deprecate.log = function(message) {
if (process.throwDeprecation) {
throw new Error(message);
-
// Do not expose the internal modules to `require`.
exports.hideInternalModules = function() {
var globalPaths;
}
};
-
// Attaches properties to |exports|.
-
exports.defineProperties = function(exports) {
return Object.defineProperties(exports, {
nativeImage = process.atomBinding('native_image');
-
// Deprecated.
-
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL');
module.exports = nativeImage;
util = require('util');
-
// Cache asar archive objects.
-
cachedArchives = {};
getOrCreateArchive = function(p) {
return cachedArchives[p] = archive;
};
-
// Clean cache on quit.
-
process.on('exit', function() {
var archive, p, results;
results = [];
return results;
});
-
// Separate asar package's path from full path.
-
splitPath = function(p) {
// shortcut to disable asar.
return [true, p.substr(0, index + 5), p.substr(index + 6)];
};
-
// Convert asar archive's Stats object to fs's Stats object.
-
nextInode = 0;
uid = process.getuid != null ? process.getuid() : 0;
};
};
-
// Create a ENOENT error.
-
notFoundError = function(asarPath, filePath, callback) {
var error;
error = new Error("ENOENT, " + filePath + " not found in " + asarPath);
});
};
-
// Create a ENOTDIR error.
-
notDirError = function(callback) {
var error;
error = new Error('ENOTDIR, not a directory');
});
};
-
// Create invalid archive error.
-
invalidArchiveError = function(asarPath, callback) {
var error;
error = new Error("Invalid package " + asarPath);
});
};
-
// Override APIs that rely on passing file path instead of content to C++.
-
overrideAPISync = function(module, name, arg) {
var old;
if (arg == null) {
};
};
-
// Override fs APIs.
-
exports.wrapFsWithAsar = function(fs) {
var exists, existsSync, internalModuleReadFile, internalModuleStat, lstat, lstatSync, mkdir, mkdirSync, open, openSync, readFile, readFileSync, readdir, readdirSync, realpath, realpathSync, stat, statSync, statSyncNoException;
lstatSync = fs.lstatSync;
};
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
-
// Add common/api/lib to module search paths.
Module.globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
}
global.clearImmediate = timers.clearImmediate;
if (process.type === 'browser') {
-
// setTimeout needs to update the polling timeout of the event loop, when
// called under Chromium's event loop the node's event loop won't get a chance
// to update the timeout, so we have to force the node's event loop to
Module = require('module');
-
// Clear Node's global search paths.
-
Module.globalPaths.length = 0;
-
// Clear current and parent(init.coffee)'s search paths.
-
module.paths = [];
module.parent.paths = [];
-
// Prevent Node from adding paths outside this app to search paths.
-
Module._nodeModulePaths = function(from) {
var dir, i, part, parts, paths, skipOutsidePaths, splitRe, tip;
from = path.resolve(from);
return ++nextId;
};
-
// |options.type| can not be empty and has to include 'window' or 'screen'.
-
isValid = function(options) {
return ((options != null ? options.types : void 0) != null) && Array.isArray(options.types);
};
common = require('../../../../common/api/lib/exports/electron');
-
// Import common modules.
-
common.defineProperties(exports);
Object.defineProperties(exports, {
-
// Renderer side modules, please sort with alphabet order.
desktopCapturer: {
enumerable: true,
v8Util = process.atomBinding('v8_util');
-
// Created by init.coffee.
-
ipcRenderer = v8Util.getHiddenValue(global, 'ipc');
ipcRenderer.send = function() {
EventEmitter = require('events').EventEmitter;
-
// This module is deprecated, we mirror everything from ipcRenderer.
-
deprecate.warn('ipc module', 'require("electron").ipcRenderer');
-
// Routes events of ipcRenderer.
-
ipc = new EventEmitter;
ipcRenderer.emit = function() {
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments);
};
-
// Deprecated.
-
for (method in ipcRenderer) {
if (method.startsWith('send')) {
ipc[method] = ipcRenderer[method];
callbacksRegistry = new CallbacksRegistry;
-
// Check for circular reference.
-
isCircular = function(field, visited) {
if (typeof field === 'object') {
if (indexOf.call(visited, field) >= 0) {
return false;
};
-
// Convert the arguments object into an array of meta data.
-
wrapArgs = function(args, visited) {
var valueToMeta;
if (visited == null) {
return Array.prototype.slice.call(args).map(valueToMeta);
};
-
// Convert meta data from browser into real value.
-
metaToValue = function(meta) {
var RemoteFunction, el, i, j, len, len1, member, ref1, ref2, results, ret;
switch (meta.type) {
break;
default:
if (meta.type === 'function') {
-
// A shadow class to represent the remote function object.
ret = RemoteFunction = (function() {
function RemoteFunction() {
}
}
- /*
- Track delegate object's life time, and tell the browser to clean up
- when the object is GCed.
- */
+ // Track delegate object's life time, and tell the browser to clean up
+ // when the object is GCed.
v8Util.setDestructor(ret, function() {
return ipcRenderer.send('ATOM_BROWSER_DEREFERENCE', meta.id);
});
}
};
-
// Construct a plain object from the meta.
-
metaToPlainObject = function(meta) {
var i, len, name, obj, ref1, ref2, value;
obj = (function() {
return obj;
};
-
-/*
- Create a RemoteMemberFunction instance.
- This function's content should not be inlined into metaToValue, otherwise V8
- may consider it circular reference.
- */
-
+// Create a RemoteMemberFunction instance.
+// This function's content should not be inlined into metaToValue, otherwise V8
+// may consider it circular reference.
createRemoteMemberFunction = function(metaId, name) {
var RemoteMemberFunction;
return RemoteMemberFunction = (function() {
})();
};
-
-/*
- Create configuration for defineProperty.
- This function's content should not be inlined into metaToValue, otherwise V8
- may consider it circular reference.
- */
-
+// Create configuration for defineProperty.
+// This function's content should not be inlined into metaToValue, otherwise V8
+// may consider it circular reference.
createRemoteMemberProperty = function(metaId, name) {
return {
enumerable: true,
};
};
-
// Browser calls a callback in renderer.
-
ipcRenderer.on('ATOM_RENDERER_CALLBACK', function(event, id, args) {
return callbacksRegistry.apply(id, metaToValue(args));
});
-
// A callback in browser is released.
-
ipcRenderer.on('ATOM_RENDERER_RELEASE_CALLBACK', function(event, id) {
return callbacksRegistry.remove(id);
});
-
// List all built-in modules in browser process.
-
browserModules = require('../../../browser/api/lib/exports/electron');
-
// And add a helper receiver for each one.
-
fn = function(name) {
return Object.defineProperty(exports, name, {
get: function() {
}
-/*
- Get remote module.
- (Just like node's require, the modules are cached permanently, note that this
- is safe leak since the object is not expected to get freed in browser)
- */
-
+// Get remote module.
+// (Just like node's require, the modules are cached permanently, note that this
+// is safe leak since the object is not expected to get freed in browser)
moduleCache = {};
exports.require = function(module) {
// Optimize require('electron').
-
moduleCache.electron = exports;
// Alias to remote.require('electron').xxx.
-
builtinCache = {};
exports.getBuiltin = function(module) {
return builtinCache[module] = metaToValue(meta);
};
-
// Get current BrowserWindow object.
-
windowCache = null;
exports.getCurrentWindow = function() {
return windowCache = metaToValue(meta);
};
-
// Get current WebContents object.
-
webContentsCache = null;
exports.getCurrentWebContents = function() {
return webContentsCache = metaToValue(meta);
};
-
// Get a global object in browser.
-
exports.getGlobal = function(name) {
var meta;
meta = ipcRenderer.sendSync('ATOM_BROWSER_GLOBAL', name);
return metaToValue(meta);
};
-
// Get the process object in browser.
-
processCache = null;
exports.__defineGetter__('process', function() {
return processCache;
});
-
// Create a funtion that will return the specifed value when called in browser.
-
exports.createFunctionWithReturnValue = function(returnValue) {
var func;
func = function() {
return func;
};
-
// Get the guest WebContents from guestInstanceId.
-
exports.getGuestWebContents = function(guestInstanceId) {
var meta;
meta = ipcRenderer.sendSync('ATOM_BROWSER_GUEST_WEB_CONTENTS', guestInstanceId);
Module = require('module');
-/*
- We modified the original process.argv to let node.js load the
- atom-renderer.js, we need to restore it here.
- */
-
+// We modified the original process.argv to let node.js load the
+// atom-renderer.js, we need to restore it here.
process.argv.splice(1, 1);
// Clear search paths.
-
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
// Import common settings.
-
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
globalPaths = Module.globalPaths;
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
}
-
// Expose public APIs.
-
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
-
// The global variable will be used by ipc for event dispatching
-
v8Util = process.atomBinding('v8_util');
v8Util.setHiddenValue(global, 'ipc', new events.EventEmitter);
});
// Process command line arguments.
-
nodeIntegration = 'false';
ref = process.argv;
for (i = 0, len = ref.length; i < len; i++) {
arg = ref[i];
if (arg.indexOf('--guest-instance-id=') === 0) {
-
// This is a guest web view.
process.guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1));
} else if (arg.indexOf('--opener-id=') === 0) {
-
// This is a guest BrowserWindow.
process.openerId = parseInt(arg.substr(arg.indexOf('=') + 1));
} else if (arg.indexOf('--node-integration=') === 0) {
}
if (location.protocol === 'chrome-devtools:') {
-
// Override some inspector APIs.
require('./inspector');
nodeIntegration = 'true';
} else if (location.protocol === 'chrome-extension:') {
-
// Add implementations of chrome API.
require('./chrome-api');
nodeIntegration = 'true';
} else {
-
// Override default web functions.
require('./override');
}
if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration === 'except-iframe' || nodeIntegration === 'manual-enable-iframe') {
-
// Export node bindings to global.
global.require = require;
global.module = module;
return process.emit('exit');
});
} else {
-
// Delete Node's symbols after the Environment has been loaded.
process.once('loaded', function() {
delete global.process;
});
}
-
// Load the script specfied by the "preload" attribute.
-
if (preloadScript) {
try {
require(preloadScript);
var convertToMenuTemplate, createFileSelectorElement, createMenu, pathToHtml5FileObject, showFileChooserDialog;
window.onload = function() {
-
// Use menu API to show context menu.
InspectorFrontendHost.showContextMenuAtPoint = createMenu;
ref = require('electron'), ipcRenderer = ref.ipcRenderer, remote = ref.remote;
-
// Helper function to resolve relative url.
-
a = window.top.document.createElement('a');
resolveURL = function(url) {
return a.href;
};
-
// Window object returned by "window.open".
-
BrowserWindowProxy = (function() {
BrowserWindowProxy.proxies = {};
})();
if (process.guestInstanceId == null) {
-
// Override default window.close.
window.close = function() {
return remote.getCurrentWindow().close();
};
}
-
// Make the browser window or guest view emit "new-window" event.
-
window.open = function(url, frameName, features) {
var feature, guestId, i, ints, j, len, len1, name, options, ref1, ref2, value;
if (frameName == null) {
}
};
-
// Use the dialog API to implement alert().
-
window.alert = function(message, title) {
var buttons;
if (title == null) {
// Alert should always return undefined.
};
-
// And the confirm().
-
window.confirm = function(message, title) {
var buttons, cancelId;
if (title == null) {
});
};
-
// But we do not support prompt().
-
window.prompt = function() {
throw new Error('prompt() is and will not be supported.');
};
}
ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function(event, sourceId, message, sourceOrigin) {
-
// Manually dispatch event instead of using postMessage because we also need to
-
// set event.source.
event = document.createEvent('Event');
event.initEvent('message', false, false);
return window.dispatchEvent(event);
});
-
// Forward history operations to browser.
-
sendHistoryOperation = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
}
});
-
// Make document.hidden and document.visibilityState return the correct value.
-
Object.defineProperty(document, 'hidden', {
get: function() {
var currentWindow;
remote = require('electron').remote;
-
// Helper function to resolve url set in attribute.
-
a = document.createElement('a');
resolveURL = function(url) {
return a.href;
};
-
-/*
- Attribute objects.
- Default implementation of a WebView attribute.
- */
-
+// Attribute objects.
+// Default implementation of a WebView attribute.
WebViewAttribute = (function() {
function WebViewAttribute(name, webViewImpl) {
this.name = name;
this.defineProperty();
}
-
// Retrieves and returns the attribute's value.
-
WebViewAttribute.prototype.getValue = function() {
return this.webViewImpl.webviewNode.getAttribute(this.name) || this.value;
};
-
// Sets the attribute's value.
-
WebViewAttribute.prototype.setValue = function(value) {
return this.webViewImpl.webviewNode.setAttribute(this.name, value || '');
};
-
// Changes the attribute's value without triggering its mutation handler.
-
WebViewAttribute.prototype.setValueIgnoreMutation = function(value) {
this.ignoreMutation = true;
this.setValue(value);
return this.ignoreMutation = false;
};
-
// Defines this attribute as a property on the webview node.
-
WebViewAttribute.prototype.defineProperty = function() {
return Object.defineProperty(this.webViewImpl.webviewNode, this.name, {
get: (function(_this) {
});
};
-
// Called when the attribute's value changes.
-
WebViewAttribute.prototype.handleMutation = function() {};
return WebViewAttribute;
})();
-
// An attribute that is treated as a Boolean.
-
BooleanAttribute = (function(superClass) {
extend(BooleanAttribute, superClass);
})(WebViewAttribute);
-
// Attribute that specifies whether transparency is allowed in the webview.
-
AllowTransparencyAttribute = (function(superClass) {
extend(AllowTransparencyAttribute, superClass);
})(BooleanAttribute);
-
// Attribute used to define the demension limits of autosizing.
-
AutosizeDimensionAttribute = (function(superClass) {
extend(AutosizeDimensionAttribute, superClass);
})(WebViewAttribute);
-
// Attribute that specifies whether the webview should be autosized.
-
AutosizeAttribute = (function(superClass) {
extend(AutosizeAttribute, superClass);
})(BooleanAttribute);
-
// Attribute representing the state of the storage partition.
-
PartitionAttribute = (function(superClass) {
extend(PartitionAttribute, superClass);
})(WebViewAttribute);
-
// Attribute that handles the location and navigation of the webview.
-
SrcAttribute = (function(superClass) {
extend(SrcAttribute, superClass);
SrcAttribute.prototype.setValueIgnoreMutation = function(value) {
WebViewAttribute.prototype.setValueIgnoreMutation.call(this, value);
- /*
- takeRecords() is needed to clear queued up src mutations. Without it, it
- is possible for this change to get picked up asyncronously by src's
- mutation observer |observer|, and then get handled even though we do not
- want to handle this mutation.
- */
+ // takeRecords() is needed to clear queued up src mutations. Without it, it
+ // is possible for this change to get picked up asyncronously by src's
+ // mutation observer |observer|, and then get handled even though we do not
+ // want to handle this mutation.
return this.observer.takeRecords();
};
SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
- /*
- Once we have navigated, we don't allow clearing the src attribute.
- Once <webview> enters a navigated state, it cannot return to a
- placeholder state.
- */
+ // Once we have navigated, we don't allow clearing the src attribute.
+ // Once <webview> enters a navigated state, it cannot return to a
+ // placeholder state.
if (!newValue && oldValue) {
- /*
- src attribute changes normally initiate a navigation. We suppress
- the next src attribute handler call to avoid reloading the page
- on every guest-initiated navigation.
- */
+ // src attribute changes normally initiate a navigation. We suppress
+ // the next src attribute handler call to avoid reloading the page
+ // on every guest-initiated navigation.
this.setValueIgnoreMutation(oldValue);
return;
}
};
- /*
- The purpose of this mutation observer is to catch assignment to the src
- attribute without any changes to its value. This is useful in the case
- where the webview guest has crashed and navigating to the same address
- spawns off a new process.
- */
-
+ // The purpose of this mutation observer is to catch assignment to the src
+ // attribute without any changes to its value. This is useful in the case
+ // where the webview guest has crashed and navigating to the same address
+ // spawns off a new process.
SrcAttribute.prototype.setupMutationObserver = function() {
var params;
this.observer = new MutationObserver((function(_this) {
})(WebViewAttribute);
-
// Attribute specifies HTTP referrer.
-
HttpReferrerAttribute = (function(superClass) {
extend(HttpReferrerAttribute, superClass);
})(WebViewAttribute);
-
// Attribute specifies user agent
-
UserAgentAttribute = (function(superClass) {
extend(UserAgentAttribute, superClass);
})(WebViewAttribute);
-
// Attribute that set preload script.
-
PreloadAttribute = (function(superClass) {
extend(PreloadAttribute, superClass);
})(WebViewAttribute);
-
// Sets up all of the webview attributes.
-
WebViewImpl.prototype.setupWebViewAttributes = function() {
var attribute, autosizeAttributes, i, len, results;
this.attributes = {};
module.exports = {
-
// Attributes.
ATTRIBUTE_ALLOWTRANSPARENCY: 'allowtransparency',
ATTRIBUTE_AUTOSIZE: 'autosize',
webViewConstants = require('./web-view-constants');
-
// ID generator.
-
nextId = 0;
getNextId = function() {
return ++nextId;
};
-
// Represents the internal state of the WebView node.
-
WebViewImpl = (function() {
function WebViewImpl(webviewNode) {
var shadowRoot;
}
WebViewImpl.prototype.createBrowserPluginNode = function() {
-
- /*
- We create BrowserPlugin as a custom element in order to observe changes
- to attributes synchronously.
- */
+ // We create BrowserPlugin as a custom element in order to observe changes
+ // to attributes synchronously.
var browserPluginNode;
browserPluginNode = new WebViewImpl.BrowserPlugin();
v8Util.setHiddenValue(browserPluginNode, 'internal', this);
return browserPluginNode;
};
-
// Resets some state upon reattaching <webview> element to the DOM.
-
WebViewImpl.prototype.reset = function() {
// Unlisten the zoom-level-changed event.
webFrame.removeListener('zoom-level-changed', this.onZoomLevelChanged);
- /*
- If guestInstanceId is defined then the <webview> has navigated and has
- already picked up a partition ID. Thus, we need to reset the initialization
- state. However, it may be the case that beforeFirstNavigation is false BUT
- guestInstanceId has yet to be initialized. This means that we have not
- heard back from createGuest yet. We will not reset the flag in this case so
- that we don't end up allocating a second guest.
- */
+ // If guestInstanceId is defined then the <webview> has navigated and has
+ // already picked up a partition ID. Thus, we need to reset the initialization
+ // state. However, it may be the case that beforeFirstNavigation is false BUT
+ // guestInstanceId has yet to be initialized. This means that we have not
+ // heard back from createGuest yet. We will not reset the flag in this case so
+ // that we don't end up allocating a second guest.
if (this.guestInstanceId) {
guestViewInternal.destroyGuest(this.guestInstanceId);
this.webContents = null;
return this.internalInstanceId = 0;
};
-
// Sets the <webview>.request property.
-
WebViewImpl.prototype.setRequestPropertyOnWebViewNode = function(request) {
return Object.defineProperty(this.webviewNode, 'request', {
value: request,
WebViewImpl.prototype.setupFocusPropagation = function() {
if (!this.webviewNode.hasAttribute('tabIndex')) {
- /*
- <webview> needs a tabIndex in order to be focusable.
- TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute
- to allow <webview> to be focusable.
- See http://crbug.com/231664.
- */
+ // <webview> needs a tabIndex in order to be focusable.
+ // TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute
+ // to allow <webview> to be focusable.
+ // See http://crbug.com/231664.
this.webviewNode.setAttribute('tabIndex', -1);
}
this.webviewNode.addEventListener('focus', (function(_this) {
};
- /*
- This observer monitors mutations to attributes of the <webview> and
- updates the BrowserPlugin properties accordingly. In turn, updating
- a BrowserPlugin property will update the corresponding BrowserPlugin
- attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
- details.
- */
-
+ // This observer monitors mutations to attributes of the <webview> and
+ // updates the BrowserPlugin properties accordingly. In turn, updating
+ // a BrowserPlugin property will update the corresponding BrowserPlugin
+ // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
+ // details.
WebViewImpl.prototype.handleWebviewAttributeMutation = function(attributeName, oldValue, newValue) {
if (!this.attributes[attributeName] || this.attributes[attributeName].ignoreMutation) {
return;
height = node.offsetHeight;
// Check the current bounds to make sure we do not resize <webview>
-
// outside of current constraints.
maxWidth = this.attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() | width;
maxHeight = this.attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() | width;
node.style.width = newWidth + 'px';
node.style.height = newHeight + 'px';
- /*
- Only fire the DOM event if the size of the <webview> has actually
- changed.
- */
+ // Only fire the DOM event if the size of the <webview> has actually
+ // changed.
return this.dispatchEvent(webViewEvent);
}
};
WebViewImpl.prototype.onElementResize = function(newSize) {
-
// Dispatch the 'resize' event.
var resizeEvent;
resizeEvent = new Event('resize', {
return this.webviewNode.dispatchEvent(webViewEvent);
};
-
// Adds an 'on<event>' property on the webview, which can be used to set/unset
-
-
// an event handler.
-
WebViewImpl.prototype.setupEventProperty = function(eventName) {
var propertyName;
propertyName = 'on' + eventName.toLowerCase();
});
};
-
// Updates state upon loadcommit.
-
WebViewImpl.prototype.onLoadCommit = function(webViewEvent) {
var newValue, oldValue;
oldValue = this.webviewNode.getAttribute(webViewConstants.ATTRIBUTE_SRC);
newValue = webViewEvent.url;
if (webViewEvent.isMainFrame && (oldValue !== newValue)) {
- /*
- Touching the src attribute triggers a navigation. To avoid
- triggering a page reload on every guest-initiated navigation,
- we do not handle this mutation.
- */
+ // Touching the src attribute triggers a navigation. To avoid
+ // triggering a page reload on every guest-initiated navigation,
+ // we do not handle this mutation.
return this.attributes[webViewConstants.ATTRIBUTE_SRC].setValueIgnoreMutation(newValue);
}
};
params[attributeName] = attribute.getValue();
}
- /*
- When the WebView is not participating in layout (display:none)
- then getBoundingClientRect() would report a width and height of 0.
- However, in the case where the WebView has a fixed size we can
- use that value to initially size the guest so as to avoid a relayout of
- the on display:block.
- */
+ // When the WebView is not participating in layout (display:none)
+ // then getBoundingClientRect() would report a width and height of 0.
+ // However, in the case where the WebView has a fixed size we can
+ // use that value to initially size the guest so as to avoid a relayout of
+ // the on display:block.
css = window.getComputedStyle(this.webviewNode, null);
elementRect = this.webviewNode.getBoundingClientRect();
params.elementWidth = parseInt(elementRect.width) || parseInt(css.getPropertyValue('width'));
})();
-
// Registers browser plugin <object> custom element.
-
registerBrowserPluginElement = function() {
var proto;
proto = Object.create(HTMLObjectElement.prototype);
return internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue);
};
proto.attachedCallback = function() {
-
// Load the plugin immediately.
var unused;
return unused = this.nonExistentAttribute;
return delete proto.attributeChangedCallback;
};
-
// Registers <webview> custom element.
-
registerWebViewElement = function() {
var createBlockHandler, createNonBlockHandler, i, j, len, len1, m, methods, nonblockMethods, proto;
proto = Object.create(HTMLObjectElement.prototype);
};
// Public-facing API methods.
- methods = ['getURL', 'getTitle', 'isLoading', 'isWaitingForResponse', 'stop', 'reload', 'reloadIgnoringCache', 'canGoBack', 'canGoForward', 'canGoToOffset', 'clearHistory', 'goBack', 'goForward', 'goToIndex', 'goToOffset', 'isCrashed', 'setUserAgent', 'getUserAgent', 'openDevTools', 'closeDevTools', 'isDevToolsOpened', 'isDevToolsFocused', 'inspectElement', 'setAudioMuted', 'isAudioMuted', 'undo', 'redo', 'cut', 'copy', 'paste', 'pasteAndMatchStyle', 'delete', 'selectAll', 'unselect', 'replace', 'replaceMisspelling', 'findInPage', 'stopFindInPage', 'getId', 'downloadURL', 'inspectServiceWorker', 'print', 'printToPDF'];
+ methods = [
+ 'getURL',
+ 'getTitle',
+ 'isLoading',
+ 'isWaitingForResponse',
+ 'stop',
+ 'reload',
+ 'reloadIgnoringCache',
+ 'canGoBack',
+ 'canGoForward',
+ 'canGoToOffset',
+ 'clearHistory',
+ 'goBack',
+ 'goForward',
+ 'goToIndex',
+ 'goToOffset',
+ 'isCrashed',
+ 'setUserAgent',
+ 'getUserAgent',
+ 'openDevTools',
+ 'closeDevTools',
+ 'isDevToolsOpened',
+ 'isDevToolsFocused',
+ 'inspectElement',
+ 'setAudioMuted',
+ 'isAudioMuted',
+ 'undo',
+ 'redo',
+ 'cut',
+ 'copy',
+ 'paste',
+ 'pasteAndMatchStyle',
+ 'delete',
+ 'selectAll',
+ 'unselect',
+ 'replace',
+ 'replaceMisspelling',
+ 'findInPage',
+ 'stopFindInPage',
+ 'getId',
+ 'downloadURL',
+ 'inspectServiceWorker',
+ 'print',
+ 'printToPDF'
+ ];
nonblockMethods = [
'executeJavaScript',
'insertCSS',
prototype: proto
});
- /*
- Delete the callbacks so developers cannot call them and produce unexpected
- behavior.
- */
+ // Delete the callbacks so developers cannot call them and produce unexpected
+ // behavior.
delete proto.createdCallback;
delete proto.attachedCallback;
delete proto.detachedCallback;