Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/controllers/conflict-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {remote} from 'electron';
const {Menu, MenuItem} = remote;
const {Menu, MenuItem} = require('electron').remote;

import {autobind} from '../helpers';
import {OURS, BASE, THEIRS} from '../models/conflicts/source';
Expand Down Expand Up @@ -83,7 +83,7 @@ export default class ConflictController extends React.Component {
click: this.props.dismiss,
}));

menu.popup(remote.getCurrentWindow());
menu.popup();
}

render() {
Expand Down
6 changes: 3 additions & 3 deletions lib/controllers/issueish-list-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {EndpointPropType} from '../prop-types';
import IssueishListView from '../views/issueish-list-view';
import Issueish from '../models/issueish';
import {shell, remote} from 'electron';
const {Menu, MenuItem} = remote;
const {Menu, MenuItem} = require('electron').remote;
import {addEvent} from '../reporter-proxy';

const StatePropType = PropTypes.oneOf(['EXPECTED', 'PENDING', 'SUCCESS', 'ERROR', 'FAILURE']);
Expand Down Expand Up @@ -91,7 +91,7 @@ export class BareIssueishListController extends React.Component {
}

openOnGitHub = async url => {
await shell.openExternal(url);
await atom.applicationDelegate.openExternal(url);
addEvent('open-issueish-in-browser', {package: 'github', component: this.constructor.name});
}

Expand All @@ -108,7 +108,7 @@ export class BareIssueishListController extends React.Component {
click: () => this.openOnGitHub(issueish.getGitHubURL()),
}));

menu.popup(remote.getCurrentWindow());
menu.popup();
}

render() {
Expand Down
4 changes: 1 addition & 3 deletions lib/controllers/issueish-searches-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import {shell} from 'electron';

import {RemotePropType, RemoteSetPropType, BranchSetPropType, EndpointPropType} from '../prop-types';
import Search from '../models/search';
import IssueishSearchContainer from '../containers/issueish-search-container';
Expand Down Expand Up @@ -115,6 +113,6 @@ export default class IssueishSearchesController extends React.Component {

onOpenSearch = async search => {
const searchURL = search.getWebURL(this.props.remote);
await shell.openExternal(searchURL);
await atom.applicationDelegate.openExternal(searchURL);
}
}
4 changes: 1 addition & 3 deletions lib/controllers/remote-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import {shell} from 'electron';

import {incrementCounter} from '../reporter-proxy';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, EndpointPropType, TokenPropType} from '../prop-types';
import IssueishSearchesController from './issueish-searches-controller';
Expand Down Expand Up @@ -67,7 +65,7 @@ export default class RemoteController extends React.Component {
createPrUrl += '/compare/' + encodeURIComponent(currentBranch.getName());
createPrUrl += '?expand=1';

await shell.openExternal(createPrUrl);
await atom.applicationDelegate.openExternal(createPrUrl);
incrementCounter('create-pull-request');
}
}
5 changes: 2 additions & 3 deletions lib/controllers/root-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fs from 'fs-extra';
import path from 'path';
import {remote} from 'electron';

import React, {Fragment} from 'react';
import PropTypes from 'prop-types';
import {CompositeDisposable} from 'event-kit';
Expand Down Expand Up @@ -500,7 +498,8 @@ export default class RootController extends React.Component {
const url =
'https://clients2.google.com/service/update2/crx?' +
`response=redirect&x=id%3D${id}%26uc&prodversion=32`;
const extensionFolder = path.resolve(remote.app.getPath('userData'), `extensions/${id}`);
const {ipcRenderer} = require('electron');
const extensionFolder = path.resolve(ipcRenderer.sendSync('atom-app-get-path-sync', 'userData'), `extensions/${id}`);
const extensionFile = `${extensionFolder}.crx`;
await fs.ensureDir(path.dirname(extensionFile));
const response = await fetch(url, {method: 'GET'});
Expand Down
4 changes: 1 addition & 3 deletions lib/git-shell-out-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import os from 'os';
import childProcess from 'child_process';
import fs from 'fs-extra';
import util from 'util';
import {remote} from 'electron';

import {CompositeDisposable} from 'event-kit';
import {GitProcess} from 'dugite';
import {parse as parseDiff} from 'what-the-diff';
Expand Down Expand Up @@ -88,7 +86,7 @@ export default class GitShellOutStrategy {
this.workerManager = options.workerManager;

if (headless === null) {
headless = !remote.getCurrentWindow().isVisible();
headless = !(require('electron').remote.getCurrentWindow().isVisible());
}
}

Expand Down
4 changes: 1 addition & 3 deletions lib/models/event-logger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import path from 'path';
import {remote} from 'electron';

let headless = null;

export default class EventLogger {
Expand All @@ -10,7 +8,7 @@ export default class EventLogger {
this.shortDirectory = '<unknown>';

if (headless === null) {
headless = !remote.getCurrentWindow().isVisible();
headless = !(require('electron').remote.getCurrentWindow().isVisible());
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/views/actionable-review-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AtomTextEditor from '../atom/atom-text-editor';
import RefHolder from '../models/ref-holder';
import {addEvent} from '../reporter-proxy';
import Commands, {Command} from '../atom/commands';
const {Menu, MenuItem} = remote;
const {Menu, MenuItem} = require('electron').remote;

export default class ActionableReviewView extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -128,12 +128,12 @@ export default class ActionableReviewView extends React.Component {
const url = 'https://github.com/contact/report-content?report=' +
`${encodeURIComponent(author)}&content_url=${encodeURIComponent(commentUrl)}`;

await shell.openExternal(url);
await atom.applicationDelegate.openExternal(url);
addEvent('report-abuse', {package: 'github', component: this.constructor.name});
}

openOnGitHub = async url => {
await shell.openExternal(url);
await atom.applicationDelegate.openExternal(url);
addEvent('open-comment-in-browser', {package: 'github', component: this.constructor.name});
}

Expand All @@ -159,6 +159,6 @@ export default class ActionableReviewView extends React.Component {
click: () => this.reportAbuse(content.url, author.login),
}));

menu.popup(remote.getCurrentWindow());
menu.popup();
}
}
4 changes: 1 addition & 3 deletions lib/views/issueish-link.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import url from 'url';
import {shell} from 'electron';

import React from 'react';
import PropTypes from 'prop-types';

Expand Down Expand Up @@ -45,7 +43,7 @@ export function openIssueishLinkInNewTab(url, options = {}) {
}

export async function openLinkInBrowser(uri) {
await shell.openExternal(uri);
await atom.applicationDelegate.openExternal(uri);
addEvent('open-issueish-in-browser', {package: 'github', from: 'issueish-link'});
}

Expand Down
6 changes: 3 additions & 3 deletions lib/views/staging-view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Disposable, CompositeDisposable} from 'event-kit';
import {remote} from 'electron';
const {Menu, MenuItem} = remote;
const {Menu, MenuItem} = require('electron').remote;
import {File} from 'atom';
import React, {Fragment} from 'react';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -644,7 +644,7 @@ export default class StagingView extends React.Component {
click: () => this.props.resolveAsTheirs(conflictPaths),
}));

menu.popup(remote.getCurrentWindow());
menu.popup();
}

showActionsMenu(event) {
Expand Down Expand Up @@ -673,7 +673,7 @@ export default class StagingView extends React.Component {
enabled: this.props.hasUndoHistory,
}));

menu.popup(remote.getCurrentWindow());
menu.popup();
}

resolveCurrentAsOurs() {
Expand Down
4 changes: 2 additions & 2 deletions lib/worker-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import querystring from 'querystring';

import {remote, ipcRenderer as ipc} from 'electron';
const {BrowserWindow} = remote;
const {BrowserWindow} = require('electron').remote;
import {Emitter, Disposable, CompositeDisposable} from 'event-kit';

import {getPackageRoot, autobind} from './helpers';
Expand Down Expand Up @@ -153,7 +153,7 @@ export class Worker {
}

getWebContentsId() {
return remote.getCurrentWebContents().id;
return require('electron').ipcRenderer.sendSync('atom-get-web-contents-id-sync');
}

executeOperation(operation) {
Expand Down
47 changes: 20 additions & 27 deletions lib/worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const qs = require('querystring');

const {remote, ipcRenderer: ipc} = require('electron');
const {ipcRenderer: ipc} = require('electron');
const {GitProcess} = require('dugite');


Expand Down Expand Up @@ -39,31 +39,24 @@ class AverageTracker {
}

const query = qs.parse(window.location.search.substr(1));
const sourceWebContentsId = remote.getCurrentWindow().webContents.id;
const sourceWebContentsId = ipc.sendSync('atom-get-web-contents-id-sync');
const operationCountLimit = parseInt(query.operationCountLimit, 10);
const averageTracker = new AverageTracker({limit: operationCountLimit});
const childPidsById = new Map();

// Manager lifecycle is handled in main (register-renderer-ipc): if the
// manager renderer dies, worker windows are destroyed automatically.
const managerWebContentsId = parseInt(query.managerWebContentsId, 10);
const destroyRenderer = () => {
if (!managerWebContents.isDestroyed()) {
managerWebContents.removeListener('crashed', destroyRenderer);
managerWebContents.removeListener('destroyed', destroyRenderer);
}
const win = remote.BrowserWindow.fromWebContents(remote.getCurrentWebContents());
if (win && !win.isDestroyed()) {
win.destroy();
try {
ipc.sendSync('atom-destroy-own-window-sync');
} catch (e) {
/* ignore */
}
};
const managerWebContentsId = parseInt(query.managerWebContentsId, 10);
const managerWebContents = remote.webContents.fromId(managerWebContentsId);
if (managerWebContents && !managerWebContents.isDestroyed()) {
managerWebContents.on('crashed', destroyRenderer);
managerWebContents.on('destroyed', destroyRenderer);
window.onbeforeunload = () => {
managerWebContents.removeListener('crashed', destroyRenderer);
managerWebContents.removeListener('destroyed', destroyRenderer);
};
}
window.onbeforeunload = () => {
// no-op: main owns parent/child lifecycle
};

const channelName = query.channelName;
ipc.on(channelName, (event, {type, data}) => {
Expand All @@ -77,15 +70,15 @@ ipc.on(channelName, (event, {type, data}) => {
childPidsById.set(id, child.pid);

child.on('error', err => {
event.sender.sendTo(managerWebContentsId, channelName, {
ipc.send('atom-wc-send', managerWebContentsId, channelName, {
sourceWebContentsId,
type: 'git-spawn-error',
data: {id, err},
});
});

child.stdin.on('error', err => {
event.sender.sendTo(managerWebContentsId, channelName, {
ipc.send('atom-wc-send', managerWebContentsId, channelName, {
sourceWebContentsId,
type: 'git-stdin-error',
data: {id, stdin: options.stdin, err},
Expand All @@ -101,7 +94,7 @@ ipc.on(channelName, (event, {type, data}) => {
execTime: performance.now() - spawnEnd,
};
childPidsById.delete(id);
event.sender.sendTo(managerWebContentsId, channelName, {
ipc.send('atom-wc-send', managerWebContentsId, channelName, {
sourceWebContentsId,
type: 'git-data',
data: {
Expand All @@ -116,7 +109,7 @@ ipc.on(channelName, (event, {type, data}) => {
execTime: performance.now() - spawnEnd,
};
childPidsById.delete(id);
event.sender.sendTo(managerWebContentsId, channelName, {
ipc.send('atom-wc-send', managerWebContentsId, channelName, {
sourceWebContentsId,
type: 'git-data',
data: {
Expand All @@ -137,17 +130,17 @@ ipc.on(channelName, (event, {type, data}) => {

// TODO: consider using this to avoid duplicate write operations upon crashing.
// For now we won't do this to avoid clogging up ipc channel
// event.sender.sendTo(managerWebContentsId, channelName, {sourceWebContentsId, type: 'exec-started', data: {id}});
// ipc.send('atom-wc-send', managerWebContentsId, channelName, {sourceWebContentsId, type: 'exec-started', data: {id}});

if (averageTracker.enoughData() && averageTracker.getAverage() > 20) {
event.sender.sendTo(managerWebContentsId, channelName, {type: 'slow-spawns'});
ipc.send('atom-wc-send', managerWebContentsId, channelName, {type: 'slow-spawns'});
}
} else if (type === 'git-cancel') {
const {id} = data;
const childPid = childPidsById.get(id);
if (childPid !== undefined) {
require('tree-kill')(childPid, 'SIGINT', () => {
event.sender.sendTo(managerWebContentsId, channelName, {
ipc.send('atom-wc-send', managerWebContentsId, channelName, {
sourceWebContentsId,
type: 'git-cancelled',
data: {id, childPid},
Expand All @@ -160,4 +153,4 @@ ipc.on(channelName, (event, {type, data}) => {
}
});

ipc.sendTo(managerWebContentsId, channelName, {sourceWebContentsId, type: 'renderer-ready', data: {pid: process.pid}});
ipc.send('atom-wc-send', managerWebContentsId, channelName, {sourceWebContentsId, type: 'renderer-ready', data: {pid: process.pid}});
Loading