Make "screen" module a browser module

This commit is contained in:
Cheng Zhao 2015-01-14 15:11:18 -08:00
parent 551c39e241
commit 809c995c0b
5 changed files with 15 additions and 18 deletions

View file

@ -25,6 +25,7 @@
'atom/browser/api/lib/menu-item.coffee',
'atom/browser/api/lib/power-monitor.coffee',
'atom/browser/api/lib/protocol.coffee',
'atom/browser/api/lib/screen.coffee',
'atom/browser/api/lib/tray.coffee',
'atom/browser/api/lib/web-contents.coffee',
'atom/browser/lib/chrome-extension.coffee',
@ -38,7 +39,6 @@
'atom/common/api/lib/crash-reporter.coffee',
'atom/common/api/lib/id-weak-map.coffee',
'atom/common/api/lib/original-fs.coffee',
'atom/common/api/lib/screen.coffee',
'atom/common/api/lib/shell.coffee',
'atom/common/lib/init.coffee',
'atom/common/lib/asar.coffee',
@ -52,6 +52,7 @@
'atom/renderer/lib/web-view/web-view-constants.coffee',
'atom/renderer/api/lib/ipc.coffee',
'atom/renderer/api/lib/remote.coffee',
'atom/renderer/api/lib/screen.coffee',
'atom/renderer/api/lib/web-frame.coffee',
],
'lib_sources': [
@ -78,6 +79,7 @@
'atom/browser/api/atom_api_power_monitor.h',
'atom/browser/api/atom_api_protocol.cc',
'atom/browser/api/atom_api_protocol.h',
'atom/browser/api/atom_api_screen.cc',
'atom/browser/api/atom_api_tray.cc',
'atom/browser/api/atom_api_tray.h',
'atom/browser/api/atom_api_web_contents.cc',
@ -199,8 +201,6 @@
'atom/common/api/atom_api_crash_reporter.cc',
'atom/common/api/atom_api_id_weak_map.cc',
'atom/common/api/atom_api_id_weak_map.h',
'atom/common/api/atom_api_screen.cc',
'atom/common/api/atom_api_screen.h',
'atom/common/api/atom_api_shell.cc',
'atom/common/api/atom_api_v8_util.cc',
'atom/common/api/atom_bindings.cc',

View file

@ -0,0 +1,11 @@
binding = process.atomBinding 'screen'
checkAppIsReady = ->
unless process.type is 'renderer' or require('app').isReady()
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
for name, _ of binding
do (name) ->
module.exports[name] = (args...) ->
checkAppIsReady()
binding[name](args...)

View file

@ -1,15 +0,0 @@
binding = process.atomBinding 'screen'
checkAppIsReady = ->
unless process.type is 'renderer' or require('app').isReady()
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
# On Linux and Windows we could not access screen in renderer process.
module.exports = require('remote').require 'screen'
else
for name, _ of binding
do (name) ->
module.exports[name] = (args...) ->
checkAppIsReady()
binding[name](args...)

View file

@ -0,0 +1 @@
module.exports = require('remote').require('screen')