From 666f6b3a01a052bdc70ff4a2f095c834ca420032 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 5 Oct 2013 13:13:04 +0800 Subject: [PATCH] Add app.getBrowserWindows() API. --- browser/api/lib/app.coffee | 4 ++++ browser/api/lib/browser-window.coffee | 6 +++--- docs/api/browser/app.md | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/browser/api/lib/app.coffee b/browser/api/lib/app.coffee index 0960db29e3..6f386f14c1 100644 --- a/browser/api/lib/app.coffee +++ b/browser/api/lib/app.coffee @@ -1,4 +1,5 @@ bindings = process.atomBinding 'app' +objectsRegistry = require '../../atom/objects-registry.js' EventEmitter = require('events').EventEmitter Application = bindings.Application @@ -9,6 +10,9 @@ app = new Application app.getHomeDir = -> process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME'] +app.getBrowserWindows = -> + objectsRegistry.getAllWindows() + app.commandLine = appendSwitch: bindings.appendSwitch, appendArgument: bindings.appendArgument diff --git a/browser/api/lib/browser-window.coffee b/browser/api/lib/browser-window.coffee index 56d03e997c..a016883aa0 100644 --- a/browser/api/lib/browser-window.coffee +++ b/browser/api/lib/browser-window.coffee @@ -1,6 +1,6 @@ EventEmitter = require('events').EventEmitter +app = require 'app' v8Util = process.atomBinding 'v8_util' -objectsRegistry = require '../../atom/objects-registry.js' BrowserWindow = process.atomBinding('window').BrowserWindow BrowserWindow::__proto__ = EventEmitter.prototype @@ -26,11 +26,11 @@ BrowserWindow::setMenu = (menu) -> @menu.attachToWindow this BrowserWindow.getFocusedWindow = -> - windows = objectsRegistry.getAllWindows() + windows = app.getBrowserWindows() return window for window in windows when window.isFocused() BrowserWindow.fromProcessIdAndRoutingId = (processId, routingId) -> - windows = objectsRegistry.getAllWindows() + windows = app.getBrowserWindows() return window for window in windows when window.getProcessId() == processId and window.getRoutingId() == routingId diff --git a/docs/api/browser/app.md b/docs/api/browser/app.md index 1375218e9e..c6e16a8875 100644 --- a/docs/api/browser/app.md +++ b/docs/api/browser/app.md @@ -79,6 +79,10 @@ code will not run. Returns the version of current bundle or executable. +## app.getBrowserWindows() + +Returns an array of all browser windows. + ## app.commandLine.appendSwitch(switch, [value]) Append a switch [with optional value] to Chromium's command line.