From c1f3aa14cdea17b54fe364969f9ffa3c9a35947a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 3 Feb 2014 16:03:59 +0800 Subject: [PATCH 01/14] Do not send synchronous messages in index.html. --- src/browser/atom-application.coffee | 4 ++++ src/browser/atom-window.coffee | 11 ++++++++++- static/index.html | 10 +++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index affabc0ae..d1d3fa49e 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -1,6 +1,7 @@ AtomWindow = require './atom-window' ApplicationMenu = require './application-menu' AtomProtocolHandler = require './atom-protocol-handler' +BrowserWindow = require 'browser-window' Menu = require 'menu' autoUpdater = require 'auto-updater' app = require 'app' @@ -195,6 +196,9 @@ class AtomApplication ipc.on 'command', (processId, routingId, command) => @emit(command) + ipc.on 'window-command', (processId, routingId, command) => + BrowserWindow.fromProcessIdAndRoutingId(processId, routingId).emit(command) + # Public: Executes the given command. # # If it isn't handled globally, delegate to the currently focused window. diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index 4ca0ab3ad..868938a8b 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -5,6 +5,7 @@ dialog = require 'dialog' ipc = require 'ipc' path = require 'path' fs = require 'fs' +url = require 'url' _ = require 'underscore-plus' # Private: @@ -43,7 +44,7 @@ class AtomWindow @browserWindow.loadSettings = loadSettings @browserWindow.once 'window:loaded', => @loaded = true - @browserWindow.loadUrl "file://#{@resourcePath}/static/index.html" + @browserWindow.loadUrl @getUrl(loadSettings) @browserWindow.focusOnWebView() if @isSpec @openPath(pathToOpen, initialLine) @@ -51,6 +52,14 @@ class AtomWindow setupNodePath: (resourcePath) -> process.env['NODE_PATH'] = path.resolve(resourcePath, 'exports') + getUrl: (loadSettingsObj) -> + loadSettings = JSON.stringify(loadSettingsObj) + url.format + protocol: 'file' + pathname: "#{@resourcePath}/static/index.html" + slashes: true + query: {loadSettings} + getInitialPath: -> @browserWindow.loadSettings.initialPath diff --git a/static/index.html b/static/index.html index ebc054082..eaccafd9c 100644 --- a/static/index.html +++ b/static/index.html @@ -6,15 +6,19 @@