};
- /*
- Private: Emit both error object and message, this is to keep compatibility
- with Old APIs.
- */
-
+ // Private: Emit both error object and message, this is to keep compatibility
+ // with Old APIs.
AutoUpdater.prototype.emitError = function(message) {
return this.emit('error', new Error(message), message);
};
spawn = require('child_process').spawn;
-
// i.e. my-app/app-0.1.13/
-
appFolder = path.dirname(process.execPath);
-
// i.e. my-app/Update.exe
-
updateExe = path.resolve(appFolder, '..', 'Update.exe');
exeName = path.basename(process.execPath);
-
-/*
- Spawn a command and invoke the callback when it completes with an error
- and the output from standard out.
- */
-
+// Spawn a command and invoke the callback when it completes with an error
+// and the output from standard out.
spawnUpdate = function(args, detached, callback) {
var error, error1, errorEmitted, spawnedProcess, stderr, stdout;
try {
return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options);
});
- /*
- window.resizeTo(...)
- window.moveTo(...)
- */
+ // window.resizeTo(...)
+ // window.moveTo(...)
this.webContents.on('move', (function(_this) {
return function(event, size) {
return _this.setBounds(size);
};
})(this));
- /*
- Sometimes the webContents doesn't get focus when window is shown, so we have
- to force focusing on webContents in this case. The safest way is to focus it
- when we first start to load URL, if we do it earlier it won't have effect,
- if we do it later we might move focus in the page.
- Though this hack is only needed on OS X when the app is launched from
- Finder, we still do it on all platforms in case of other bugs we don't know.
- */
+ // Sometimes the webContents doesn't get focus when window is shown, so we have
+ // to force focusing on webContents in this case. The safest way is to focus it
+ // when we first start to load URL, if we do it earlier it won't have effect,
+ // if we do it later we might move focus in the page.
+ // Though this hack is only needed on OS X when the app is launched from
+ // Finder, we still do it on all platforms in case of other bugs we don't know.
this.webContents.once('load-url', function() {
return this.focus();
});
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
});
-
-/*
- JavaScript implementation of Chromium's NavigationController.
- Instead of relying on Chromium for history control, we compeletely do history
- control on user land, and only rely on WebContents.loadURL for navigation.
- This helps us avoid Chromium's various optimizations so we can ensure renderer
- process is restarted everytime.
- */
-
+// JavaScript implementation of Chromium's NavigationController.
+// Instead of relying on Chromium for history control, we compeletely do history
+// control on user land, and only rely on WebContents.loadURL for navigation.
+// This helps us avoid Chromium's various optimizations so we can ensure renderer
+// process is restarted everytime.
NavigationController = (function() {
function NavigationController(webContents) {
this.webContents = webContents;
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
- /*
- Calling loadURL during this event might cause crash, so delay the event
- until next tick.
- */
+ // Calling loadURL during this event might cause crash, so delay the event
+ // until next tick.
return setImmediate((function(_this) {
return function() {
return _this.emit.apply(_this, ['did-fail-load'].concat(slice.call(args)));
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
if (extensionInfoMap[manifest.name] == null) {
- /*
- We can not use 'file://' directly because all resources in the extension
- will be treated as relative to the root in Chrome.
- */
+ // We can not use 'file://' directly because all resources in the extension
+ // will be treated as relative to the root in Chrome.
page = url.format({
protocol: 'chrome-extension',
slashes: true,
desktopCapturer.startHandling(captureWindow, captureScreen, thumbnailSize);
}
- /*
- If the WebContents is destroyed before receiving result, just remove the
- reference from requestsQueue to make the module not send the result to it.
- */
+ // If the WebContents is destroyed before receiving result, just remove the
+ // reference from requestsQueue to make the module not send the result to it.
return event.sender.once('destroyed', function() {
return request.webContents = null;
});
ref.send("ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_" + handledRequest.id, result);
}
- /*
- Check the queue to see whether there is other same request. If has, handle
- it for reducing redunplicated `desktopCaptuer.startHandling` calls.
- */
+ // Check the queue to see whether there is other same request. If has, handle
+ // it for reducing redunplicated `desktopCaptuer.startHandling` calls.
unhandledRequestsQueue = [];
for (i = 0, len = requestsQueue.length; i < len; i++) {
request = requestsQueue[i];
event = destroyEvents[i];
embedder.once(event, destroy);
- /*
- Users might also listen to the crashed event, so We must ensure the guest
- is destroyed before users' listener gets called. It is done by moving our
- listener to the first one in queue.
- */
+ // Users might also listen to the crashed event, so We must ensure the guest
+ // is destroyed before users' listener gets called. It is done by moving our
+ // listener to the first one in queue.
listeners = embedder._events[event];
if (Array.isArray(listeners)) {
moveLastToFirst(listeners);
guest = new BrowserWindow(options);
guest.loadURL(url);
- /*
- When |embedder| is destroyed we should also destroy attached guest, and if
- guest is closed by user then we should prevent |embedder| from double
- closing guest.
- */
+ // When |embedder| is destroyed we should also destroy attached guest, and if
+ // guest is closed by user then we should prevent |embedder| from double
+ // closing guest.
guestId = guest.id;
closedByEmbedder = function() {
guest.removeListener('closed', closedByUser);
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'));
if (process.platform === 'win32') {
-
- /*
- Redirect node's console to use our own implementations, since node can not
- handle console output when running as GUI program.
- */
+ // Redirect node's console to use our own implementations, since node can not
+ // handle console output when running as GUI program.
consoleLog = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
this.setMaxListeners(Number.MAX_VALUE);
this.nextId = 0;
- /*
- Stores all objects by ref-counting.
- (id) => {object, count}
- */
+ // Stores all objects by ref-counting.
+ // (id) => {object, count}
this.storage = {};
- /*
- Stores the IDs of objects referenced by WebContents.
- (webContentsId) => {(id) => (count)}
- */
+ // Stores the IDs of objects referenced by WebContents.
+ // (webContentsId) => {(id) => (count)}
this.owners = {};
}
-
- /*
- Register a new object, the object would be kept referenced until you release
- it explicitly.
- */
-
+ // Register a new object, the object would be kept referenced until you release
+ // it explicitly.
ObjectsRegistry.prototype.add = function(webContentsId, obj) {
var base, base1, id;
id = this.saveToStorage(obj);
// Get an object according to its ID.
-
ObjectsRegistry.prototype.get = function(id) {
var ref;
return (ref = this.storage[id]) != null ? ref.object : void 0;
// Dereference an object according to its ID.
-
ObjectsRegistry.prototype.remove = function(webContentsId, id) {
var pointer;
this.dereference(id, 1);
// Clear all references to objects refrenced by the WebContents.
-
ObjectsRegistry.prototype.clear = function(webContentsId) {
var count, id, ref;
this.emit("clear-" + webContentsId);
// Private: Saves the object into storage and assigns an ID for it.
-
ObjectsRegistry.prototype.saveToStorage = function(object) {
var id;
id = v8Util.getHiddenValue(object, 'atomId');
// Private: Dereference the object from store.
-
ObjectsRegistry.prototype.dereference = function(id, count) {
var pointer;
pointer = this.storage[id];
} else if (meta.type === 'object' || meta.type === 'function') {
meta.name = value.constructor.name;
- /*
- Reference the original value if it's an object, because when it's
- passed to renderer we would assume the renderer keeps a reference of
- it.
- */
+ // Reference the original value if it's an object, because when it's
+ // passed to renderer we would assume the renderer keeps a reference of
+ // it.
meta.id = objectsRegistry.add(sender.getId(), value);
meta.members = (function() {
var results;
return args.map(metaToValue);
};
-
-/*
- Call a function and send reply asynchronously if it's a an asynchronous
- style function and the caller didn't pass a callback.
- */
-
+// Call a function and send reply asynchronously if it's a an asynchronous
+// style function and the caller didn't pass a callback.
callFunction = function(event, func, caller, args) {
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
} catch (error1) {
e = error1;
- /*
- Catch functions thrown further down in function invocation and wrap
- them with the function name so it's easier to trace things like
- `Error processing argument -1.`
- */
+ // Catch functions thrown further down in function invocation and wrap
+ // them with the function name so it's easier to trace things like
+ // `Error processing argument -1.`
funcName = (ref = func.name) != null ? ref : "anonymous";
throw new Error("Could not call remote function `" + funcName + "`. Check that the function signature is correct. Underlying error: " + e.message);
}
// Send by BrowserWindow when its render view is deleted.
-
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
return objectsRegistry.clear(id);
});
args = unwrapArgs(event.sender, args);
constructor = objectsRegistry.get(id);
- /*
- Call new with array of arguments.
- http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
- */
+ // Call new with array of arguments.
+ // http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
return event.returnValue = valueToMeta(event.sender, obj);
} catch (error1) {
}
id = ++this.nextId;
- /*
- Capture the location of the function and put it in the ID string,
- so that release errors can be tracked down easily.
- */
+ // Capture the location of the function and put it in the ID string,
+ // so that release errors can be tracked down easily.
regexp = /at (.*)/gi;
stackString = (new Error).stack;
while ((match = regexp.exec(stackString)) !== null) {
}
};
- /*
- Calling mkdir for directory inside asar archive should throw ENOTDIR
- error, but on Windows it throws ENOENT.
- This is to work around the recursive looping bug of mkdirp since it is
- widely used.
- */
+ // Calling mkdir for directory inside asar archive should throw ENOTDIR
+ // error, but on Windows it throws ENOENT.
+ // This is to work around the recursive looping bug of mkdirp since it is
+ // widely used.
if (process.platform === 'win32') {
mkdir = fs.mkdir;
fs.mkdir = function(p, mode, callback) {
}
-/*
- setImmediate and process.nextTick makes use of uv_check and uv_prepare to
- run the callbacks, however since we only run uv loop on requests, the
- callbacks wouldn't be called until something else activated the uv loop,
- which would delay the callbacks for arbitrary long time. So we should
- initiatively activate the uv loop once setImmediate and process.nextTick is
- called.
- */
-
+// setImmediate and process.nextTick makes use of uv_check and uv_prepare to
+// run the callbacks, however since we only run uv loop on requests, the
+// callbacks wouldn't be called until something else activated the uv loop,
+// which would delay the callbacks for arbitrary long time. So we should
+// initiatively activate the uv loop once setImmediate and process.nextTick is
+// called.
wrapWithActivateUvLoop = function(func) {
return function() {
process.activateUvLoop();
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
- recalculate the timeout in browser process.
- */
+ // 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
+ // recalculate the timeout in browser process.
global.setTimeout = wrapWithActivateUvLoop(timers.setTimeout);
global.setInterval = wrapWithActivateUvLoop(timers.setInterval);
}