├── script ├── lib │ ├── __init__.py │ └── config.py ├── coffeelint.json ├── chrome_version.h.in ├── pylint.py ├── test.py ├── coffeelint.py ├── compile-coffee.py ├── build.py └── update.py ├── spec ├── fixtures │ ├── asar │ │ ├── file │ │ ├── web.asar │ │ └── a.asar │ ├── module │ │ ├── id.js │ │ ├── property.js │ │ ├── print_name.js │ │ ├── ping.js │ │ ├── call.js │ │ ├── runas.js │ │ ├── create_socket.js │ │ └── fork_ping.js │ ├── workers │ │ ├── worker.js │ │ └── shared_worker.js │ ├── zip │ │ └── a.zip │ ├── pages │ │ ├── a.html │ │ ├── b.html │ │ ├── c.html │ │ └── d.html │ └── api │ │ ├── send-sync-message.html │ │ ├── unload.html │ │ ├── close.html │ │ ├── beforeunload-false.html │ │ ├── close-beforeunload-false.html │ │ ├── close-beforeunload-empty-string.html │ │ ├── close-beforeunload-string.html │ │ ├── close-beforeunload-true.html │ │ └── crash.html ├── api-clipboard-spec.coffee ├── package.json ├── api-screen-spec.coffee ├── api-app-spec.coffee ├── modules-spec.coffee └── api-crash-reporter-spec.coffee ├── chromium_src ├── chrome │ ├── common │ │ ├── pref_names.h │ │ ├── tts_utterance_request.cc │ │ ├── tts_utterance_request.h │ │ └── print_messages.cc │ └── browser │ │ ├── profiles │ │ ├── profile.h │ │ └── profile_io_data.h │ │ ├── ui │ │ └── simple_message_box.h │ │ ├── speech │ │ └── tts_platform.cc │ │ ├── browser_process.cc │ │ ├── printing │ │ ├── printing_ui_web_contents_observer.cc │ │ ├── print_view_manager_observer.h │ │ ├── printing_ui_web_contents_observer.h │ │ ├── print_job_worker_owner.h │ │ └── print_view_manager_basic.cc │ │ └── browser_process.h ├── grit │ └── generated_resources.h ├── LICENSE.chromium └── library_loaders │ └── libgio.h ├── atom ├── renderer │ ├── api │ │ ├── lib │ │ │ ├── web-frame.coffee │ │ │ └── ipc.coffee │ │ ├── atom_renderer_bindings.h │ │ └── atom_api_web_frame.h │ ├── lib │ │ ├── chrome-api.coffee │ │ └── override.coffee │ ├── resources │ │ └── mac │ │ │ └── Info.plist │ └── atom_render_view_observer.h ├── browser │ ├── api │ │ ├── lib │ │ │ ├── ipc.coffee │ │ │ ├── global-shortcut.coffee │ │ │ ├── atom-delegate.coffee │ │ │ ├── power-monitor.coffee │ │ │ ├── content-tracing.coffee │ │ │ ├── tray.coffee │ │ │ ├── protocol.coffee │ │ │ ├── auto-updater.coffee │ │ │ ├── app.coffee │ │ │ └── menu-item.coffee │ │ ├── atom_api_menu_views.h │ │ ├── atom_api_menu_mac.h │ │ ├── atom_api_menu_views.cc │ │ ├── atom_api_power_monitor.h │ │ ├── event_emitter.h │ │ ├── atom_api_tray.h │ │ ├── event.h │ │ └── atom_api_auto_updater.h │ ├── resources │ │ ├── mac │ │ │ ├── atom.icns │ │ │ └── Info.plist │ │ └── win │ │ │ ├── atom.ico │ │ │ └── resource.h │ ├── default_app │ │ └── package.json │ ├── mac │ │ ├── atom_application_delegate.h │ │ ├── atom_application.h │ │ ├── atom_application.mm │ │ └── atom_application_delegate.mm │ ├── auto_updater_linux.cc │ ├── auto_updater_win.cc │ ├── ui │ │ ├── accelerator_util_views.cc │ │ ├── tray_icon_win.cc │ │ ├── tray_icon_observer.h │ │ ├── x │ │ │ ├── x_window_utils.h │ │ │ └── x_window_utils.cc │ │ ├── tray_icon.cc │ │ ├── tray_icon_win.h │ │ ├── views │ │ │ ├── menu_layout.h │ │ │ ├── win_frame_view.h │ │ │ ├── menu_layout.cc │ │ │ └── submenu_button.h │ │ ├── cocoa │ │ │ └── event_processing_window.h │ │ ├── tray_icon_gtk.h │ │ ├── accelerator_util.h │ │ ├── message_box.h │ │ ├── accelerator_util_mac.mm │ │ ├── tray_icon_cocoa.h │ │ └── tray_icon_gtk.cc │ ├── auto_updater.cc │ ├── javascript_environment.cc │ ├── auto_updater.h │ ├── browser_linux.cc │ ├── atom_access_token_store.h │ ├── window_list_observer.h │ ├── javascript_environment.h │ ├── net │ │ ├── url_request_string_job.cc │ │ ├── url_request_string_job.h │ │ └── asar │ │ │ └── asar_protocol_handler.h │ ├── atom_javascript_dialog_manager.cc │ ├── native_window_observer.h │ ├── auto_updater_delegate.h │ ├── web_view │ │ ├── web_view_renderer_state.cc │ │ ├── web_view_manager.h │ │ └── web_view_renderer_state.h │ ├── atom_javascript_dialog_manager.h │ ├── browser_observer.h │ ├── atom_browser_context.h │ └── atom_access_token_store.cc ├── common │ ├── api │ │ ├── lib │ │ │ ├── id-weak-map.coffee │ │ │ ├── shell.coffee │ │ │ ├── screen.coffee │ │ │ ├── clipboard.coffee │ │ │ ├── callbacks-registry.coffee │ │ │ └── crash-reporter.coffee │ │ ├── object_life_monitor.h │ │ ├── atom_api_screen.cc │ │ ├── atom_api_shell.cc │ │ ├── atom_bindings.h │ │ ├── object_life_monitor.cc │ │ ├── atom_api_id_weak_map.h │ │ ├── api_messages.h │ │ └── atom_api_crash_reporter.cc │ ├── draggable_region.cc │ ├── common_message_generator.h │ ├── google_api_key.h │ ├── linux │ │ └── application_info.cc │ ├── chrome_version.h │ ├── draggable_region.h │ ├── crash_reporter │ │ ├── win │ │ │ └── crash_service_main.h │ │ ├── crash_reporter_mac.h │ │ ├── crash_reporter.cc │ │ ├── crash_reporter.h │ │ └── linux │ │ │ └── crash_dump_handler.h │ ├── resources │ │ └── mac │ │ │ └── Info.plist │ ├── native_mate_converters │ │ ├── accelerator_converter.cc │ │ ├── accelerator_converter.h │ │ ├── image_converter.h │ │ ├── value_converter.h │ │ ├── gurl_converter.h │ │ ├── string16_converter.h │ │ ├── file_path_converter.h │ │ └── value_converter.cc │ ├── node_bindings_win.h │ ├── node_bindings_mac.h │ ├── node_bindings_linux.h │ ├── node_includes.h │ ├── platform_util.h │ ├── common_message_generator.cc │ ├── asar │ │ ├── scoped_temporary_file.h │ │ └── scoped_temporary_file.cc │ ├── atom_version.h │ ├── lib │ │ └── init.coffee │ ├── node_bindings_linux.cc │ └── options_switches.h └── app │ ├── atom_main.h │ ├── atom_library_main.h │ ├── atom_library_main.cc │ ├── atom_content_client.cc │ ├── atom_content_client.h │ ├── atom_main_delegate_mac.mm │ └── atom_main_delegate.h ├── tools ├── posix │ ├── strip.sh │ └── make_locale_paks.sh ├── atom_source_root.py ├── mac │ ├── create-framework-subdir-symlinks.sh │ ├── make_locale_dirs.sh │ └── apply_locales.py ├── copy_binary.py └── win │ └── register_msdia80_dll.js ├── .gitignore ├── .travis.yml ├── docs ├── api │ ├── process.md │ ├── power-monitor.md │ ├── screen.md │ ├── menu-item.md │ ├── file-object.md │ ├── shell.md │ ├── web-frame.md │ ├── ipc-renderer.md │ ├── accelerator.md │ ├── clipboard.md │ ├── ipc-browser.md │ ├── global-shortcut.md │ ├── image.md │ ├── synopsis.md │ └── crash-reporter.md ├── development │ ├── coding-style.md │ └── build-instructions-mac.md └── tutorial │ ├── debugging-browser-process.md │ └── application-distribution.md ├── package.json ├── .gitmodules ├── appveyor.yml ├── README.md └── LICENSE /script/lib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/asar/file: -------------------------------------------------------------------------------- 1 | file 2 | -------------------------------------------------------------------------------- /chromium_src/chrome/common/pref_names.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chromium_src/grit/generated_resources.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/profiles/profile.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/module/id.js: -------------------------------------------------------------------------------- 1 | exports.id = 1127 2 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/ui/simple_message_box.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/profiles/profile_io_data.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/module/property.js: -------------------------------------------------------------------------------- 1 | exports.property = 1127 2 | -------------------------------------------------------------------------------- /atom/renderer/api/lib/web-frame.coffee: -------------------------------------------------------------------------------- 1 | module.exports = process.atomBinding('web_frame').webFrame 2 | -------------------------------------------------------------------------------- /spec/fixtures/workers/worker.js: -------------------------------------------------------------------------------- 1 | this.onmessage = function(msg) { 2 | this.postMessage(msg.data); 3 | } 4 | -------------------------------------------------------------------------------- /spec/fixtures/zip/a.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanbuck/atom-shell/master/spec/fixtures/zip/a.zip -------------------------------------------------------------------------------- /tools/posix/strip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ignore errors from strip. 4 | strip "$@" 5 | 6 | exit 0 7 | -------------------------------------------------------------------------------- /spec/fixtures/module/print_name.js: -------------------------------------------------------------------------------- 1 | exports.print = function(obj) { 2 | return obj.constructor.name; 3 | } 4 | -------------------------------------------------------------------------------- /atom/browser/api/lib/ipc.coffee: -------------------------------------------------------------------------------- 1 | EventEmitter = require('events').EventEmitter 2 | 3 | module.exports = new EventEmitter 4 | -------------------------------------------------------------------------------- /script/coffeelint.json: -------------------------------------------------------------------------------- 1 | { 2 | "max_line_length": { 3 | "value": 80, 4 | "level": "ignore" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec/fixtures/module/ping.js: -------------------------------------------------------------------------------- 1 | process.on('message', function(msg) { 2 | process.send(msg); 3 | process.exit(0); 4 | }); 5 | -------------------------------------------------------------------------------- /atom/browser/resources/mac/atom.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanbuck/atom-shell/master/atom/browser/resources/mac/atom.icns -------------------------------------------------------------------------------- /atom/browser/resources/win/atom.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanbuck/atom-shell/master/atom/browser/resources/win/atom.ico -------------------------------------------------------------------------------- /atom/common/api/lib/id-weak-map.coffee: -------------------------------------------------------------------------------- 1 | IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap 2 | 3 | module.exports = IDWeakMap 4 | -------------------------------------------------------------------------------- /spec/fixtures/pages/a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spec/fixtures/module/call.js: -------------------------------------------------------------------------------- 1 | exports.call = function(func) { 2 | return func(); 3 | } 4 | 5 | exports.constructor = function() { 6 | this.test = 'test'; 7 | } 8 | -------------------------------------------------------------------------------- /spec/fixtures/pages/b.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spec/fixtures/module/runas.js: -------------------------------------------------------------------------------- 1 | process.on('uncaughtException', function(err) { 2 | process.send(err.message); 3 | }); 4 | 5 | require('runas'); 6 | process.send('ok'); 7 | -------------------------------------------------------------------------------- /spec/fixtures/module/create_socket.js: -------------------------------------------------------------------------------- 1 | var net = require('net'); 2 | var server = net.createServer(function() {}); 3 | server.listen(process.argv[2]); 4 | process.exit(0); 5 | -------------------------------------------------------------------------------- /atom/browser/api/lib/global-shortcut.coffee: -------------------------------------------------------------------------------- 1 | bindings = process.atomBinding 'global_shortcut' 2 | 3 | globalShortcut = bindings.globalShortcut 4 | 5 | module.exports = globalShortcut 6 | -------------------------------------------------------------------------------- /atom/browser/default_app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-shell-default-app", 3 | "productName": "Atom Shell Default App", 4 | "version": "0.1.0", 5 | "main": "main.js" 6 | } 7 | -------------------------------------------------------------------------------- /atom/browser/api/lib/atom-delegate.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | browserMainParts: 3 | preMainMessageLoopRun: -> 4 | 5 | setImmediate -> 6 | module.exports.browserMainParts.preMainMessageLoopRun() 7 | -------------------------------------------------------------------------------- /spec/fixtures/pages/c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spec/fixtures/pages/d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spec/fixtures/workers/shared_worker.js: -------------------------------------------------------------------------------- 1 | onconnect = function(event) { 2 | var port = event.ports[0]; 3 | port.start(); 4 | port.onmessage = function(event) { 5 | port.postMessage(event.data); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /build/ 3 | /dist/ 4 | /external_binaries/ 5 | /out/ 6 | /vendor/brightray/vendor/download/ 7 | /vendor/python_26/ 8 | /vendor/npm/ 9 | node_modules/ 10 | *.xcodeproj 11 | *.swp 12 | *.pyc 13 | -------------------------------------------------------------------------------- /tools/atom_source_root.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | 5 | """Prints the absolute path of the root of atom-shell's source tree. 6 | """ 7 | 8 | 9 | print os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 10 | -------------------------------------------------------------------------------- /tools/mac/create-framework-subdir-symlinks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd "${BUILT_PRODUCTS_DIR}/${1}.framework" 6 | shift 7 | 8 | while [ ! -z "${1}" ]; do 9 | ln -sf Versions/Current/"${1}" "${1}" 10 | shift 11 | done 12 | -------------------------------------------------------------------------------- /spec/fixtures/api/send-sync-message.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: clang 3 | os: 4 | - linux 5 | - osx 6 | 7 | notifications: 8 | email: 9 | on_success: never 10 | on_failure: change 11 | 12 | script: './script/cibuild' 13 | 14 | git: 15 | depth: 10 16 | -------------------------------------------------------------------------------- /atom/browser/api/lib/power-monitor.coffee: -------------------------------------------------------------------------------- 1 | powerMonitor = process.atomBinding('power_monitor').powerMonitor 2 | EventEmitter = require('events').EventEmitter 3 | 4 | powerMonitor.__proto__ = EventEmitter.prototype 5 | 6 | module.exports = powerMonitor 7 | -------------------------------------------------------------------------------- /atom/common/api/lib/shell.coffee: -------------------------------------------------------------------------------- 1 | module.exports = process.atomBinding 'shell' 2 | 3 | if process.platform is 'win32' and process.type is 'renderer' 4 | module.exports.showItemInFolder = require('remote').process.atomBinding('shell').showItemInFolder 5 | -------------------------------------------------------------------------------- /spec/fixtures/asar/web.asar: -------------------------------------------------------------------------------- 1 | <82{"files":{"index.html":{"size":133,"offset":"0"}}} 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tools/copy_binary.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import shutil 5 | import stat 6 | import sys 7 | 8 | src = sys.argv[1] 9 | dist = sys.argv[2] 10 | 11 | shutil.copyfile(src, dist) 12 | os.chmod(dist, os.stat(dist).st_mode | stat.S_IEXEC) 13 | -------------------------------------------------------------------------------- /atom/common/api/lib/screen.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | if process.platform in ['linux', 'win32'] and process.type is 'renderer' 3 | # On Linux we could not access screen in renderer process. 4 | require('remote').require 'screen' 5 | else 6 | process.atomBinding 'screen' 7 | -------------------------------------------------------------------------------- /spec/fixtures/api/unload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spec/fixtures/api/close.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /atom/renderer/lib/chrome-api.coffee: -------------------------------------------------------------------------------- 1 | url = require 'url' 2 | 3 | chrome = window.chrome = window.chrome || {} 4 | chrome.extension = 5 | getURL: (path) -> 6 | url.format 7 | protocol: location.protocol 8 | slashes: true 9 | hostname: location.hostname 10 | pathname: path 11 | -------------------------------------------------------------------------------- /atom/browser/api/lib/content-tracing.coffee: -------------------------------------------------------------------------------- 1 | module.exports = process.atomBinding 'content_tracing' 2 | 3 | # Mirrored from content::TracingController::Options 4 | module.exports.DEFAULT_OPTIONS = 0 5 | module.exports.ENABLE_SYSTRACE = 1 << 0 6 | module.exports.ENABLE_SAMPLING = 1 << 1 7 | module.exports.RECORD_CONTINUOUSLY = 1 << 2 8 | -------------------------------------------------------------------------------- /atom/browser/mac/atom_application_delegate.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | 7 | @interface AtomApplicationDelegate : NSObject { 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /spec/fixtures/api/beforeunload-false.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /atom/browser/api/lib/tray.coffee: -------------------------------------------------------------------------------- 1 | EventEmitter = require('events').EventEmitter 2 | bindings = process.atomBinding 'tray' 3 | 4 | Tray = bindings.Tray 5 | Tray::__proto__ = EventEmitter.prototype 6 | Tray::setContextMenu = (menu) -> 7 | @_setContextMenu menu 8 | @menu = menu # Keep a strong reference of menu. 9 | 10 | module.exports = Tray 11 | -------------------------------------------------------------------------------- /spec/api-clipboard-spec.coffee: -------------------------------------------------------------------------------- 1 | assert = require 'assert' 2 | clipboard = require 'clipboard' 3 | 4 | describe 'clipboard module', -> 5 | describe 'clipboard.readText()', -> 6 | it 'returns unicode string correctly', -> 7 | text = '千江有水千江月,万里无云万里天' 8 | clipboard.writeText text 9 | assert.equal clipboard.readText(), text 10 | -------------------------------------------------------------------------------- /atom/app/atom_main.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_APP_ATOM_MAIN_H_ 6 | #define ATOM_APP_ATOM_MAIN_H_ 7 | 8 | #include "content/public/app/content_main.h" 9 | 10 | #endif // ATOM_APP_ATOM_MAIN_H_ 11 | -------------------------------------------------------------------------------- /spec/fixtures/api/close-beforeunload-false.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spec/fixtures/api/close-beforeunload-empty-string.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spec/fixtures/api/close-beforeunload-string.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spec/fixtures/api/close-beforeunload-true.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /atom/common/draggable_region.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/draggable_region.h" 6 | 7 | namespace atom { 8 | 9 | DraggableRegion::DraggableRegion() 10 | : draggable(false) { 11 | } 12 | 13 | } // namespace atom 14 | -------------------------------------------------------------------------------- /spec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-shell-specs", 3 | "productName": "Atom Shell Test App", 4 | "main": "static/main.js", 5 | "version": "0.1.0", 6 | 7 | "devDependencies": { 8 | "formidable": "~1.0.14", 9 | "pathwatcher": "2.x", 10 | "q": "0.9.7", 11 | "mocha": "~1.18.2", 12 | "runas": "1.x", 13 | "temp": "~0.6.0", 14 | "walkdir": "~0.0.7" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /atom/common/common_message_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // Multiply-included file, no traditional include guard. 6 | 7 | #include "atom/common/api/api_messages.h" 8 | #include "chrome/common/print_messages.h" 9 | #include "chrome/common/tts_messages.h" 10 | -------------------------------------------------------------------------------- /spec/fixtures/module/fork_ping.js: -------------------------------------------------------------------------------- 1 | process.on('uncaughtException', function(error) { 2 | process.send(error.stack); 3 | }); 4 | 5 | var child = require('child_process').fork(__dirname + '/ping.js'); 6 | process.on('message', function(msg) { 7 | child.send(msg); 8 | }); 9 | child.on('message', function (msg) { 10 | process.send(msg); 11 | }); 12 | child.on('exit', function(code) { 13 | process.exit(code); 14 | }); 15 | -------------------------------------------------------------------------------- /docs/api/process.md: -------------------------------------------------------------------------------- 1 | # Process object 2 | 3 | The `process` object in atom-shell has following differences between the one in 4 | upstream node: 5 | 6 | * `process.type` String - Process's type, can be `browser` or `renderer`. 7 | * `process.versions['atom-shell']` String - Version of atom-shell. 8 | * `process.versions['chrome']` String - Version of Chromium. 9 | * `process.resourcesPath` String - Path to JavaScript source code. 10 | -------------------------------------------------------------------------------- /atom/common/google_api_key.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_GOOGLE_API_KEY_H_ 6 | #define ATOM_COMMON_GOOGLE_API_KEY_H_ 7 | 8 | #ifndef GOOGLEAPIS_API_KEY 9 | #define GOOGLEAPIS_API_KEY "AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q" 10 | #endif 11 | 12 | #endif // ATOM_COMMON_GOOGLE_API_KEY_H_ 13 | -------------------------------------------------------------------------------- /atom/browser/auto_updater_linux.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/auto_updater.h" 6 | 7 | namespace auto_updater { 8 | 9 | // static 10 | void AutoUpdater::SetFeedURL(const std::string& url) { 11 | } 12 | 13 | // static 14 | void AutoUpdater::CheckForUpdates() { 15 | } 16 | 17 | } // namespace auto_updater 18 | -------------------------------------------------------------------------------- /atom/browser/auto_updater_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/auto_updater.h" 6 | 7 | namespace auto_updater { 8 | 9 | // static 10 | void AutoUpdater::SetFeedURL(const std::string& url) { 11 | } 12 | 13 | // static 14 | void AutoUpdater::CheckForUpdates() { 15 | } 16 | 17 | } // namespace auto_updater 18 | -------------------------------------------------------------------------------- /atom/browser/ui/accelerator_util_views.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/accelerator_util.h" 6 | 7 | #include "ui/base/accelerators/accelerator.h" 8 | 9 | namespace accelerator_util { 10 | 11 | void SetPlatformAccelerator(ui::Accelerator* accelerator) { 12 | } 13 | 14 | } // namespace accelerator_util 15 | -------------------------------------------------------------------------------- /atom/browser/resources/win/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | 4 | #define IDR_MAINFRAME 1 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1001 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /docs/api/power-monitor.md: -------------------------------------------------------------------------------- 1 | # power-monitor 2 | 3 | The `power-monitor` module is used to monitor the power state change, you can 4 | only use it on the browser side. 5 | 6 | An example is: 7 | 8 | ```javascript 9 | require('power-monitor').on('suspend', function() { 10 | console.log('The system is going to sleep'); 11 | }); 12 | ``` 13 | 14 | ## Event: suspend 15 | 16 | Emitted when the system is suspending. 17 | 18 | ## Event: resume 19 | 20 | Emitted when system is resuming. 21 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/win/notify_icon.h" 6 | #include "atom/browser/ui/win/notify_icon_host.h" 7 | 8 | namespace atom { 9 | 10 | // static 11 | TrayIcon* TrayIcon::Create() { 12 | static NotifyIconHost host; 13 | return host.CreateNotifyIcon(); 14 | } 15 | 16 | } // namespace atom 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atom-shell", 3 | "version": "0.18.2", 4 | 5 | "licenses": [ 6 | { 7 | "type": "MIT", 8 | "url": "http://github.com/atom/atom-shell/raw/master/LICENSE.md" 9 | } 10 | ], 11 | 12 | "devDependencies": { 13 | "atom-package-manager": "0.102.0", 14 | "coffee-script": "~1.7.1", 15 | "coffeelint": "~1.3.0" 16 | }, 17 | 18 | "private": true, 19 | 20 | "scripts": { 21 | "preinstall": "node -e 'process.exit(0)'" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /atom/common/linux/application_info.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | #include "atom/common/atom_version.h" 8 | 9 | namespace brightray { 10 | 11 | std::string GetApplicationName() { 12 | return "Atom-Shell"; 13 | } 14 | 15 | std::string GetApplicationVersion() { 16 | return ATOM_VERSION_STRING; 17 | } 18 | 19 | } // namespace brightray 20 | -------------------------------------------------------------------------------- /tools/win/register_msdia80_dll.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var path = require('path'); 3 | var runas = require('runas'); 4 | 5 | var source = path.resolve(__dirname, '..', '..', 'vendor', 'breakpad', 'msdia80.dll'); 6 | var target = 'C:\\Program Files\\Common Files\\Microsoft Shared\\VC\\msdia80.dll'; 7 | if (fs.existsSync(target)) 8 | return; 9 | 10 | var copy = 'copy "' + source + '" "' + target + '"'; 11 | var register = 'regsvr32 "' + target + '"'; 12 | runas('cmd', ['/K', copy + ' & ' + register + ' & exit']); 13 | -------------------------------------------------------------------------------- /docs/api/screen.md: -------------------------------------------------------------------------------- 1 | # screen 2 | 3 | Gets various info about screen size, displays, cursor position, etc. 4 | ```js 5 | var Screen = require('screen'); 6 | var BrowserWindow = require('browser-window'); 7 | var size = Screen.getPrimaryDisplay().workAreaSize; 8 | mainWindow = new BrowserWindow({ width: size.width, height: size.height }); 9 | ``` 10 | 11 | ## screen.getCursorScreenPoint() 12 | 13 | Returns the current absolute position of the mouse pointer. 14 | 15 | ## screen.getPrimaryDisplay() 16 | 17 | Returns the primary display. 18 | -------------------------------------------------------------------------------- /script/chrome_version.h.in: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file is generated by script/bootstrap.py, you should never modify it 6 | // by hand. 7 | 8 | #ifndef ATOM_COMMON_CHROME_VERSION_H_ 9 | #define ATOM_COMMON_CHROME_VERSION_H_ 10 | 11 | #define CHROME_VERSION_STRING "{PLACEHOLDER}" 12 | #define CHROME_VERSION "v" CHROME_VERSION_STRING 13 | 14 | #endif // ATOM_COMMON_CHROME_VERSION_H_ 15 | -------------------------------------------------------------------------------- /atom/app/atom_library_main.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_APP_ATOM_LIBRARY_MAIN_H_ 6 | #define ATOM_APP_ATOM_LIBRARY_MAIN_H_ 7 | 8 | #include "base/basictypes.h" 9 | 10 | #if defined(OS_MACOSX) 11 | extern "C" { 12 | __attribute__((visibility("default"))) 13 | int AtomMain(int argc, const char* argv[]); 14 | } 15 | #endif // OS_MACOSX 16 | 17 | #endif // ATOM_APP_ATOM_LIBRARY_MAIN_H_ 18 | -------------------------------------------------------------------------------- /atom/common/chrome_version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file is generated by script/bootstrap.py, you should never modify it 6 | // by hand. 7 | 8 | #ifndef ATOM_COMMON_CHROME_VERSION_H_ 9 | #define ATOM_COMMON_CHROME_VERSION_H_ 10 | 11 | #define CHROME_VERSION_STRING "38.0.2125.101" 12 | #define CHROME_VERSION "v" CHROME_VERSION_STRING 13 | 14 | #endif // ATOM_COMMON_CHROME_VERSION_H_ 15 | -------------------------------------------------------------------------------- /atom/common/draggable_region.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_DRAGGABLE_REGION_H_ 6 | #define ATOM_COMMON_DRAGGABLE_REGION_H_ 7 | 8 | #include "ui/gfx/rect.h" 9 | 10 | namespace atom { 11 | 12 | struct DraggableRegion { 13 | bool draggable; 14 | gfx::Rect bounds; 15 | 16 | DraggableRegion(); 17 | }; 18 | 19 | } // namespace atom 20 | 21 | #endif // ATOM_COMMON_DRAGGABLE_REGION_H_ 22 | -------------------------------------------------------------------------------- /atom/renderer/resources/mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.github.atom.helper 7 | CFBundleName 8 | ${PRODUCT_NAME} 9 | CFBundlePackageType 10 | APPL 11 | LSUIElement 12 | 13 | NSSupportsAutomaticGraphicsSwitching 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /atom/browser/auto_updater.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/auto_updater.h" 6 | 7 | namespace auto_updater { 8 | 9 | AutoUpdaterDelegate* AutoUpdater::delegate_ = NULL; 10 | 11 | AutoUpdaterDelegate* AutoUpdater::GetDelegate() { 12 | return delegate_; 13 | } 14 | 15 | void AutoUpdater::SetDelegate(AutoUpdaterDelegate* delegate) { 16 | delegate_ = delegate; 17 | } 18 | 19 | } // namespace auto_updater 20 | -------------------------------------------------------------------------------- /atom/common/crash_reporter/win/crash_service_main.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_CRASH_REPORTER_WIN_CRASH_SERVICE_MAIN_H_ 6 | #define ATOM_COMMON_CRASH_REPORTER_WIN_CRASH_SERVICE_MAIN_H_ 7 | 8 | namespace crash_service { 9 | 10 | // Program entry, should be called by main(); 11 | int Main(const wchar_t* cmd_line); 12 | 13 | } // namespace crash_service 14 | 15 | #endif // ATOM_COMMON_CRASH_REPORTER_WIN_CRASH_SERVICE_MAIN_H_ 16 | -------------------------------------------------------------------------------- /atom/common/resources/mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | Atom Framework 7 | CFBundleIdentifier 8 | com.github.AtomFramework 9 | CFBundleName 10 | Atom Framework 11 | CFBundlePackageType 12 | FMWK 13 | NSSupportsAutomaticGraphicsSwitching 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/brightray"] 2 | path = vendor/brightray 3 | url = https://github.com/brightray/brightray.git 4 | [submodule "vendor/node"] 5 | path = vendor/node 6 | url = https://github.com/atom/node.git 7 | [submodule "vendor/depot_tools"] 8 | path = vendor/depot_tools 9 | url = https://chromium.googlesource.com/chromium/tools/depot_tools.git 10 | [submodule "vendor/breakpad"] 11 | path = vendor/breakpad 12 | url = https://github.com/atom/chromium-breakpad.git 13 | [submodule "vendor/native_mate"] 14 | path = vendor/native_mate 15 | url = https://github.com/zcbenz/native-mate.git 16 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_ 6 | #define ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_ 7 | 8 | namespace atom { 9 | 10 | class TrayIconObserver { 11 | public: 12 | virtual void OnClicked() {} 13 | virtual void OnDoubleClicked() {} 14 | 15 | protected: 16 | virtual ~TrayIconObserver() {} 17 | }; 18 | 19 | } // namespace atom 20 | 21 | #endif // ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_ 22 | -------------------------------------------------------------------------------- /spec/fixtures/api/crash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /script/pylint.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import glob 4 | import os 5 | import subprocess 6 | import sys 7 | 8 | SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 9 | 10 | 11 | def main(): 12 | os.chdir(SOURCE_ROOT) 13 | 14 | pylint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'pylint.py') 15 | settings = ['--rcfile=vendor/depot_tools/pylintrc'] 16 | pys = glob.glob('script/*.py') 17 | subprocess.check_call([sys.executable, pylint] + settings + pys, 18 | env=dict(PYTHONPATH='script')) 19 | 20 | 21 | if __name__ == '__main__': 22 | sys.exit(main()) 23 | -------------------------------------------------------------------------------- /atom/app/atom_library_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/app/atom_library_main.h" 6 | 7 | #include "atom/app/atom_main_delegate.h" 8 | #include "content/public/app/content_main.h" 9 | 10 | #if defined(OS_MACOSX) 11 | int AtomMain(int argc, const char* argv[]) { 12 | atom::AtomMainDelegate delegate; 13 | content::ContentMainParams params(&delegate); 14 | params.argc = argc; 15 | params.argv = argv; 16 | return content::ContentMain(params); 17 | } 18 | #endif // OS_MACOSX 19 | -------------------------------------------------------------------------------- /atom/common/api/lib/clipboard.coffee: -------------------------------------------------------------------------------- 1 | if process.platform is 'linux' and process.type is 'renderer' 2 | # On Linux we could not access clipboard in renderer process. 3 | module.exports = require('remote').require 'clipboard' 4 | else 5 | binding = process.atomBinding 'clipboard' 6 | 7 | module.exports = 8 | has: (format, type='standard') -> binding._has format, type 9 | read: (format, type='standard') -> binding._read format, type 10 | readText: (type='standard') -> binding._readText type 11 | writeText: (text, type='standard') -> binding._writeText text, type 12 | clear: (type='standard') -> binding._clear type 13 | -------------------------------------------------------------------------------- /spec/api-screen-spec.coffee: -------------------------------------------------------------------------------- 1 | assert = require 'assert' 2 | screen = require 'screen' 3 | 4 | describe 'screen module', -> 5 | describe 'screen.getCursorScreenPoint()', -> 6 | it 'returns a point object', -> 7 | point = screen.getCursorScreenPoint() 8 | assert.equal typeof(point.x), 'number' 9 | assert.equal typeof(point.y), 'number' 10 | 11 | describe 'screen.getPrimaryDisplay()', -> 12 | it 'returns a display object', -> 13 | display = screen.getPrimaryDisplay() 14 | assert.equal typeof(display.scaleFactor), 'number' 15 | assert display.size.width > 0 16 | assert display.size.height > 0 17 | -------------------------------------------------------------------------------- /script/lib/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import platform 4 | import sys 5 | 6 | BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' 7 | LIBCHROMIUMCONTENT_COMMIT = '2dfdf169b582e3f051e1fec3dd7df2bc179e1aa6' 8 | 9 | ARCH = { 10 | 'cygwin': '32bit', 11 | 'darwin': '64bit', 12 | 'linux2': platform.architecture()[0], 13 | 'win32': '32bit', 14 | }[sys.platform] 15 | DIST_ARCH = { 16 | '32bit': 'ia32', 17 | '64bit': 'x64', 18 | }[ARCH] 19 | 20 | TARGET_PLATFORM = { 21 | 'cygwin': 'win32', 22 | 'darwin': 'darwin', 23 | 'linux2': 'linux', 24 | 'win32': 'win32', 25 | }[sys.platform] 26 | -------------------------------------------------------------------------------- /atom/browser/api/lib/protocol.coffee: -------------------------------------------------------------------------------- 1 | protocol = process.atomBinding('protocol').protocol 2 | EventEmitter = require('events').EventEmitter 3 | 4 | protocol.__proto__ = EventEmitter.prototype 5 | 6 | protocol.RequestStringJob = 7 | class RequestStringJob 8 | constructor: ({mimeType, charset, data}) -> 9 | if typeof data isnt 'string' and not data instanceof Buffer 10 | throw new TypeError('Data should be string or Buffer') 11 | 12 | @mimeType = mimeType ? 'text/plain' 13 | @charset = charset ? 'UTF-8' 14 | @data = String data 15 | 16 | protocol.RequestFileJob = 17 | class RequestFileJob 18 | constructor: (@path) -> 19 | 20 | module.exports = protocol 21 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # appveyor file 2 | # http://www.appveyor.com/docs/appveyor-yml 3 | version: "{build}" 4 | 5 | init: 6 | - git config --global core.autocrlf input 7 | 8 | environment: 9 | matrix: 10 | - nodejs_version: 0.10 11 | 12 | platform: 13 | - x86 14 | 15 | install: 16 | - ps: Install-Product node $env:nodejs_version 17 | - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% 18 | - cmd: SET PATH=C:\python27;%PATH% 19 | - cmd: python script/bootstrap.py 20 | - cmd: python script/build.py -c Debug 21 | 22 | test_script: 23 | - node --version 24 | - npm --version 25 | - cmd: python script/cpplint.py 26 | - cmd: python script/coffeelint.py 27 | 28 | build: off 29 | -------------------------------------------------------------------------------- /atom/browser/mac/atom_application.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #import "base/mac/scoped_sending_event.h" 6 | 7 | @interface AtomApplication : NSApplication { 9 | @private 10 | BOOL handlingSendEvent_; 11 | } 12 | 13 | + (AtomApplication*)sharedApplication; 14 | 15 | // CrAppProtocol: 16 | - (BOOL)isHandlingSendEvent; 17 | 18 | // CrAppControlProtocol: 19 | - (void)setHandlingSendEvent:(BOOL)handlingSendEvent; 20 | 21 | - (IBAction)closeAllWindows:(id)sender; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /atom/browser/javascript_environment.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/javascript_environment.h" 6 | 7 | namespace atom { 8 | 9 | JavascriptEnvironment::JavascriptEnvironment() 10 | : isolate_holder_(gin::IsolateHolder::kNonStrictMode), 11 | isolate_(isolate_holder_.isolate()), 12 | isolate_scope_(isolate_), 13 | locker_(isolate_), 14 | handle_scope_(isolate_), 15 | context_(isolate_, v8::Context::New(isolate_)), 16 | context_scope_(v8::Local::New(isolate_, context_)) { 17 | } 18 | 19 | } // namespace atom 20 | -------------------------------------------------------------------------------- /docs/api/menu-item.md: -------------------------------------------------------------------------------- 1 | # menu-item 2 | 3 | ## Class: MenuItem 4 | 5 | ### new MenuItem(options) 6 | 7 | * `options` Object 8 | * `click` Function - Callback when the menu item is clicked 9 | * `selector` String - Call the selector of first responder when clicked (OS 10 | X only) 11 | * `type` String - Can be `normal`, `separator`, `submenu`, `checkbox` or 12 | `radio` 13 | * `label` String 14 | * `sublabel` String 15 | * `accelerator` [Accelerator](accelerator.md) 16 | * `enabled` Boolean 17 | * `visible` Boolean 18 | * `checked` Boolean 19 | * `submenu` Menu - Should be specified for `submenu` type menu item, when 20 | it's specified the `type: 'submenu'` can be omitted for the menu item 21 | -------------------------------------------------------------------------------- /atom/renderer/api/lib/ipc.coffee: -------------------------------------------------------------------------------- 1 | EventEmitter = require('events').EventEmitter 2 | process = global.process 3 | ipc = process.atomBinding('ipc') 4 | 5 | class Ipc extends EventEmitter 6 | constructor: -> 7 | process.on 'ATOM_INTERNAL_MESSAGE', (args...) => 8 | @emit args... 9 | 10 | window.addEventListener 'unload', (event) -> 11 | process.removeAllListeners 'ATOM_INTERNAL_MESSAGE' 12 | 13 | send: (args...) -> 14 | ipc.send 'ipc-message', [args...] 15 | 16 | sendSync: (args...) -> 17 | JSON.parse ipc.sendSync('ipc-message-sync', [args...]) 18 | 19 | # Discarded 20 | sendChannel: -> @send.apply this, arguments 21 | sendChannelSync: -> @sendSync.apply this, arguments 22 | 23 | module.exports = new Ipc 24 | -------------------------------------------------------------------------------- /script/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | 8 | SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 9 | 10 | 11 | def main(): 12 | os.chdir(SOURCE_ROOT) 13 | 14 | if sys.platform == 'darwin': 15 | atom_shell = os.path.join(SOURCE_ROOT, 'out', 'Debug', 'Atom.app', 16 | 'Contents', 'MacOS', 'Atom') 17 | elif sys.platform == 'win32': 18 | atom_shell = os.path.join(SOURCE_ROOT, 'out', 'Debug', 'atom.exe') 19 | else: 20 | atom_shell = os.path.join(SOURCE_ROOT, 'out', 'Debug', 'atom') 21 | 22 | subprocess.check_call([atom_shell, 'spec'] + sys.argv[1:]) 23 | 24 | 25 | if __name__ == '__main__': 26 | sys.exit(main()) 27 | -------------------------------------------------------------------------------- /atom/browser/ui/x/x_window_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ 6 | #define ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace atom { 13 | 14 | ::Atom GetAtom(const char* name); 15 | 16 | // Sends a message to the x11 window manager, enabling or disabling the |state| 17 | // for _NET_WM_STATE. 18 | void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state); 19 | 20 | } // namespace atom 21 | 22 | #endif // ATOM_BROWSER_UI_X_X_WINDOW_UTILS_H_ 23 | -------------------------------------------------------------------------------- /atom/browser/api/atom_api_menu_views.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_ 6 | #define ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_ 7 | 8 | #include "atom/browser/api/atom_api_menu.h" 9 | 10 | namespace atom { 11 | 12 | namespace api { 13 | 14 | class MenuViews : public Menu { 15 | public: 16 | MenuViews(); 17 | 18 | protected: 19 | virtual void Popup(Window* window) OVERRIDE; 20 | 21 | private: 22 | DISALLOW_COPY_AND_ASSIGN(MenuViews); 23 | }; 24 | 25 | } // namespace api 26 | 27 | } // namespace atom 28 | 29 | #endif // ATOM_BROWSER_API_ATOM_API_MENU_VIEWS_H_ 30 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/tray_icon.h" 6 | 7 | namespace atom { 8 | 9 | TrayIcon::TrayIcon() { 10 | } 11 | 12 | TrayIcon::~TrayIcon() { 13 | } 14 | 15 | void TrayIcon::SetTitle(const std::string& title) { 16 | } 17 | 18 | void TrayIcon::SetHighlightMode(bool highlight) { 19 | } 20 | 21 | void TrayIcon::NotifyClicked() { 22 | FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked()); 23 | } 24 | 25 | void TrayIcon::NotifyDoubleClicked() { 26 | FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDoubleClicked()); 27 | } 28 | 29 | } // namespace atom 30 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/accelerator_converter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/native_mate_converters/accelerator_converter.h" 6 | 7 | #include 8 | 9 | #include "atom/browser/ui/accelerator_util.h" 10 | 11 | namespace mate { 12 | 13 | // static 14 | bool Converter::FromV8( 15 | v8::Isolate* isolate, v8::Handle val, ui::Accelerator* out) { 16 | std::string keycode; 17 | if (!ConvertFromV8(isolate, val, &keycode)) 18 | return false; 19 | return accelerator_util::StringToAccelerator(keycode, out); 20 | } 21 | 22 | } // namespace mate 23 | -------------------------------------------------------------------------------- /atom/common/node_bindings_win.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NODE_BINDINGS_WIN_H_ 6 | #define ATOM_COMMON_NODE_BINDINGS_WIN_H_ 7 | 8 | #include "atom/common/node_bindings.h" 9 | #include "base/compiler_specific.h" 10 | 11 | namespace atom { 12 | 13 | class NodeBindingsWin : public NodeBindings { 14 | public: 15 | explicit NodeBindingsWin(bool is_browser); 16 | virtual ~NodeBindingsWin(); 17 | 18 | private: 19 | virtual void PollEvents() OVERRIDE; 20 | 21 | DISALLOW_COPY_AND_ASSIGN(NodeBindingsWin); 22 | }; 23 | 24 | } // namespace atom 25 | 26 | #endif // ATOM_COMMON_NODE_BINDINGS_WIN_H_ 27 | -------------------------------------------------------------------------------- /chromium_src/chrome/common/tts_utterance_request.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "chrome/common/tts_utterance_request.h" 6 | 7 | TtsUtteranceRequest::TtsUtteranceRequest() 8 | : id(0), 9 | volume(1.0), 10 | rate(1.0), 11 | pitch(1.0) { 12 | } 13 | 14 | TtsUtteranceRequest::~TtsUtteranceRequest() { 15 | } 16 | 17 | TtsVoice::TtsVoice() 18 | : local_service(true), 19 | is_default(false) { 20 | } 21 | 22 | TtsVoice::~TtsVoice() { 23 | } 24 | 25 | TtsUtteranceResponse::TtsUtteranceResponse() 26 | : id(0) { 27 | } 28 | 29 | TtsUtteranceResponse::~TtsUtteranceResponse() { 30 | } -------------------------------------------------------------------------------- /atom/common/api/lib/callbacks-registry.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | class CallbacksRegistry 3 | constructor: -> 4 | @emptyFunc = -> throw new Error "Browser trying to call a non-exist callback 5 | in renderer, this usually happens when renderer code forgot to release 6 | a callback installed on objects in browser when renderer was going to be 7 | unloaded or released." 8 | @callbacks = {} 9 | 10 | add: (callback) -> 11 | id = Math.random().toString() 12 | @callbacks[id] = callback 13 | id 14 | 15 | get: (id) -> 16 | @callbacks[id] ? -> 17 | 18 | call: (id, args...) -> 19 | @get(id).call global, args... 20 | 21 | apply: (id, args...) -> 22 | @get(id).apply global, args... 23 | 24 | remove: (id) -> 25 | delete @callbacks[id] 26 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/accelerator_converter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_ACCELERATOR_CONVERTER_H_ 6 | #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_ACCELERATOR_CONVERTER_H_ 7 | 8 | #include "native_mate/converter.h" 9 | 10 | namespace ui { 11 | class Accelerator; 12 | } 13 | 14 | namespace mate { 15 | 16 | template<> 17 | struct Converter { 18 | static bool FromV8(v8::Isolate* isolate, v8::Handle val, 19 | ui::Accelerator* out); 20 | }; 21 | 22 | } // namespace mate 23 | 24 | #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_ACCELERATOR_CONVERTER_H_ 25 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/image_converter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_ 6 | #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_ 7 | 8 | #include "native_mate/converter.h" 9 | 10 | namespace gfx { 11 | class ImageSkia; 12 | } 13 | 14 | namespace mate { 15 | 16 | template<> 17 | struct Converter { 18 | static bool FromV8(v8::Isolate* isolate, 19 | v8::Handle val, 20 | gfx::ImageSkia* out); 21 | }; 22 | 23 | } // namespace mate 24 | 25 | #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_ 26 | -------------------------------------------------------------------------------- /atom/app/atom_content_client.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/app/atom_content_client.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "atom/common/chrome_version.h" 11 | 12 | namespace atom { 13 | 14 | AtomContentClient::AtomContentClient() { 15 | } 16 | 17 | AtomContentClient::~AtomContentClient() { 18 | } 19 | 20 | std::string AtomContentClient::GetProduct() const { 21 | return "Chrome/" CHROME_VERSION_STRING; 22 | } 23 | 24 | void AtomContentClient::AddAdditionalSchemes( 25 | std::vector* standard_schemes, 26 | std::vector* savable_schemes) { 27 | standard_schemes->push_back("chrome-extension"); 28 | } 29 | 30 | } // namespace atom 31 | -------------------------------------------------------------------------------- /spec/fixtures/asar/a.asar: -------------------------------------------------------------------------------- 1 | hd]{"files":{"dir2":{"files":{"file1":{"size":6,"offset":"100"},"file2":{"size":6,"offset":"106"},"file3":{"size":6,"offset":"112"}}},"dir1":{"files":{"file1":{"size":6,"offset":"118"},"file2":{"size":6,"offset":"124"},"file3":{"size":6,"offset":"130"},"link1":{"link":"file1"},"link2":{"link":"dir1"}}},"dir3":{"files":{"file1":{"size":6,"offset":"136"},"file2":{"size":6,"offset":"142"},"file3":{"size":6,"offset":"148"}}},"file1":{"size":6,"offset":"0"},"file2":{"size":6,"offset":"6"},"file3":{"size":6,"offset":"12"},"link1":{"link":"file1"},"link2":{"link":"dir1"},"ping.js":{"size":82,"offset":"18"}}}file1 2 | file2 3 | file3 4 | process.on('message', function(msg) { 5 | process.send(msg); 6 | process.exit(0); 7 | }); 8 | file1 9 | file2 10 | file3 11 | file1 12 | file2 13 | file3 14 | file1 15 | file2 16 | file3 17 | -------------------------------------------------------------------------------- /script/coffeelint.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import glob 4 | import os 5 | import sys 6 | 7 | from lib.util import execute 8 | 9 | 10 | SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 11 | 12 | 13 | def main(): 14 | os.chdir(SOURCE_ROOT) 15 | 16 | coffeelint = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'coffeelint') 17 | if sys.platform in ['win32', 'cygwin']: 18 | coffeelint += '.cmd' 19 | settings = ['--quiet', '-f', os.path.join('script', 'coffeelint.json')] 20 | files = glob.glob('atom/browser/api/lib/*.coffee') + \ 21 | glob.glob('atom/renderer/api/lib/*.coffee') + \ 22 | glob.glob('atom/common/api/lib/*.coffee') + \ 23 | glob.glob('atom/browser/atom/*.coffee') 24 | 25 | execute([coffeelint] + settings + files) 26 | 27 | if __name__ == '__main__': 28 | sys.exit(main()) 29 | -------------------------------------------------------------------------------- /tools/posix/make_locale_paks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # usage: make_locale_paks locale_dir [...] 8 | # 9 | # This script creates the .pak files under locales directory, it is used to fool 10 | # the ResourcesBundle that the locale is available. 11 | 12 | set -eu 13 | 14 | if [[ ${#} -eq 0 ]]; then 15 | echo "usage: ${0} build_dir [locale_pak...]" >& 2 16 | exit 1 17 | fi 18 | 19 | PRODUCT_DIR="$1" 20 | shift 21 | 22 | LOCALES_DIR="${PRODUCT_DIR}/locales" 23 | if [[ ! -d "${LOCALES_DIR}" ]]; then 24 | mkdir "${LOCALES_DIR}" 25 | fi 26 | 27 | cd "${LOCALES_DIR}" 28 | 29 | for pak in "${@}"; do 30 | if [[ ! -f "${pak}.pak" ]]; then 31 | touch "${pak}.pak" 32 | fi 33 | done 34 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/speech/tts_platform.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "chrome/browser/speech/tts_platform.h" 6 | 7 | #include 8 | 9 | bool TtsPlatformImpl::LoadBuiltInTtsExtension( 10 | content::BrowserContext* browser_context) { 11 | return false; 12 | } 13 | 14 | std::string TtsPlatformImpl::error() { 15 | return error_; 16 | } 17 | 18 | void TtsPlatformImpl::clear_error() { 19 | error_ = std::string(); 20 | } 21 | 22 | void TtsPlatformImpl::set_error(const std::string& error) { 23 | error_ = error; 24 | } 25 | 26 | void TtsPlatformImpl::WillSpeakUtteranceWithVoice(const Utterance* utterance, 27 | const VoiceData& voice_data) { 28 | } -------------------------------------------------------------------------------- /chromium_src/chrome/browser/browser_process.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "chrome/browser/browser_process.h" 6 | 7 | #include "chrome/browser/printing/print_job_manager.h" 8 | #include "ui/base/l10n/l10n_util.h" 9 | 10 | BrowserProcess* g_browser_process = NULL; 11 | 12 | BrowserProcess::BrowserProcess() { 13 | g_browser_process = this; 14 | 15 | print_job_manager_.reset(new printing::PrintJobManager); 16 | } 17 | 18 | BrowserProcess::~BrowserProcess() { 19 | g_browser_process = NULL; 20 | } 21 | 22 | std::string BrowserProcess::GetApplicationLocale() { 23 | return l10n_util::GetApplicationLocale(""); 24 | } 25 | 26 | printing::PrintJobManager* BrowserProcess::print_job_manager() { 27 | return print_job_manager_.get(); 28 | } 29 | -------------------------------------------------------------------------------- /docs/api/file-object.md: -------------------------------------------------------------------------------- 1 | # `File` object 2 | 3 | The DOM's File interface provides abstraction around native files, in order to 4 | let users work on native files directly with HTML5 file API, atom-shell has 5 | added a `path` attribute to `File` interface which exposes the file's real path 6 | on filesystem. 7 | 8 | Example on getting real path of a dragged file: 9 | 10 | ```html 11 |
12 | Drag your file here 13 |
14 | 15 | 30 | ``` 31 | -------------------------------------------------------------------------------- /atom/browser/auto_updater.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_AUTO_UPDATER_H_ 6 | #define ATOM_BROWSER_AUTO_UPDATER_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | 12 | namespace auto_updater { 13 | 14 | class AutoUpdaterDelegate; 15 | 16 | class AutoUpdater { 17 | public: 18 | // Gets/Sets the delegate. 19 | static AutoUpdaterDelegate* GetDelegate(); 20 | static void SetDelegate(AutoUpdaterDelegate* delegate); 21 | 22 | static void SetFeedURL(const std::string& url); 23 | static void CheckForUpdates(); 24 | 25 | private: 26 | static AutoUpdaterDelegate* delegate_; 27 | 28 | DISALLOW_IMPLICIT_CONSTRUCTORS(AutoUpdater); 29 | }; 30 | 31 | } // namespace auto_updater 32 | 33 | #endif // ATOM_BROWSER_AUTO_UPDATER_H_ 34 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/printing/printing_ui_web_contents_observer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "chrome/browser/printing/printing_ui_web_contents_observer.h" 6 | 7 | #include "content/public/browser/browser_thread.h" 8 | #include "content/public/browser/web_contents.h" 9 | 10 | PrintingUIWebContentsObserver::PrintingUIWebContentsObserver( 11 | content::WebContents* web_contents) 12 | : content::WebContentsObserver(web_contents) { 13 | DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 14 | } 15 | 16 | gfx::NativeView PrintingUIWebContentsObserver::GetParentView() { 17 | DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 18 | return web_contents() ? web_contents()->GetNativeView() : NULL; 19 | } 20 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/printing/print_view_manager_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_OBSERVER_H_ 6 | #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_OBSERVER_H_ 7 | 8 | namespace printing { 9 | 10 | // An interface the PrintViewManager uses to notify an observer when the print 11 | // dialog is shown. Register the observer via PrintViewManager::set_observer. 12 | class PrintViewManagerObserver { 13 | public: 14 | // Notifies the observer that the print dialog was shown. 15 | virtual void OnPrintDialogShown() = 0; 16 | 17 | protected: 18 | virtual ~PrintViewManagerObserver() {} 19 | }; 20 | 21 | } // namespace printing 22 | 23 | #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_OBSERVER_H_ 24 | -------------------------------------------------------------------------------- /atom/browser/api/lib/auto-updater.coffee: -------------------------------------------------------------------------------- 1 | autoUpdater = process.atomBinding('auto_updater').autoUpdater 2 | EventEmitter = require('events').EventEmitter 3 | 4 | autoUpdater.__proto__ = EventEmitter.prototype 5 | 6 | autoUpdater.on 'update-downloaded-raw', (args...) -> 7 | args[3] = new Date(args[3]) # releaseDate 8 | @emit 'update-downloaded', args..., => @quitAndInstall() 9 | 10 | autoUpdater.quitAndInstall = -> 11 | # If we don't have any window then quitAndInstall immediately. 12 | BrowserWindow = require 'browser-window' 13 | windows = BrowserWindow.getAllWindows() 14 | if windows.length is 0 15 | @_quitAndInstall() 16 | return 17 | 18 | # Do the restart after all windows have been closed. 19 | app = require 'app' 20 | app.removeAllListeners 'window-all-closed' 21 | app.once 'window-all-closed', @_quitAndInstall.bind(this) 22 | win.close() for win in windows 23 | 24 | module.exports = autoUpdater 25 | -------------------------------------------------------------------------------- /docs/api/shell.md: -------------------------------------------------------------------------------- 1 | # shell 2 | 3 | The `shell` module provides functions related to desktop integration. 4 | 5 | An example of opening a URL in default browser: 6 | 7 | ```javascript 8 | var shell = require('shell'); 9 | shell.openExternal('https://github.com'); 10 | ``` 11 | 12 | ## shell.showItemInFolder(fullPath) 13 | 14 | * `fullPath` String 15 | 16 | Show the given file in a file manager. If possible, select the file. 17 | 18 | ## shell.openItem(fullPath) 19 | 20 | * `fullPath` String 21 | 22 | Open the given file in the desktop's default manner. 23 | 24 | ## shell.openExternal(url) 25 | 26 | * `url` String 27 | 28 | Open the given external protocol URL in the desktop's default manner. (For 29 | example, mailto: URLs in the default mail user agent.) 30 | 31 | ## shell.moveItemToTrash(fullPath) 32 | 33 | * `fullPath` String 34 | 35 | Move the given file to trash. 36 | 37 | ## shell.beep() 38 | 39 | Play the beep sound. 40 | -------------------------------------------------------------------------------- /docs/api/web-frame.md: -------------------------------------------------------------------------------- 1 | # web-frame 2 | 3 | The `web-frame` module can custom the rendering of current web page. 4 | 5 | An example of zooming current page to 200%. 6 | 7 | ```javascript 8 | var webFrame = require('web-frame'); 9 | webFrame.setZoomFactor(2); 10 | ``` 11 | 12 | ## webFrame.setZoomFactor(factor) 13 | 14 | * `factor` Number - Zoom factor 15 | 16 | Changes the zoom factor to the specified factor, zoom factor is 17 | zoom percent / 100, so 300% = 3.0. 18 | 19 | ## webFrame.getZoomFactor() 20 | 21 | Returns the current zoom factor. 22 | 23 | ## webFrame.setZoomLevel(level) 24 | 25 | * `level` Number - Zoom level 26 | 27 | Changes the zoom level to the specified level, 0 is "original size", and each 28 | increment above or below represents zooming 20% larger or smaller to default 29 | limits of 300% and 50% of original size, respectively. 30 | 31 | ## webFrame.getZoomLevel() 32 | 33 | Returns the current zoom level. 34 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon_win.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_TRAY_ICON_WIN_H_ 6 | #define ATOM_BROWSER_UI_TRAY_ICON_WIN_H_ 7 | 8 | #include 9 | 10 | #include "atom/browser/ui/tray_icon.h" 11 | 12 | namespace atom { 13 | 14 | class TrayIconWin : public TrayIcon { 15 | public: 16 | TrayIconWin(); 17 | virtual ~TrayIconWin(); 18 | 19 | virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; 20 | virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; 21 | virtual void SetToolTip(const std::string& tool_tip) OVERRIDE; 22 | virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE; 23 | 24 | private: 25 | DISALLOW_COPY_AND_ASSIGN(TrayIconWin); 26 | }; 27 | 28 | } // namespace atom 29 | 30 | #endif // ATOM_BROWSER_UI_TRAY_ICON_WIN_H_ 31 | -------------------------------------------------------------------------------- /spec/api-app-spec.coffee: -------------------------------------------------------------------------------- 1 | assert = require 'assert' 2 | app = require('remote').require 'app' 3 | 4 | describe 'app module', -> 5 | describe 'app.getVersion()', -> 6 | it 'returns the version field of package.json', -> 7 | assert.equal app.getVersion(), '0.1.0' 8 | 9 | describe 'app.setVersion(version)', -> 10 | it 'overrides the version', -> 11 | assert.equal app.getVersion(), '0.1.0' 12 | app.setVersion 'test-version' 13 | assert.equal app.getVersion(), 'test-version' 14 | app.setVersion '0.1.0' 15 | 16 | describe 'app.getName()', -> 17 | it 'returns the name field of package.json', -> 18 | assert.equal app.getName(), 'Atom Shell Test App' 19 | 20 | describe 'app.setName(name)', -> 21 | it 'overrides the name', -> 22 | assert.equal app.getName(), 'Atom Shell Test App' 23 | app.setName 'test-name' 24 | assert.equal app.getName(), 'test-name' 25 | app.setName 'Atom Shell Test App' 26 | -------------------------------------------------------------------------------- /atom/app/atom_content_client.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_APP_ATOM_CONTENT_CLIENT_H_ 6 | #define ATOM_APP_ATOM_CONTENT_CLIENT_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "brightray/common/content_client.h" 12 | 13 | namespace atom { 14 | 15 | class AtomContentClient : public brightray::ContentClient { 16 | public: 17 | AtomContentClient(); 18 | virtual ~AtomContentClient(); 19 | 20 | protected: 21 | // content::ContentClient: 22 | virtual std::string GetProduct() const OVERRIDE; 23 | virtual void AddAdditionalSchemes( 24 | std::vector* standard_schemes, 25 | std::vector* savable_schemes) OVERRIDE; 26 | 27 | private: 28 | DISALLOW_COPY_AND_ASSIGN(AtomContentClient); 29 | }; 30 | 31 | } // namespace atom 32 | 33 | #endif // ATOM_APP_ATOM_CONTENT_CLIENT_H_ 34 | -------------------------------------------------------------------------------- /atom/common/api/object_life_monitor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_ 6 | #define ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_ 7 | 8 | #include "base/basictypes.h" 9 | #include "native_mate/scoped_persistent.h" 10 | 11 | namespace atom { 12 | 13 | class ObjectLifeMonitor { 14 | public: 15 | static void BindTo(v8::Isolate* isolate, 16 | v8::Handle target, 17 | v8::Handle destructor); 18 | 19 | private: 20 | ObjectLifeMonitor(); 21 | 22 | static void WeakCallback( 23 | const v8::WeakCallbackData& data); 24 | 25 | mate::ScopedPersistent handle_; 26 | 27 | DISALLOW_COPY_AND_ASSIGN(ObjectLifeMonitor); 28 | }; 29 | 30 | } // namespace atom 31 | 32 | #endif // ATOM_COMMON_API_OBJECT_LIFE_MONITOR_H_ 33 | -------------------------------------------------------------------------------- /atom/common/node_bindings_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NODE_BINDINGS_MAC_H_ 6 | #define ATOM_COMMON_NODE_BINDINGS_MAC_H_ 7 | 8 | #include "atom/common/node_bindings.h" 9 | #include "base/compiler_specific.h" 10 | 11 | namespace atom { 12 | 13 | class NodeBindingsMac : public NodeBindings { 14 | public: 15 | explicit NodeBindingsMac(bool is_browser); 16 | virtual ~NodeBindingsMac(); 17 | 18 | virtual void RunMessageLoop() OVERRIDE; 19 | 20 | private: 21 | // Called when uv's watcher queue changes. 22 | static void OnWatcherQueueChanged(uv_loop_t* loop); 23 | 24 | virtual void PollEvents() OVERRIDE; 25 | 26 | // Kqueue to poll for uv's backend fd. 27 | int kqueue_; 28 | 29 | DISALLOW_COPY_AND_ASSIGN(NodeBindingsMac); 30 | }; 31 | 32 | } // namespace atom 33 | 34 | #endif // ATOM_COMMON_NODE_BINDINGS_MAC_H_ 35 | -------------------------------------------------------------------------------- /atom/browser/api/atom_api_menu_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_ 6 | #define ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_ 7 | 8 | #include "atom/browser/api/atom_api_menu.h" 9 | 10 | #include 11 | 12 | #import "atom/browser/ui/cocoa/atom_menu_controller.h" 13 | 14 | namespace atom { 15 | 16 | namespace api { 17 | 18 | class MenuMac : public Menu { 19 | protected: 20 | MenuMac(); 21 | 22 | virtual void Popup(Window* window) OVERRIDE; 23 | 24 | base::scoped_nsobject menu_controller_; 25 | 26 | private: 27 | friend class Menu; 28 | 29 | static void SendActionToFirstResponder(const std::string& action); 30 | 31 | DISALLOW_COPY_AND_ASSIGN(MenuMac); 32 | }; 33 | 34 | } // namespace api 35 | 36 | } // namespace atom 37 | 38 | #endif // ATOM_BROWSER_API_ATOM_API_MENU_MAC_H_ 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Atom Shell [![Build Status](https://travis-ci.org/atom/atom-shell.svg?branch=master)](https://travis-ci.org/atom/atom-shell) 2 | 3 | The Atom Shell framework lets you write cross-platform desktop applications 4 | using JavaScript, HTML and CSS. It is based on [node.js](http://nodejs.org) and 5 | [Chromium](http://www.chromium.org) and is used in the [Atom 6 | editor](https://github.com/atom/atom). 7 | 8 | ## Downloads 9 | 10 | Prebuilt binaries of atom-shell for Linux, Windows and Mac can be found on the 11 | [releases](https://github.com/atom/atom-shell/releases) page. 12 | 13 | ## Documentation 14 | 15 | Guides and the API reference are located in the 16 | [docs](https://github.com/atom/atom-shell/tree/master/docs) directory. It also 17 | contains documents describing how to build and contribute to atom-shell. 18 | 19 | ## Community 20 | 21 | There is an [`atom-shell` category on the Atom forums](http://discuss.atom.io/category/atom-shell) 22 | as well as an `#atom-shell` channel on Freenode. 23 | -------------------------------------------------------------------------------- /atom/common/node_bindings_linux.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NODE_BINDINGS_LINUX_H_ 6 | #define ATOM_COMMON_NODE_BINDINGS_LINUX_H_ 7 | 8 | #include "base/compiler_specific.h" 9 | #include "atom/common/node_bindings.h" 10 | 11 | namespace atom { 12 | 13 | class NodeBindingsLinux : public NodeBindings { 14 | public: 15 | explicit NodeBindingsLinux(bool is_browser); 16 | virtual ~NodeBindingsLinux(); 17 | 18 | virtual void RunMessageLoop() OVERRIDE; 19 | 20 | private: 21 | // Called when uv's watcher queue changes. 22 | static void OnWatcherQueueChanged(uv_loop_t* loop); 23 | 24 | virtual void PollEvents() OVERRIDE; 25 | 26 | // Epoll to poll for uv's backend fd. 27 | int epoll_; 28 | 29 | DISALLOW_COPY_AND_ASSIGN(NodeBindingsLinux); 30 | }; 31 | 32 | } // namespace atom 33 | 34 | #endif // ATOM_COMMON_NODE_BINDINGS_LINUX_H_ 35 | -------------------------------------------------------------------------------- /atom/browser/browser_linux.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/browser.h" 6 | 7 | #include 8 | 9 | #include "atom/browser/native_window.h" 10 | #include "atom/browser/window_list.h" 11 | #include "atom/common/atom_version.h" 12 | 13 | namespace atom { 14 | 15 | void Browser::Focus() { 16 | // Focus on the first visible window. 17 | WindowList* list = WindowList::GetInstance(); 18 | for (WindowList::iterator iter = list->begin(); iter != list->end(); ++iter) { 19 | NativeWindow* window = *iter; 20 | if (window->IsVisible()) { 21 | window->Focus(true); 22 | break; 23 | } 24 | } 25 | } 26 | 27 | std::string Browser::GetExecutableFileVersion() const { 28 | return ATOM_VERSION_STRING; 29 | } 30 | 31 | std::string Browser::GetExecutableFileProductName() const { 32 | return "Atom-Shell"; 33 | } 34 | 35 | } // namespace atom 36 | -------------------------------------------------------------------------------- /docs/api/ipc-renderer.md: -------------------------------------------------------------------------------- 1 | # ipc (renderer) 2 | 3 | The `ipc` module provides a few methods so you can send synchronous and 4 | asynchronous messages to the browser, and also receive messages sent from 5 | browser. If you want to make use of modules of browser from renderer, you 6 | might consider using the [remote](remote.md) module. 7 | 8 | See [ipc (browser)](ipc-browser.md) for examples. 9 | 10 | ## ipc.send(channel[, args...]) 11 | 12 | Send `args..` to the web page via `channel` in asynchronous message, the browser 13 | process can handle it by listening to the `channel` event of `ipc` module. 14 | 15 | ## ipc.sendSync(channel[, args...]) 16 | 17 | Send `args..` to the web page via `channel` in synchronous message, and returns 18 | the result sent from browser. The browser process can handle it by listening to 19 | the `channel` event of `ipc` module, and returns by setting `event.returnValue`. 20 | 21 | **Note:** Usually developers should never use this API, since sending 22 | synchronous message would block the whole web page. 23 | -------------------------------------------------------------------------------- /atom/browser/atom_access_token_store.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_ 6 | #define ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_ 7 | 8 | #include "content/public/browser/access_token_store.h" 9 | 10 | namespace atom { 11 | 12 | class AtomBrowserContext; 13 | 14 | class AtomAccessTokenStore : public content::AccessTokenStore { 15 | public: 16 | AtomAccessTokenStore(); 17 | virtual ~AtomAccessTokenStore(); 18 | 19 | // content::AccessTokenStore: 20 | virtual void LoadAccessTokens( 21 | const LoadAccessTokensCallbackType& callback) OVERRIDE; 22 | virtual void SaveAccessToken(const GURL& server_url, 23 | const base::string16& access_token) OVERRIDE; 24 | 25 | private: 26 | DISALLOW_COPY_AND_ASSIGN(AtomAccessTokenStore); 27 | }; 28 | 29 | } // namespace atom 30 | 31 | #endif // ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_ 32 | -------------------------------------------------------------------------------- /atom/browser/ui/views/menu_layout.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_VIEWS_MENU_LAYOUT_H_ 6 | #define ATOM_BROWSER_UI_VIEWS_MENU_LAYOUT_H_ 7 | 8 | #include "ui/views/layout/fill_layout.h" 9 | 10 | namespace atom { 11 | 12 | class MenuLayout : public views::FillLayout { 13 | public: 14 | explicit MenuLayout(int menu_height); 15 | virtual ~MenuLayout(); 16 | 17 | // views::LayoutManager: 18 | virtual void Layout(views::View* host) OVERRIDE; 19 | virtual gfx::Size GetPreferredSize(const views::View* host) const OVERRIDE; 20 | virtual int GetPreferredHeightForWidth( 21 | const views::View* host, int width) const OVERRIDE; 22 | 23 | private: 24 | bool HasMenu(const views::View* host) const; 25 | 26 | int menu_height_; 27 | 28 | DISALLOW_COPY_AND_ASSIGN(MenuLayout); 29 | }; 30 | 31 | } // namespace atom 32 | 33 | #endif // ATOM_BROWSER_UI_VIEWS_MENU_LAYOUT_H_ 34 | -------------------------------------------------------------------------------- /atom/common/api/atom_api_screen.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/native_mate_converters/gfx_converter.h" 6 | #include "atom/common/node_includes.h" 7 | 8 | namespace { 9 | 10 | void Initialize(v8::Handle exports, v8::Handle unused, 11 | v8::Handle context, void* priv) { 12 | gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 13 | mate::Dictionary dict(context->GetIsolate(), exports); 14 | dict.SetMethod("getCursorScreenPoint", 15 | base::Bind(&gfx::Screen::GetCursorScreenPoint, 16 | base::Unretained(screen))); 17 | dict.SetMethod("getPrimaryDisplay", 18 | base::Bind(&gfx::Screen::GetPrimaryDisplay, 19 | base::Unretained(screen))); 20 | } 21 | 22 | } // namespace 23 | 24 | NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize) 25 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/value_converter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_ 6 | #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_ 7 | 8 | #include "native_mate/converter.h" 9 | 10 | namespace base { 11 | class DictionaryValue; 12 | class ListValue; 13 | } 14 | 15 | namespace mate { 16 | 17 | template<> 18 | struct Converter { 19 | static bool FromV8(v8::Isolate* isolate, 20 | v8::Handle val, 21 | base::DictionaryValue* out); 22 | }; 23 | 24 | template<> 25 | struct Converter { 26 | static bool FromV8(v8::Isolate* isolate, 27 | v8::Handle val, 28 | base::ListValue* out); 29 | }; 30 | 31 | } // namespace mate 32 | 33 | #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_VALUE_CONVERTER_H_ 34 | -------------------------------------------------------------------------------- /atom/browser/window_list_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_WINDOW_LIST_OBSERVER_H_ 6 | #define ATOM_BROWSER_WINDOW_LIST_OBSERVER_H_ 7 | 8 | namespace atom { 9 | 10 | class NativeWindow; 11 | 12 | class WindowListObserver { 13 | public: 14 | // Called immediately after a window is added to the list. 15 | virtual void OnWindowAdded(NativeWindow* window) {} 16 | 17 | // Called immediately after a window is removed from the list. 18 | virtual void OnWindowRemoved(NativeWindow* window) {} 19 | 20 | // Called when a window close is cancelled by beforeunload handler. 21 | virtual void OnWindowCloseCancelled(NativeWindow* window) {} 22 | 23 | // Called immediately after all windows are closed. 24 | virtual void OnWindowAllClosed() {} 25 | 26 | protected: 27 | virtual ~WindowListObserver() {} 28 | }; 29 | 30 | } // namespace atom 31 | 32 | #endif // ATOM_BROWSER_WINDOW_LIST_OBSERVER_H_ 33 | -------------------------------------------------------------------------------- /atom/browser/resources/mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | ${PRODUCT_NAME} 7 | CFBundleExecutable 8 | ${PRODUCT_NAME} 9 | CFBundleIdentifier 10 | com.github.atom 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleIconFile 18 | atom.icns 19 | CFBundleVersion 20 | 0.18.2 21 | LSMinimumSystemVersion 22 | 10.8.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | AtomApplication 27 | NSSupportsAutomaticGraphicsSwitching 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /atom/common/node_includes.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NODE_INCLUDES_H_ 6 | #define ATOM_COMMON_NODE_INCLUDES_H_ 7 | 8 | // Include common headers for using node APIs. 9 | 10 | #undef CHECK 11 | #undef CHECK_EQ 12 | #undef CHECK_NE 13 | #undef CHECK_GE 14 | #undef CHECK_GT 15 | #undef CHECK_LE 16 | #undef CHECK_LT 17 | #undef DISALLOW_COPY_AND_ASSIGN 18 | #undef debug_string // This is defined in OS X 10.9 SDK in AssertMacros.h. 19 | #include "vendor/node/src/env.h" 20 | #include "vendor/node/src/env-inl.h" 21 | #include "vendor/node/src/node.h" 22 | #include "vendor/node/src/node_buffer.h" 23 | #include "vendor/node/src/node_internals.h" 24 | 25 | namespace atom { 26 | // Defined in node_bindings.cc. 27 | // For renderer it's created in atom_renderer_client.cc. 28 | // For browser it's created in atom_browser_main_parts.cc. 29 | extern node::Environment* global_env; 30 | } 31 | 32 | #endif // ATOM_COMMON_NODE_INCLUDES_H_ 33 | -------------------------------------------------------------------------------- /chromium_src/chrome/common/tts_utterance_request.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef CHROME_COMMON_TTS_UTTERANCE_REQUEST_H_ 6 | #define CHROME_COMMON_TTS_UTTERANCE_REQUEST_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | #include "base/strings/string16.h" 12 | 13 | struct TtsUtteranceRequest { 14 | TtsUtteranceRequest(); 15 | ~TtsUtteranceRequest(); 16 | 17 | int id; 18 | std::string text; 19 | std::string lang; 20 | std::string voice; 21 | float volume; 22 | float rate; 23 | float pitch; 24 | }; 25 | 26 | struct TtsVoice { 27 | TtsVoice(); 28 | ~TtsVoice(); 29 | 30 | std::string voice_uri; 31 | std::string name; 32 | std::string lang; 33 | bool local_service; 34 | bool is_default; 35 | }; 36 | 37 | struct TtsUtteranceResponse { 38 | TtsUtteranceResponse(); 39 | ~TtsUtteranceResponse(); 40 | 41 | int id; 42 | }; 43 | 44 | #endif // CHROME_COMMON_TTS_UTTERANCE_REQUEST_H_ -------------------------------------------------------------------------------- /chromium_src/chrome/browser/printing/printing_ui_web_contents_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_ 6 | #define CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_ 7 | 8 | #include "base/basictypes.h" 9 | #include "content/public/browser/web_contents_observer.h" 10 | #include "ui/gfx/native_widget_types.h" 11 | 12 | // Wrapper used to keep track of the lifetime of a WebContents. 13 | // Lives on the UI thread. 14 | class PrintingUIWebContentsObserver : public content::WebContentsObserver { 15 | public: 16 | explicit PrintingUIWebContentsObserver(content::WebContents* web_contents); 17 | 18 | // Return the parent NativeView of the observed WebContents. 19 | gfx::NativeView GetParentView(); 20 | 21 | private: 22 | DISALLOW_COPY_AND_ASSIGN(PrintingUIWebContentsObserver); 23 | }; 24 | 25 | #endif // CHROME_BROWSER_PRINTING_PRINTING_UI_WEB_CONTENTS_OBSERVER_H_ 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 GitHub Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /atom/browser/javascript_environment.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ 6 | #define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ 7 | 8 | #include "base/basictypes.h" 9 | #include "gin/public/isolate_holder.h" 10 | 11 | namespace atom { 12 | 13 | class JavascriptEnvironment { 14 | public: 15 | JavascriptEnvironment(); 16 | 17 | v8::Isolate* isolate() const { return isolate_; } 18 | v8::Local context() const { 19 | return v8::Local::New(isolate_, context_); 20 | } 21 | 22 | private: 23 | gin::IsolateHolder isolate_holder_; 24 | v8::Isolate* isolate_; 25 | v8::Isolate::Scope isolate_scope_; 26 | v8::Locker locker_; 27 | v8::HandleScope handle_scope_; 28 | v8::UniquePersistent context_; 29 | v8::Context::Scope context_scope_; 30 | 31 | DISALLOW_COPY_AND_ASSIGN(JavascriptEnvironment); 32 | }; 33 | 34 | } // namespace atom 35 | 36 | #endif // ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ 37 | -------------------------------------------------------------------------------- /atom/common/platform_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_PLATFORM_UTIL_H_ 6 | #define ATOM_COMMON_PLATFORM_UTIL_H_ 7 | 8 | class GURL; 9 | 10 | namespace base { 11 | class FilePath; 12 | } 13 | 14 | namespace platform_util { 15 | 16 | // Show the given file in a file manager. If possible, select the file. 17 | // Must be called from the UI thread. 18 | void ShowItemInFolder(const base::FilePath& full_path); 19 | 20 | // Open the given file in the desktop's default manner. 21 | // Must be called from the UI thread. 22 | void OpenItem(const base::FilePath& full_path); 23 | 24 | // Open the given external protocol URL in the desktop's default manner. 25 | // (For example, mailto: URLs in the default mail user agent.) 26 | void OpenExternal(const GURL& url); 27 | 28 | // Move a file to trash. 29 | void MoveItemToTrash(const base::FilePath& full_path); 30 | 31 | void Beep(); 32 | 33 | } // namespace platform_util 34 | 35 | #endif // ATOM_COMMON_PLATFORM_UTIL_H_ 36 | -------------------------------------------------------------------------------- /atom/browser/api/lib/app.coffee: -------------------------------------------------------------------------------- 1 | EventEmitter = require('events').EventEmitter 2 | 3 | bindings = process.atomBinding 'app' 4 | 5 | app = bindings.app 6 | app.__proto__ = EventEmitter.prototype 7 | 8 | app.getHomeDir = -> 9 | process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME'] 10 | 11 | app.setApplicationMenu = (menu) -> 12 | require('menu').setApplicationMenu menu 13 | 14 | app.getApplicationMenu = -> 15 | require('menu').getApplicationMenu() 16 | 17 | app.commandLine = 18 | appendSwitch: bindings.appendSwitch, 19 | appendArgument: bindings.appendArgument 20 | 21 | if process.platform is 'darwin' 22 | app.dock = 23 | bounce: (type='informational') -> bindings.dockBounce type 24 | cancelBounce: bindings.dockCancelBounce 25 | setBadge: bindings.dockSetBadgeText 26 | getBadge: bindings.dockGetBadgeText 27 | hide: bindings.dockHide 28 | show: bindings.dockShow 29 | 30 | # Be compatible with old API. 31 | app.once 'ready', -> app.emit 'finish-launching' 32 | app.terminate = app.quit 33 | app.exit = process.exit 34 | 35 | # Only one App object pemitted. 36 | module.exports = app 37 | -------------------------------------------------------------------------------- /script/compile-coffee.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | 8 | SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) 9 | WINDOWS_NODE_PATHs = [ 10 | 'C:/Program Files/nodejs/node.exe', 11 | 'C:/Program Files (x86)/nodejs/node.exe', 12 | ] 13 | 14 | 15 | def main(): 16 | input_file = sys.argv[1] 17 | output_dir = os.path.dirname(sys.argv[2]) 18 | 19 | coffee = os.path.join(SOURCE_ROOT, 'node_modules', 'coffee-script', 'bin', 20 | 'coffee') 21 | if sys.platform in ['win32', 'cygwin']: 22 | node = find_node() 23 | if not node: 24 | print 'Node.js is required for building atom-shell' 25 | return 1 26 | subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file], 27 | executable=node) 28 | else: 29 | subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file]) 30 | 31 | 32 | def find_node(): 33 | for path in WINDOWS_NODE_PATHs: 34 | if os.path.exists(path): 35 | return path 36 | return None 37 | 38 | 39 | if __name__ == '__main__': 40 | sys.exit(main()) 41 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/gurl_converter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_ 6 | #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_ 7 | 8 | #include 9 | 10 | #include "native_mate/converter.h" 11 | #include "url/gurl.h" 12 | 13 | namespace mate { 14 | 15 | template<> 16 | struct Converter { 17 | static v8::Handle ToV8(v8::Isolate* isolate, 18 | const GURL& val) { 19 | return ConvertToV8(isolate, val.spec()); 20 | } 21 | static bool FromV8(v8::Isolate* isolate, 22 | v8::Handle val, 23 | GURL* out) { 24 | std::string url; 25 | if (Converter::FromV8(isolate, val, &url)) { 26 | *out = GURL(url); 27 | return true; 28 | } else { 29 | return false; 30 | } 31 | } 32 | }; 33 | 34 | } // namespace mate 35 | 36 | #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_GURL_CONVERTER_H_ 37 | -------------------------------------------------------------------------------- /atom/browser/api/atom_api_menu_views.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/api/atom_api_menu_views.h" 6 | 7 | #include "atom/browser/native_window_views.h" 8 | #include "ui/gfx/screen.h" 9 | #include "ui/views/controls/menu/menu_runner.h" 10 | 11 | namespace atom { 12 | 13 | namespace api { 14 | 15 | MenuViews::MenuViews() { 16 | } 17 | 18 | void MenuViews::Popup(Window* window) { 19 | gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); 20 | views::MenuRunner menu_runner( 21 | model(), 22 | views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS); 23 | ignore_result(menu_runner.RunMenuAt( 24 | static_cast(window->window())->widget(), 25 | NULL, 26 | gfx::Rect(cursor, gfx::Size()), 27 | views::MENU_ANCHOR_TOPLEFT, 28 | ui::MENU_SOURCE_MOUSE)); 29 | } 30 | 31 | // static 32 | mate::Wrappable* Menu::Create() { 33 | return new MenuViews(); 34 | } 35 | 36 | } // namespace api 37 | 38 | } // namespace atom 39 | -------------------------------------------------------------------------------- /atom/common/api/atom_api_shell.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | #include "atom/common/platform_util.h" 8 | #include "atom/common/native_mate_converters/file_path_converter.h" 9 | #include "atom/common/native_mate_converters/gurl_converter.h" 10 | #include "native_mate/dictionary.h" 11 | 12 | #include "atom/common/node_includes.h" 13 | 14 | namespace { 15 | 16 | void Initialize(v8::Handle exports, v8::Handle unused, 17 | v8::Handle context, void* priv) { 18 | mate::Dictionary dict(context->GetIsolate(), exports); 19 | dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder); 20 | dict.SetMethod("openItem", &platform_util::OpenItem); 21 | dict.SetMethod("openExternal", &platform_util::OpenExternal); 22 | dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash); 23 | dict.SetMethod("beep", &platform_util::Beep); 24 | } 25 | 26 | } // namespace 27 | 28 | NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_shell, Initialize) 29 | -------------------------------------------------------------------------------- /atom/browser/ui/views/win_frame_view.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_VIEWS_WIN_FRAME_VIEW_H_ 6 | #define ATOM_BROWSER_UI_VIEWS_WIN_FRAME_VIEW_H_ 7 | 8 | #include "atom/browser/ui/views/frameless_view.h" 9 | 10 | namespace atom { 11 | 12 | class WinFrameView : public FramelessView { 13 | public: 14 | WinFrameView(); 15 | virtual ~WinFrameView(); 16 | 17 | // views::NonClientFrameView: 18 | virtual gfx::Rect GetWindowBoundsForClientBounds( 19 | const gfx::Rect& client_bounds) const OVERRIDE; 20 | virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 21 | 22 | // views::View: 23 | virtual gfx::Size GetMinimumSize() const OVERRIDE; 24 | virtual gfx::Size GetMaximumSize() const OVERRIDE; 25 | virtual const char* GetClassName() const OVERRIDE; 26 | 27 | private: 28 | void ClientAreaSizeToWindowSize(gfx::Size* size) const; 29 | 30 | DISALLOW_COPY_AND_ASSIGN(WinFrameView); 31 | }; 32 | 33 | } // namespace atom 34 | 35 | #endif // ATOM_BROWSER_UI_VIEWS_WIN_FRAME_VIEW_H_ 36 | -------------------------------------------------------------------------------- /atom/common/common_message_generator.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // Get basic type definitions. 6 | #define IPC_MESSAGE_IMPL 7 | #include "atom/common/common_message_generator.h" 8 | 9 | // Generate constructors. 10 | #include "ipc/struct_constructor_macros.h" 11 | #include "atom/common/common_message_generator.h" 12 | 13 | // Generate destructors. 14 | #include "ipc/struct_destructor_macros.h" 15 | #include "atom/common/common_message_generator.h" 16 | 17 | // Generate param traits write methods. 18 | #include "ipc/param_traits_write_macros.h" 19 | namespace IPC { 20 | #include "atom/common/common_message_generator.h" 21 | } // namespace IPC 22 | 23 | // Generate param traits read methods. 24 | #include "ipc/param_traits_read_macros.h" 25 | namespace IPC { 26 | #include "atom/common/common_message_generator.h" 27 | } // namespace IPC 28 | 29 | // Generate param traits log methods. 30 | #include "ipc/param_traits_log_macros.h" 31 | namespace IPC { 32 | #include "atom/common/common_message_generator.h" 33 | } // namespace IPC 34 | 35 | -------------------------------------------------------------------------------- /docs/development/coding-style.md: -------------------------------------------------------------------------------- 1 | # Coding style 2 | 3 | ## C++ and Python 4 | 5 | For C++ and Python, we just follow Chromium's [Coding 6 | Style](http://www.chromium.org/developers/coding-style), there is also a 7 | script `script/cpplint.py` to check whether all files confirm. 8 | 9 | The python's version we are using now is Python 2.7. 10 | 11 | ## CoffeeScript 12 | 13 | For CoffeeScript, we follow GitHub's [Style 14 | Guide](https://github.com/styleguide/javascript), and also following rules: 15 | 16 | * Files should **NOT** end with new line, because we want to match Google's 17 | styles. 18 | * File names should be concatenated with `-` instead of `_`, e.g. 19 | `file-name.coffee` rather than `file_name.coffee`, because in 20 | [github/atom](https://github.com/github/atom) module names are usually in 21 | the `module-name` form, this rule only apply to `.coffee` files. 22 | 23 | ## API Names 24 | 25 | When creating a new API, we should prefer getters and setters instead of 26 | jQuery's one-function style, for example, `.getText()` and `.setText(text)` 27 | are preferred to `.text([text])`. There is a 28 | [discussion](https://github.com/atom/atom-shell/issues/46) of this. 29 | -------------------------------------------------------------------------------- /docs/api/accelerator.md: -------------------------------------------------------------------------------- 1 | # Accelerator 2 | 3 | An accelerator is string that represents a keyboard shortcut, it can contain 4 | multiple modifiers and key codes, combined by the `+` character. 5 | 6 | Examples: 7 | 8 | * `Command+A` 9 | * `Ctrl+Shift+Z` 10 | 11 | ## Platform notice 12 | 13 | On Linux and Windows, the `Command` key would not have any effect, you can 14 | use `CommandOrControl` which represents `Command` on OS X and `Control` on 15 | Linux and Windows to define some accelerators. 16 | 17 | ## Available modifiers 18 | 19 | * `Command` (or `Cmd` for short) 20 | * `Control` (or `Ctrl` for short) 21 | * `CommandOrControl` (or `CmdOrCtrl` for short) 22 | * `Alt` 23 | * `Shift` 24 | 25 | ## Available key codes 26 | 27 | * `0` to `9` 28 | * `A` to `Z` 29 | * `F1` to `F24` 30 | * Punctuations like `~`, `!`, `@`, `#`, `$`, etc. 31 | * `Space` 32 | * `Backspace` 33 | * `Delete` 34 | * `Insert` 35 | * `Return` (or `Enter` as alias) 36 | * `Up`, `Down`, `Left` and `Right` 37 | * `Home` and `End` 38 | * `PageUp` and `PageDown` 39 | * `Escape` (or `Esc` for short) 40 | * `VolumeUp`, `VolumeDown` and `VolumeMute` 41 | * `MediaNextTrack`, `MediaPreviousTrack`, `MediaStop` and `MediaPlayPause` 42 | -------------------------------------------------------------------------------- /atom/browser/ui/x/x_window_utils.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/x/x_window_utils.h" 6 | 7 | #include "ui/base/x/x11_util.h" 8 | 9 | namespace atom { 10 | 11 | ::Atom GetAtom(const char* name) { 12 | return XInternAtom(gfx::GetXDisplay(), name, false); 13 | } 14 | 15 | void SetWMSpecState(::Window xwindow, bool enabled, ::Atom state) { 16 | XEvent xclient; 17 | memset(&xclient, 0, sizeof(xclient)); 18 | xclient.type = ClientMessage; 19 | xclient.xclient.window = xwindow; 20 | xclient.xclient.message_type = GetAtom("_NET_WM_STATE"); 21 | xclient.xclient.format = 32; 22 | xclient.xclient.data.l[0] = enabled ? 1 : 0; 23 | xclient.xclient.data.l[1] = state; 24 | xclient.xclient.data.l[2] = None; 25 | xclient.xclient.data.l[3] = 1; 26 | xclient.xclient.data.l[4] = 0; 27 | 28 | XDisplay* xdisplay = gfx::GetXDisplay(); 29 | XSendEvent(xdisplay, DefaultRootWindow(xdisplay), False, 30 | SubstructureRedirectMask | SubstructureNotifyMask, 31 | &xclient); 32 | } 33 | 34 | } // namespace atom 35 | -------------------------------------------------------------------------------- /atom/common/api/atom_bindings.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_API_ATOM_BINDINGS_H_ 6 | #define ATOM_COMMON_API_ATOM_BINDINGS_H_ 7 | 8 | #include 9 | 10 | #include "base/strings/string16.h" 11 | #include "v8/include/v8.h" 12 | #include "vendor/node/deps/uv/include/uv.h" 13 | 14 | namespace node { 15 | class Environment; 16 | } 17 | 18 | namespace atom { 19 | 20 | class AtomBindings { 21 | public: 22 | AtomBindings(); 23 | virtual ~AtomBindings(); 24 | 25 | // Add process.atomBinding function, which behaves like process.binding but 26 | // load native code from atom-shell instead. 27 | virtual void BindTo(v8::Isolate* isolate, v8::Handle process); 28 | 29 | private: 30 | void ActivateUVLoop(v8::Isolate* isolate); 31 | 32 | static void OnCallNextTick(uv_async_t* handle); 33 | 34 | uv_async_t call_next_tick_async_; 35 | std::list pending_next_ticks_; 36 | 37 | DISALLOW_COPY_AND_ASSIGN(AtomBindings); 38 | }; 39 | 40 | } // namespace atom 41 | 42 | #endif // ATOM_COMMON_API_ATOM_BINDINGS_H_ 43 | -------------------------------------------------------------------------------- /atom/browser/api/atom_api_power_monitor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_ 6 | #define ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_ 7 | 8 | #include "atom/browser/api/event_emitter.h" 9 | #include "base/compiler_specific.h" 10 | #include "base/power_monitor/power_observer.h" 11 | #include "native_mate/handle.h" 12 | 13 | namespace atom { 14 | 15 | namespace api { 16 | 17 | class PowerMonitor : public mate::EventEmitter, 18 | public base::PowerObserver { 19 | public: 20 | static mate::Handle Create(v8::Isolate* isolate); 21 | 22 | protected: 23 | PowerMonitor(); 24 | virtual ~PowerMonitor(); 25 | 26 | // base::PowerObserver implementations: 27 | virtual void OnPowerStateChange(bool on_battery_power) OVERRIDE; 28 | virtual void OnSuspend() OVERRIDE; 29 | virtual void OnResume() OVERRIDE; 30 | 31 | private: 32 | DISALLOW_COPY_AND_ASSIGN(PowerMonitor); 33 | }; 34 | 35 | } // namespace api 36 | 37 | } // namespace atom 38 | 39 | #endif // ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_ 40 | -------------------------------------------------------------------------------- /atom/browser/net/url_request_string_job.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/net/url_request_string_job.h" 6 | 7 | #include 8 | 9 | #include "net/base/net_errors.h" 10 | 11 | namespace atom { 12 | 13 | URLRequestStringJob::URLRequestStringJob(net::URLRequest* request, 14 | net::NetworkDelegate* network_delegate, 15 | const std::string& mime_type, 16 | const std::string& charset, 17 | const std::string& data) 18 | : net::URLRequestSimpleJob(request, network_delegate), 19 | mime_type_(mime_type), 20 | charset_(charset), 21 | data_(data) { 22 | } 23 | 24 | int URLRequestStringJob::GetData( 25 | std::string* mime_type, 26 | std::string* charset, 27 | std::string* data, 28 | const net::CompletionCallback& callback) const { 29 | *mime_type = mime_type_; 30 | *charset = charset_; 31 | *data = data_; 32 | return net::OK; 33 | } 34 | 35 | } // namespace atom 36 | -------------------------------------------------------------------------------- /atom/browser/ui/cocoa/event_processing_window.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_ 6 | #define ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_ 7 | 8 | #import 9 | 10 | // Override NSWindow to access unhandled keyboard events (for command 11 | // processing); subclassing NSWindow is the only method to do 12 | // this. 13 | @interface EventProcessingWindow : NSWindow { 14 | @private 15 | BOOL redispatchingEvent_; 16 | BOOL eventHandled_; 17 | } 18 | 19 | // Sends a key event to |NSApp sendEvent:|, but also makes sure that it's not 20 | // short-circuited to the RWHV. This is used to send keyboard events to the menu 21 | // and the cmd-` handler if a keyboard event comes back unhandled from the 22 | // renderer. The event must be of type |NSKeyDown|, |NSKeyUp|, or 23 | // |NSFlagsChanged|. 24 | // Returns |YES| if |event| has been handled. 25 | - (BOOL)redispatchKeyEvent:(NSEvent*)event; 26 | 27 | - (BOOL)performKeyEquivalent:(NSEvent*)theEvent; 28 | @end 29 | 30 | #endif // ATOM_BROWSER_UI_COCOA_EVENT_PROCESSING_WINDOW_H_ 31 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/string16_converter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_ 6 | #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_ 7 | 8 | #include "base/strings/string16.h" 9 | #include "native_mate/converter.h" 10 | 11 | namespace mate { 12 | 13 | template<> 14 | struct Converter { 15 | static v8::Handle ToV8(v8::Isolate* isolate, 16 | const base::string16& val) { 17 | return MATE_STRING_NEW_FROM_UTF16( 18 | isolate, reinterpret_cast(val.data()), val.size()); 19 | } 20 | static bool FromV8(v8::Isolate* isolate, 21 | v8::Handle val, 22 | base::string16* out) { 23 | if (!val->IsString()) 24 | return false; 25 | 26 | v8::String::Value s(val); 27 | out->assign(reinterpret_cast(*s), s.length()); 28 | return true; 29 | } 30 | }; 31 | 32 | } // namespace mate 33 | 34 | #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_STRING16_CONVERTER_H_ 35 | -------------------------------------------------------------------------------- /atom/renderer/api/atom_renderer_bindings.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_RENDERER_API_ATOM_RENDERER_BINDINGS_H_ 6 | #define ATOM_RENDERER_API_ATOM_RENDERER_BINDINGS_H_ 7 | 8 | #include "atom/common/api/atom_bindings.h" 9 | 10 | #include "base/strings/string16.h" 11 | 12 | namespace base { 13 | class ListValue; 14 | } 15 | 16 | namespace content { 17 | class RenderView; 18 | } 19 | 20 | namespace blink { 21 | class WebFrame; 22 | } 23 | 24 | namespace atom { 25 | 26 | class AtomRendererBindings : public AtomBindings { 27 | public: 28 | AtomRendererBindings(); 29 | virtual ~AtomRendererBindings(); 30 | 31 | // Call BindTo for process object of the frame. 32 | void BindToFrame(blink::WebFrame* frame); 33 | 34 | // Dispatch messages from browser. 35 | void OnBrowserMessage(content::RenderView* render_view, 36 | const base::string16& channel, 37 | const base::ListValue& args); 38 | 39 | private: 40 | DISALLOW_COPY_AND_ASSIGN(AtomRendererBindings); 41 | }; 42 | 43 | } // namespace atom 44 | 45 | #endif // ATOM_RENDERER_API_ATOM_RENDERER_BINDINGS_H_ 46 | -------------------------------------------------------------------------------- /atom/common/api/lib/crash-reporter.coffee: -------------------------------------------------------------------------------- 1 | {spawn} = require 'child_process' 2 | binding = process.atomBinding 'crash_reporter' 3 | 4 | class CrashReporter 5 | start: (options={}) -> 6 | {productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra} = options 7 | 8 | productName ?= 'Atom-Shell' 9 | companyName ?= 'GitHub, Inc' 10 | submitUrl ?= 'http://54.249.141.255:1127/post' 11 | autoSubmit ?= true 12 | ignoreSystemCrashHandler ?= false 13 | extra ?= {} 14 | 15 | extra._productName ?= productName 16 | extra._companyName ?= companyName 17 | extra._version ?= 18 | if process.type is 'browser' 19 | require('app').getVersion() 20 | else 21 | require('remote').require('app').getVersion() 22 | 23 | start = -> binding.start productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra 24 | 25 | if process.platform is 'win32' 26 | args = [ 27 | "--reporter-url=#{submitUrl}" 28 | "--application-name=#{productName}" 29 | "--v=1" 30 | ] 31 | env = ATOM_SHELL_INTERNAL_CRASH_SERVICE: 1 32 | 33 | spawn process.execPath, args, {env, detached: true} 34 | start() 35 | else 36 | start() 37 | 38 | module.exports = new CrashReporter 39 | -------------------------------------------------------------------------------- /atom/common/asar/scoped_temporary_file.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ 6 | #define ATOM_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ 7 | 8 | #include "base/files/file_path.h" 9 | 10 | namespace asar { 11 | 12 | // An object representing a temporary file that should be cleaned up when this 13 | // object goes out of scope. Note that since deletion occurs during the 14 | // destructor, no further error handling is possible if the directory fails to 15 | // be deleted. As a result, deletion is not guaranteed by this class. 16 | class ScopedTemporaryFile { 17 | public: 18 | ScopedTemporaryFile(); 19 | virtual ~ScopedTemporaryFile(); 20 | 21 | // Init an empty temporary file. 22 | bool Init(); 23 | 24 | // Init an temporary file and fill it with content of |path|. 25 | bool InitFromFile(const base::FilePath& path, uint64 offset, uint64 size); 26 | 27 | base::FilePath path() const { return path_; } 28 | 29 | private: 30 | base::FilePath path_; 31 | 32 | DISALLOW_COPY_AND_ASSIGN(ScopedTemporaryFile); 33 | }; 34 | 35 | } // namespace asar 36 | 37 | #endif // ATOM_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ 38 | -------------------------------------------------------------------------------- /atom/browser/atom_javascript_dialog_manager.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/atom_javascript_dialog_manager.h" 6 | 7 | #include 8 | 9 | #include "base/strings/utf_string_conversions.h" 10 | 11 | namespace atom { 12 | 13 | void AtomJavaScriptDialogManager::RunJavaScriptDialog( 14 | content::WebContents* web_contents, 15 | const GURL& origin_url, 16 | const std::string& accept_lang, 17 | content::JavaScriptMessageType javascript_message_type, 18 | const base::string16& message_text, 19 | const base::string16& default_prompt_text, 20 | const DialogClosedCallback& callback, 21 | bool* did_suppress_message) { 22 | callback.Run(false, base::string16()); 23 | } 24 | 25 | void AtomJavaScriptDialogManager::RunBeforeUnloadDialog( 26 | content::WebContents* web_contents, 27 | const base::string16& message_text, 28 | bool is_reload, 29 | const DialogClosedCallback& callback) { 30 | 31 | bool prevent_reload = message_text.empty() || 32 | message_text == base::ASCIIToUTF16("false"); 33 | callback.Run(!prevent_reload, message_text); 34 | } 35 | 36 | } // namespace atom 37 | -------------------------------------------------------------------------------- /script/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | import os 5 | import subprocess 6 | import sys 7 | 8 | 9 | CONFIGURATIONS = ['Release', 'Debug'] 10 | SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 11 | 12 | 13 | def main(): 14 | os.chdir(SOURCE_ROOT) 15 | 16 | ninja = os.path.join('vendor', 'depot_tools', 'ninja') 17 | if sys.platform == 'win32': 18 | ninja += '.exe' 19 | 20 | args = parse_args() 21 | for config in args.configuration: 22 | build_path = os.path.join('out', config) 23 | ret = subprocess.call([ninja, '-C', build_path, args.target]) 24 | if ret != 0: 25 | sys.exit(ret) 26 | 27 | 28 | def parse_args(): 29 | parser = argparse.ArgumentParser(description='Build atom-shell') 30 | parser.add_argument('-c', '--configuration', 31 | help='Build with Release or Debug configuration', 32 | nargs='+', 33 | default=CONFIGURATIONS, 34 | required=False) 35 | parser.add_argument('-t', '--target', 36 | help='Build specified target', 37 | default='atom', 38 | required=False) 39 | return parser.parse_args() 40 | 41 | 42 | if __name__ == '__main__': 43 | sys.exit(main()) 44 | -------------------------------------------------------------------------------- /atom/browser/native_window_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_NATIVE_WINDOW_OBSERVER_H_ 6 | #define ATOM_BROWSER_NATIVE_WINDOW_OBSERVER_H_ 7 | 8 | #include 9 | 10 | namespace atom { 11 | 12 | class NativeWindowObserver { 13 | public: 14 | virtual ~NativeWindowObserver() {} 15 | 16 | // Called when the web page of the window has updated it's document title. 17 | virtual void OnPageTitleUpdated(bool* prevent_default, 18 | const std::string& title) {} 19 | 20 | // Called when the window is gonna closed. 21 | virtual void WillCloseWindow(bool* prevent_default) {} 22 | 23 | // Called when the window is closed. 24 | virtual void OnWindowClosed() {} 25 | 26 | // Called when window loses focus. 27 | virtual void OnWindowBlur() {} 28 | 29 | // Called when window gains focus. 30 | virtual void OnWindowFocus() {} 31 | 32 | // Called when renderer is hung. 33 | virtual void OnRendererUnresponsive() {} 34 | 35 | // Called when renderer recovers. 36 | virtual void OnRendererResponsive() {} 37 | }; 38 | 39 | } // namespace atom 40 | 41 | #endif // ATOM_BROWSER_NATIVE_WINDOW_OBSERVER_H_ 42 | -------------------------------------------------------------------------------- /atom/browser/net/url_request_string_job.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_NET_URL_REQUEST_STRING_JOB_H_ 6 | #define ATOM_BROWSER_NET_URL_REQUEST_STRING_JOB_H_ 7 | 8 | #include "net/url_request/url_request_simple_job.h" 9 | 10 | #include 11 | 12 | namespace atom { 13 | 14 | class URLRequestStringJob : public net::URLRequestSimpleJob { 15 | public: 16 | URLRequestStringJob(net::URLRequest* request, 17 | net::NetworkDelegate* network_delegate, 18 | const std::string& mime_type, 19 | const std::string& charset, 20 | const std::string& data); 21 | 22 | // URLRequestSimpleJob: 23 | virtual int GetData(std::string* mime_type, 24 | std::string* charset, 25 | std::string* data, 26 | const net::CompletionCallback& callback) const OVERRIDE; 27 | 28 | private: 29 | std::string mime_type_; 30 | std::string charset_; 31 | std::string data_; 32 | 33 | DISALLOW_COPY_AND_ASSIGN(URLRequestStringJob); 34 | }; 35 | 36 | } // namespace atom 37 | 38 | #endif // ATOM_BROWSER_NET_URL_REQUEST_STRING_JOB_H_ 39 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/file_path_converter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_ 6 | #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_ 7 | 8 | #include 9 | 10 | #include "atom/common/native_mate_converters/string16_converter.h" 11 | #include "base/files/file_path.h" 12 | 13 | namespace mate { 14 | 15 | template<> 16 | struct Converter { 17 | static v8::Handle ToV8(v8::Isolate* isolate, 18 | const base::FilePath& val) { 19 | return Converter::ToV8(isolate, val.value()); 20 | } 21 | static bool FromV8(v8::Isolate* isolate, 22 | v8::Handle val, 23 | base::FilePath* out) { 24 | base::FilePath::StringType path; 25 | if (Converter::FromV8(isolate, val, &path)) { 26 | *out = base::FilePath(path); 27 | return true; 28 | } else { 29 | return false; 30 | } 31 | } 32 | }; 33 | 34 | } // namespace mate 35 | 36 | #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_FILE_PATH_CONVERTER_H_ 37 | -------------------------------------------------------------------------------- /atom/common/api/object_life_monitor.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Copyright (c) 2012 Intel Corp. All rights reserved. 3 | // Use of this source code is governed by the MIT license that can be 4 | // found in the LICENSE file. 5 | 6 | #include "atom/common/api/object_life_monitor.h" 7 | 8 | #include "native_mate/compat.h" 9 | 10 | namespace atom { 11 | 12 | // static 13 | void ObjectLifeMonitor::BindTo(v8::Isolate* isolate, 14 | v8::Handle target, 15 | v8::Handle destructor) { 16 | target->SetHiddenValue(MATE_STRING_NEW(isolate, "destructor"), destructor); 17 | 18 | ObjectLifeMonitor* olm = new ObjectLifeMonitor(); 19 | olm->handle_.reset(isolate, target); 20 | olm->handle_.SetWeak(olm, WeakCallback); 21 | } 22 | 23 | ObjectLifeMonitor::ObjectLifeMonitor() { 24 | } 25 | 26 | // static 27 | void ObjectLifeMonitor::WeakCallback( 28 | const v8::WeakCallbackData& data) { 29 | // destructor.call(object, object); 30 | v8::Local obj = data.GetValue(); 31 | v8::Local::Cast(obj->GetHiddenValue( 32 | MATE_STRING_NEW(data.GetIsolate(), "destructor")))->Call(obj, 0, NULL); 33 | delete data.GetParameter(); 34 | } 35 | 36 | } // namespace atom 37 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon_gtk.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_TRAY_ICON_GTK_H_ 6 | #define ATOM_BROWSER_UI_TRAY_ICON_GTK_H_ 7 | 8 | #include 9 | 10 | #include "atom/browser/ui/tray_icon.h" 11 | #include "ui/views/linux_ui/status_icon_linux.h" 12 | 13 | namespace views { 14 | class StatusIconLinux; 15 | } 16 | 17 | namespace atom { 18 | 19 | class TrayIconGtk : public TrayIcon, 20 | public views::StatusIconLinux::Delegate { 21 | public: 22 | TrayIconGtk(); 23 | virtual ~TrayIconGtk(); 24 | 25 | // TrayIcon: 26 | virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; 27 | virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; 28 | virtual void SetToolTip(const std::string& tool_tip) OVERRIDE; 29 | virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE; 30 | 31 | private: 32 | // views::StatusIconLinux::Delegate: 33 | virtual void OnClick() OVERRIDE; 34 | virtual bool HasClickAction() OVERRIDE; 35 | 36 | scoped_ptr icon_; 37 | 38 | DISALLOW_COPY_AND_ASSIGN(TrayIconGtk); 39 | }; 40 | 41 | } // namespace atom 42 | 43 | #endif // ATOM_BROWSER_UI_TRAY_ICON_GTK_H_ 44 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/browser_process.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // This interface is for managing the global services of the application. Each 6 | // service is lazily created when requested the first time. The service getters 7 | // will return NULL if the service is not available, so callers must check for 8 | // this condition. 9 | 10 | #ifndef CHROME_BROWSER_BROWSER_PROCESS_H_ 11 | #define CHROME_BROWSER_BROWSER_PROCESS_H_ 12 | 13 | #include 14 | 15 | #include "base/basictypes.h" 16 | #include "base/memory/scoped_ptr.h" 17 | 18 | namespace printing { 19 | class PrintJobManager; 20 | } 21 | 22 | // NOT THREAD SAFE, call only from the main thread. 23 | // These functions shouldn't return NULL unless otherwise noted. 24 | class BrowserProcess { 25 | public: 26 | BrowserProcess(); 27 | ~BrowserProcess(); 28 | 29 | std::string GetApplicationLocale(); 30 | 31 | printing::PrintJobManager* print_job_manager(); 32 | 33 | private: 34 | scoped_ptr print_job_manager_; 35 | 36 | DISALLOW_COPY_AND_ASSIGN(BrowserProcess); 37 | }; 38 | 39 | extern BrowserProcess* g_browser_process; 40 | 41 | #endif // CHROME_BROWSER_BROWSER_PROCESS_H_ 42 | -------------------------------------------------------------------------------- /spec/modules-spec.coffee: -------------------------------------------------------------------------------- 1 | assert = require 'assert' 2 | fs = require 'fs' 3 | path = require 'path' 4 | temp = require 'temp' 5 | 6 | describe 'third-party module', -> 7 | fixtures = path.join __dirname, 'fixtures' 8 | temp.track() 9 | 10 | describe 'runas', -> 11 | it 'can be required in renderer', -> 12 | require 'runas' 13 | 14 | it 'can be required in node binary', (done) -> 15 | runas = path.join fixtures, 'module', 'runas.js' 16 | child = require('child_process').fork runas 17 | child.on 'message', (msg) -> 18 | assert.equal msg, 'ok' 19 | done() 20 | 21 | describe 'pathwatcher', -> 22 | it 'emits file events correctly', (done) -> 23 | pathwatcher = require 'pathwatcher' 24 | temp.mkdir 'dir', (err, dir) -> 25 | return done() if err 26 | file = path.join dir, 'file' 27 | fs.writeFileSync file, 'content' 28 | watcher = pathwatcher.watch file, (event) -> 29 | assert.equal event, 'change' 30 | watcher.close() 31 | done() 32 | fs.writeFileSync file, 'content2' 33 | 34 | describe 'q', -> 35 | Q = require 'q' 36 | 37 | describe 'Q.when', -> 38 | it 'emits the fullfil callback', (done) -> 39 | Q(true).then (val) -> 40 | assert.equal val, true 41 | done() 42 | -------------------------------------------------------------------------------- /docs/development/build-instructions-mac.md: -------------------------------------------------------------------------------- 1 | # Build instructions (Mac) 2 | 3 | ## Prerequisites 4 | 5 | * Mac OS X >= 10.8 6 | * [Xcode](https://developer.apple.com/technologies/tools/) >= 5.1 7 | * [node.js](http://nodejs.org) (external). 8 | 9 | If you are using the python downloaded by Homebrew, you also need to install 10 | following python modules: 11 | 12 | * pyobjc 13 | 14 | ## Getting the code 15 | 16 | ```bash 17 | $ git clone https://github.com/atom/atom-shell.git 18 | ``` 19 | 20 | ## Bootstrapping 21 | 22 | The bootstrap script will download all necessary build dependencies and create 23 | build project files. Notice that we're using `ninja` to build `atom-shell` so 24 | there is no Xcode project generated. 25 | 26 | ```bash 27 | $ cd atom-shell 28 | $ ./script/bootstrap.py 29 | ``` 30 | 31 | ## Building 32 | 33 | Build both `Release` and `Debug` targets: 34 | 35 | ```bash 36 | $ ./script/build.py 37 | ``` 38 | 39 | You can also only build the `Debug` target: 40 | 41 | ```bash 42 | $ ./script/build.py -c Debug 43 | ``` 44 | 45 | After building is done, you can find `Atom.app` under `out/Debug`. 46 | 47 | ## 32bit support 48 | 49 | Currently atom-shell can only be built for 64bit target on OS X, and there is no 50 | plan to support 32bit on OS X in future. 51 | 52 | ## Tests 53 | 54 | ```bash 55 | $ ./script/test.py 56 | ``` 57 | -------------------------------------------------------------------------------- /atom/browser/ui/accelerator_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_ 6 | #define ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "ui/base/accelerators/accelerator.h" 12 | 13 | namespace ui { 14 | class MenuModel; 15 | } 16 | 17 | namespace accelerator_util { 18 | 19 | typedef struct { int position; ui::MenuModel* model; } MenuItem; 20 | typedef std::map AcceleratorTable; 21 | 22 | // Parse a string as an accelerator. 23 | bool StringToAccelerator(const std::string& description, 24 | ui::Accelerator* accelerator); 25 | 26 | // Set platform accelerator for the Accelerator. 27 | void SetPlatformAccelerator(ui::Accelerator* accelerator); 28 | 29 | // Generate a table that contains memu model's accelerators and command ids. 30 | void GenerateAcceleratorTable(AcceleratorTable* table, ui::MenuModel* model); 31 | 32 | // Trigger command from the accelerators table. 33 | bool TriggerAcceleratorTableCommand(AcceleratorTable* table, 34 | const ui::Accelerator& accelerator); 35 | 36 | } // namespace accelerator_util 37 | 38 | #endif // ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_ 39 | -------------------------------------------------------------------------------- /atom/app/atom_main_delegate_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/app/atom_main_delegate.h" 6 | 7 | #include "base/mac/bundle_locations.h" 8 | #include "base/files/file_path.h" 9 | #include "base/path_service.h" 10 | #include "brightray/common/mac/main_application_bundle.h" 11 | #include "content/public/common/content_paths.h" 12 | 13 | namespace atom { 14 | 15 | namespace { 16 | 17 | base::FilePath GetFrameworksPath() { 18 | return brightray::MainApplicationBundlePath().Append("Contents") 19 | .Append("Frameworks"); 20 | } 21 | 22 | } // namespace 23 | 24 | void AtomMainDelegate::OverrideFrameworkBundlePath() { 25 | base::mac::SetOverrideFrameworkBundlePath( 26 | GetFrameworksPath().Append("Atom Framework.framework")); 27 | } 28 | 29 | void AtomMainDelegate::OverrideChildProcessPath() { 30 | base::FilePath helper_path = GetFrameworksPath().Append("Atom Helper.app") 31 | .Append("Contents") 32 | .Append("MacOS") 33 | .Append("Atom Helper"); 34 | PathService::Override(content::CHILD_PROCESS_EXE, helper_path); 35 | } 36 | 37 | } // namespace atom 38 | -------------------------------------------------------------------------------- /atom/browser/ui/message_box.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_MESSAGE_BOX_H_ 6 | #define ATOM_BROWSER_UI_MESSAGE_BOX_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "base/callback_forward.h" 12 | 13 | namespace atom { 14 | 15 | class NativeWindow; 16 | 17 | enum MessageBoxType { 18 | MESSAGE_BOX_TYPE_NONE = 0, 19 | MESSAGE_BOX_TYPE_INFORMATION, 20 | MESSAGE_BOX_TYPE_WARNING 21 | }; 22 | 23 | typedef base::Callback MessageBoxCallback; 24 | 25 | int ShowMessageBox(NativeWindow* parent_window, 26 | MessageBoxType type, 27 | const std::vector& buttons, 28 | const std::string& title, 29 | const std::string& message, 30 | const std::string& detail); 31 | 32 | void ShowMessageBox(NativeWindow* parent_window, 33 | MessageBoxType type, 34 | const std::vector& buttons, 35 | const std::string& title, 36 | const std::string& message, 37 | const std::string& detail, 38 | const MessageBoxCallback& callback); 39 | 40 | } // namespace atom 41 | 42 | #endif // ATOM_BROWSER_UI_MESSAGE_BOX_H_ 43 | -------------------------------------------------------------------------------- /docs/api/clipboard.md: -------------------------------------------------------------------------------- 1 | # clipboard 2 | 3 | The `clipboard` provides methods to do copy/paste operations. An example of 4 | writing a string to clipboard: 5 | 6 | ```javascript 7 | var clipboard = require('clipboard'); 8 | clipboard.writeText('Example String'); 9 | ``` 10 | 11 | On X Window systems, there is also a selection clipboard, to manipulate in it 12 | you need to pass `selection` to each method: 13 | 14 | ```javascript 15 | var clipboard = require('clipboard'); 16 | clipboard.writeText('Example String', 'selection'); 17 | console.log(clipboard.readText('selection')); 18 | ``` 19 | 20 | ## clipboard.readText([type]) 21 | 22 | * `type` String 23 | 24 | Returns the content in clipboard as plain text. 25 | 26 | ## clipboard.writeText(text[, type]) 27 | 28 | * `text` String 29 | * `type` String 30 | 31 | Writes the `text` into clipboard as plain text. 32 | 33 | ## clipboard.clear([type]) 34 | 35 | * `type` String 36 | 37 | Clears everything in clipboard. 38 | 39 | ## clipboard.has(format[, type]) 40 | 41 | * `format` String 42 | * `type` String 43 | 44 | Returns whether clipboard has data in specified `format`. 45 | 46 | **Note:** This API is experimental and could be removed in future. 47 | 48 | ## clipboard.read(format[, type]) 49 | 50 | * `format` String 51 | * `type` String 52 | 53 | Reads the data in clipboard of the `format`. 54 | 55 | **Note:** This API is experimental and could be removed in future. 56 | -------------------------------------------------------------------------------- /atom/renderer/api/atom_api_web_frame.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_ 6 | #define ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_ 7 | 8 | #include 9 | 10 | #include "native_mate/handle.h" 11 | #include "native_mate/wrappable.h" 12 | 13 | namespace blink { 14 | class WebLocalFrame; 15 | } 16 | 17 | namespace atom { 18 | 19 | namespace api { 20 | 21 | class WebFrame : public mate::Wrappable { 22 | public: 23 | static mate::Handle Create(v8::Isolate* isolate); 24 | 25 | private: 26 | WebFrame(); 27 | virtual ~WebFrame(); 28 | 29 | void SetName(const std::string& name); 30 | 31 | double SetZoomLevel(double level); 32 | double GetZoomLevel() const; 33 | double SetZoomFactor(double factor); 34 | double GetZoomFactor() const; 35 | 36 | v8::Handle RegisterEmbedderCustomElement( 37 | const base::string16& name, v8::Handle options); 38 | 39 | // mate::Wrappable: 40 | virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder( 41 | v8::Isolate* isolate); 42 | 43 | blink::WebLocalFrame* web_frame_; 44 | 45 | DISALLOW_COPY_AND_ASSIGN(WebFrame); 46 | }; 47 | 48 | } // namespace api 49 | 50 | } // namespace atom 51 | 52 | #endif // ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_ 53 | -------------------------------------------------------------------------------- /tools/mac/make_locale_dirs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | # usage: make_locale_dirs.sh locale_dir [...] 8 | # 9 | # This script creates the Resources directory for the bundle being built by 10 | # the Xcode target that calls it if the directory does not yet exist. It then 11 | # changes to that directory and creates subdirectories for each locale_dir 12 | # passed on the command line. 13 | # 14 | # This script is intended to create empty locale directories (.lproj) in a 15 | # Cocoa .app bundle. The presence of these empty directories is sufficient to 16 | # convince Cocoa that the application supports the named localization, even if 17 | # an InfoPlist.strings file is not provided. Chrome uses these empty locale 18 | # directoires for its helper executable bundles, which do not otherwise 19 | # require any direct Cocoa locale support. 20 | 21 | set -eu 22 | 23 | if [[ ${#} -eq 0 ]]; then 24 | echo "usage: ${0} locale_dir [...]" >& 2 25 | exit 1 26 | fi 27 | 28 | RESOURCES_DIR="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 29 | if [[ ! -d "${RESOURCES_DIR}" ]]; then 30 | mkdir "${RESOURCES_DIR}" 31 | fi 32 | 33 | cd "${RESOURCES_DIR}" 34 | 35 | for dir in "${@}"; do 36 | if [[ ! -d "${dir}" ]]; then 37 | mkdir "${dir}" 38 | fi 39 | done 40 | -------------------------------------------------------------------------------- /atom/browser/auto_updater_delegate.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_AUTO_UPDATER_DELEGATE_H_ 6 | #define ATOM_BROWSER_AUTO_UPDATER_DELEGATE_H_ 7 | 8 | #include 9 | 10 | #include "base/callback_forward.h" 11 | 12 | namespace base { 13 | class Time; 14 | } 15 | 16 | namespace auto_updater { 17 | 18 | class AutoUpdaterDelegate { 19 | public: 20 | // An error happened. 21 | virtual void OnError(const std::string& error) {} 22 | 23 | // Checking to see if there is an update 24 | virtual void OnCheckingForUpdate() {} 25 | 26 | // There is an update available and it is being downloaded 27 | virtual void OnUpdateAvailable() {} 28 | 29 | // There is no available update. 30 | virtual void OnUpdateNotAvailable() {} 31 | 32 | // There is a new update which has been downloaded. 33 | virtual void OnUpdateDownloaded(const std::string& release_notes, 34 | const std::string& release_name, 35 | const base::Time& release_date, 36 | const std::string& update_url, 37 | const base::Closure& quit_and_install) {} 38 | 39 | protected: 40 | virtual ~AutoUpdaterDelegate() {} 41 | }; 42 | 43 | } // namespace auto_updater 44 | 45 | #endif // ATOM_BROWSER_AUTO_UPDATER_DELEGATE_H_ 46 | -------------------------------------------------------------------------------- /atom/browser/ui/accelerator_util_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/accelerator_util.h" 6 | 7 | #include "ui/base/accelerators/accelerator.h" 8 | #import "ui/base/accelerators/platform_accelerator_cocoa.h" 9 | #import "ui/events/keycodes/keyboard_code_conversion_mac.h" 10 | 11 | namespace accelerator_util { 12 | 13 | void SetPlatformAccelerator(ui::Accelerator* accelerator) { 14 | unichar character; 15 | unichar characterIgnoringModifiers; 16 | ui::MacKeyCodeForWindowsKeyCode(accelerator->key_code(), 17 | 0, 18 | &character, 19 | &characterIgnoringModifiers); 20 | NSString* characters = 21 | [[[NSString alloc] initWithCharacters:&character length:1] autorelease]; 22 | 23 | NSUInteger modifiers = 24 | (accelerator->IsCtrlDown() ? NSControlKeyMask : 0) | 25 | (accelerator->IsCmdDown() ? NSCommandKeyMask : 0) | 26 | (accelerator->IsAltDown() ? NSAlternateKeyMask : 0) | 27 | (accelerator->IsShiftDown() ? NSShiftKeyMask : 0); 28 | 29 | scoped_ptr platform_accelerator( 30 | new ui::PlatformAcceleratorCocoa(characters, modifiers)); 31 | accelerator->set_platform_accelerator(platform_accelerator.Pass()); 32 | } 33 | 34 | } // namespace accelerator_util 35 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon_cocoa.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_ 6 | #define ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_ 7 | 8 | #import 9 | 10 | #include 11 | 12 | #include "atom/browser/ui/tray_icon.h" 13 | #include "base/mac/scoped_nsobject.h" 14 | 15 | @class AtomMenuController; 16 | @class StatusItemController; 17 | 18 | namespace atom { 19 | 20 | class TrayIconCocoa : public TrayIcon { 21 | public: 22 | TrayIconCocoa(); 23 | virtual ~TrayIconCocoa(); 24 | 25 | virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; 26 | virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; 27 | virtual void SetToolTip(const std::string& tool_tip) OVERRIDE; 28 | virtual void SetTitle(const std::string& title) OVERRIDE; 29 | virtual void SetHighlightMode(bool highlight) OVERRIDE; 30 | virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE; 31 | 32 | private: 33 | base::scoped_nsobject item_; 34 | 35 | base::scoped_nsobject controller_; 36 | 37 | // Status menu shown when right-clicking the system icon. 38 | base::scoped_nsobject menu_; 39 | 40 | DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa); 41 | }; 42 | 43 | } // namespace atom 44 | 45 | #endif // ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_ 46 | -------------------------------------------------------------------------------- /atom/browser/web_view/web_view_renderer_state.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/web_view/web_view_renderer_state.h" 6 | 7 | #include "content/public/browser/browser_thread.h" 8 | 9 | namespace atom { 10 | 11 | // static 12 | WebViewRendererState* WebViewRendererState::GetInstance() { 13 | return Singleton::get(); 14 | } 15 | 16 | WebViewRendererState::WebViewRendererState() { 17 | } 18 | 19 | WebViewRendererState::~WebViewRendererState() { 20 | } 21 | 22 | bool WebViewRendererState::IsGuest(int render_process_id) { 23 | return webview_info_map_.find(render_process_id) != 24 | webview_info_map_.end(); 25 | } 26 | 27 | void WebViewRendererState::AddGuest(int guest_process_id, 28 | const WebViewInfo& webview_info) { 29 | webview_info_map_[guest_process_id] = webview_info; 30 | } 31 | 32 | void WebViewRendererState::RemoveGuest(int guest_process_id) { 33 | webview_info_map_.erase(guest_process_id); 34 | } 35 | 36 | bool WebViewRendererState::GetInfo(int guest_process_id, 37 | WebViewInfo* webview_info) { 38 | WebViewInfoMap::iterator iter = webview_info_map_.find(guest_process_id); 39 | if (iter != webview_info_map_.end()) { 40 | *webview_info = iter->second; 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | } // namespace atom 47 | -------------------------------------------------------------------------------- /atom/renderer/atom_render_view_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ 6 | #define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ 7 | 8 | #include "base/strings/string16.h" 9 | #include "content/public/renderer/render_view_observer.h" 10 | 11 | namespace base { 12 | class ListValue; 13 | } 14 | 15 | namespace atom { 16 | 17 | class AtomRendererClient; 18 | 19 | class AtomRenderViewObserver : public content::RenderViewObserver { 20 | public: 21 | explicit AtomRenderViewObserver(content::RenderView* render_view, 22 | AtomRendererClient* renderer_client); 23 | 24 | protected: 25 | virtual ~AtomRenderViewObserver(); 26 | 27 | private: 28 | // content::RenderViewObserver implementation. 29 | virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) OVERRIDE; 30 | virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE; 31 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 32 | 33 | void OnBrowserMessage(const base::string16& channel, 34 | const base::ListValue& args); 35 | 36 | // Weak reference to renderer client. 37 | AtomRendererClient* renderer_client_; 38 | 39 | DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver); 40 | }; 41 | 42 | } // namespace atom 43 | 44 | #endif // ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ 45 | -------------------------------------------------------------------------------- /atom/common/crash_reporter/crash_reporter_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_MAC_H_ 6 | #define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_MAC_H_ 7 | 8 | #include 9 | 10 | #include "atom/common/crash_reporter/crash_reporter.h" 11 | #include "base/compiler_specific.h" 12 | #import "vendor/breakpad/src/client/mac/Framework/Breakpad.h" 13 | 14 | template struct DefaultSingletonTraits; 15 | 16 | namespace crash_reporter { 17 | 18 | class CrashReporterMac : public CrashReporter { 19 | public: 20 | static CrashReporterMac* GetInstance(); 21 | 22 | virtual void InitBreakpad(const std::string& product_name, 23 | const std::string& version, 24 | const std::string& company_name, 25 | const std::string& submit_url, 26 | bool auto_submit, 27 | bool skip_system_crash_handler) OVERRIDE; 28 | virtual void SetUploadParameters() OVERRIDE; 29 | 30 | private: 31 | friend struct DefaultSingletonTraits; 32 | 33 | CrashReporterMac(); 34 | virtual ~CrashReporterMac(); 35 | 36 | BreakpadRef breakpad_; 37 | 38 | DISALLOW_COPY_AND_ASSIGN(CrashReporterMac); 39 | }; 40 | 41 | } // namespace crash_reporter 42 | 43 | #endif // ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_MAC_H_ 44 | -------------------------------------------------------------------------------- /docs/tutorial/debugging-browser-process.md: -------------------------------------------------------------------------------- 1 | # Debugging browser process 2 | 3 | The devtools of browser window can only debug the scripts of the web pages 4 | (e.g. the renderer process), in order to provide a way to debug the scripts of 5 | the browser side (e.g. the browser process), atom-shell has provided the 6 | `--debug` and `--debug-brk` switches. 7 | 8 | ## Command line switches 9 | 10 | ### `--debug=[port]` 11 | 12 | When this switch is used atom-shell would listen for V8 debugger protocol 13 | messages on `port`, the `port` is `5858` by default. 14 | 15 | ### `--debug-brk=[port]` 16 | 17 | Like `--debug` but pauses the script on the first line. 18 | 19 | ## Use node-inspector for debugging 20 | 21 | __Note:__ Atom Shell uses node v0.11.13, which currently doesn't work very well 22 | with node-inspector, and the browser process would crash if you inspect the 23 | `process` object under node-inspector's console. 24 | 25 | ### 1. Start the [node-inspector][node-inspector] server 26 | 27 | ```bash 28 | $ node-inspector 29 | ``` 30 | 31 | ### 2. Enable debug mode for atom-shell 32 | 33 | You can either start atom-shell with a debug flag like: 34 | 35 | ```bash 36 | $ atom-shell --debug=5858 your/app 37 | ``` 38 | 39 | or, to pause your script on the first line: 40 | 41 | ```bash 42 | $ atom-shell --debug-brk=5858 your/app 43 | ``` 44 | 45 | ### 3. Load the debugger UI 46 | 47 | Open http://127.0.0.1:8080/debug?port=5858 in the Chrome browser. 48 | 49 | [node-inspector]: https://github.com/node-inspector/node-inspector 50 | -------------------------------------------------------------------------------- /atom/renderer/lib/override.coffee: -------------------------------------------------------------------------------- 1 | process = global.process 2 | remote = require 'remote' 3 | 4 | unless process.guestInstanceId? 5 | # Override default window.close, see: 6 | window.close = -> 7 | remote.getCurrentWindow().close() 8 | 9 | # Override default window.open. 10 | window.open = (url, name, features) -> 11 | options = {} 12 | for feature in features.split ',' 13 | [name, value] = feature.split '=' 14 | options[name] = 15 | if value is 'yes' 16 | true 17 | else if value is 'no' 18 | false 19 | else 20 | value 21 | 22 | options.x ?= options.left 23 | options.y ?= options.top 24 | options.title ?= name 25 | options.width ?= 800 26 | options.height ?= 600 27 | 28 | BrowserWindow = require('remote').require 'browser-window' 29 | browser = new BrowserWindow options 30 | browser.loadUrl url 31 | browser 32 | 33 | # Use the dialog API to implement alert(). 34 | window.alert = (message, title='') -> 35 | dialog = remote.require 'dialog' 36 | buttons = ['OK'] 37 | dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons} 38 | 39 | # And the confirm(). 40 | window.confirm = (message, title='') -> 41 | dialog = remote.require 'dialog' 42 | buttons = ['OK', 'Cancel'] 43 | not dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons} 44 | 45 | # But we do not support prompt(). 46 | window.prompt = -> 47 | throw new Error('prompt() is and will not be supported in atom-shell.') 48 | -------------------------------------------------------------------------------- /docs/api/ipc-browser.md: -------------------------------------------------------------------------------- 1 | # ipc (browser) 2 | 3 | Handles asynchronous and synchronous message sent from web page. 4 | 5 | The messages sent from web page would be emitted to this module, the event name 6 | is the `channel` when sending message. To reply a synchronous message, you need 7 | to set `event.returnValue`, to send an asynchronous back to the sender, you can 8 | use `event.sender.send(...)`. 9 | 10 | It's also possible to send messages from browser side to web pages, see 11 | [WebContents.send](browser-window.md#webcontentssendchannel-args) for more. 12 | 13 | An example of sending and handling messages: 14 | 15 | ```javascript 16 | // In browser. 17 | var ipc = require('ipc'); 18 | ipc.on('asynchronous-message', function(event, arg) { 19 | console.log(arg); // prints "ping" 20 | event.sender.send('asynchronous-reply', 'pong'); 21 | }); 22 | 23 | ipc.on('synchronous-message', function(event, arg) { 24 | console.log(arg); // prints "ping" 25 | event.returnValue = 'pong'; 26 | }); 27 | ``` 28 | 29 | ```javascript 30 | // In web page. 31 | var ipc = require('ipc'); 32 | console.log(ipc.sendSync('synchronous-message', 'ping')); // prints "pong" 33 | 34 | ipc.on('asynchronous-reply', function(arg) { 35 | console.log(arg); // prints "pong" 36 | }); 37 | ipc.send('asynchronous-message', 'ping'); 38 | ``` 39 | 40 | ## Class: Event 41 | 42 | ### Event.returnValue 43 | 44 | Assign to this to return an value to synchronous messages. 45 | 46 | ### Event.sender 47 | 48 | The `WebContents` of the web page that has sent the message. 49 | -------------------------------------------------------------------------------- /script/update.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | from lib.config import DIST_ARCH 8 | 9 | 10 | SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 11 | 12 | 13 | def main(): 14 | os.chdir(SOURCE_ROOT) 15 | 16 | update_external_binaries() 17 | update_gyp() 18 | 19 | 20 | def update_external_binaries(): 21 | uf = os.path.join('script', 'update-external-binaries.py') 22 | subprocess.check_call([sys.executable, uf]) 23 | 24 | 25 | def update_gyp(): 26 | gyp = os.path.join('vendor', 'brightray', 'vendor', 'gyp', 'gyp_main.py') 27 | python = sys.executable 28 | arch = DIST_ARCH 29 | if sys.platform == 'darwin': 30 | # Only have 64bit build on OS X. 31 | arch = 'x64' 32 | elif sys.platform in ['cygwin', 'win32']: 33 | # Only have 32bit build on Windows. 34 | arch = 'ia32' 35 | if sys.platform == 'cygwin': 36 | # Force using win32 python on cygwin. 37 | python = os.path.join('vendor', 'python_26', 'python.exe') 38 | 39 | ret = subprocess.call([python, gyp, 40 | '-f', 'ninja', '--depth', '.', 'atom.gyp', 41 | '-Icommon.gypi', '-Ivendor/brightray/brightray.gypi', 42 | '-Dlinux_clang=0', # Disable brightray's clang setting 43 | '-Dtarget_arch={0}'.format(arch), 44 | '-Dlibrary=static_library']) 45 | if ret != 0: 46 | sys.exit(ret) 47 | 48 | 49 | if __name__ == '__main__': 50 | sys.exit(main()) 51 | -------------------------------------------------------------------------------- /docs/api/global-shortcut.md: -------------------------------------------------------------------------------- 1 | # global-shortcut 2 | 3 | The `global-shortcut` module can register/unregister a global keyboard shortcut 4 | in operating system, so that you can custom the operations for various shortcuts. 5 | Note that it is global, even the app does not get focused, it still works. 6 | 7 | ```javascript 8 | var globalShortcut = require('global-shortcut'); 9 | 10 | // Register a 'ctrl+x' shortcut listener. 11 | var ret = globalShortcut.register('ctrl+x', function() { console.log('ctrl+x is pressed'); }) 12 | if (!ret) 13 | console.log('registerion fails'); 14 | 15 | // Check whether a shortcut is registered. 16 | console.log(globalShortcut.isRegistered('ctrl+x')); 17 | 18 | // Unregister a shortcut. 19 | globalShortcut.unregister('ctrl+x'); 20 | 21 | // Unregister all shortcuts. 22 | globalShortcut.unregisterAll(); 23 | ``` 24 | 25 | ## globalShortcut.register(accelerator, callback) 26 | 27 | * `accelerator` [Accelerator](accelerator.md) 28 | * `callback` Function 29 | 30 | Registers a global shortcut of `accelerator`, the `callback` would be called when 31 | the registered shortcut is pressed by user. 32 | 33 | ## globalShortcut.isRegistered(accelerator) 34 | 35 | * `accelerator` [Accelerator](accelerator.md) 36 | 37 | Returns whether shortcut of `accelerator` is registered. 38 | 39 | ## globalShortcut.unregister(accelerator) 40 | 41 | * `accelerator` [Accelerator](accelerator.md) 42 | 43 | Unregisters the global shortcut of `keycode`. 44 | 45 | ## globalShortcut.unregisterAll() 46 | 47 | Unregisters all the global shortcuts. 48 | -------------------------------------------------------------------------------- /docs/api/image.md: -------------------------------------------------------------------------------- 1 | # Image 2 | 3 | In atom-shell images are represented by their file paths, we currently do not 4 | support in-memory images or remote images. 5 | 6 | For example when creating tray or setting window's icon, you can pass image's 7 | file path as `String` to represent an image: 8 | 9 | ```javascript 10 | var appIcon = new Tray('/Users/somebody/images/icon.png'); 11 | var window = new BrowserWindow({icon: '/Users/somebody/images/window.png'}); 12 | ``` 13 | 14 | ## Supported formats 15 | 16 | Only `PNG` and `JPG` formats are supported, and `PNG` format is preferred. 17 | 18 | ## High resolution image 19 | 20 | On platforms that have high-DPI support, you can append `@2x` after image's 21 | file name's base name to mark it as a high resolution image. 22 | 23 | For example if `icon.png` is a normal image that has standard resolution, the 24 | `icon@2x.png` would be treated as a high resolution image that has double DPI 25 | dense. 26 | 27 | If you want to support displays with different DPI denses at the same time, you 28 | can put images with different sizes in the same folder, and use the filename 29 | without DPI suffixes, like this: 30 | 31 | ```text 32 | images/ 33 | ├── icon.png 34 | ├── icon@2x.png 35 | └── icon@3x.png 36 | ``` 37 | 38 | 39 | ```javascript 40 | var appIcon = new Tray('/Users/somebody/images/icon.png'); 41 | ``` 42 | 43 | Following suffixes as DPI denses are also supported: 44 | 45 | * `@1x` 46 | * `@1.25x` 47 | * `@1.33x` 48 | * `@1.4x` 49 | * `@1.5x` 50 | * `@1.8x` 51 | * `@2x` 52 | * `@2.5x` 53 | * `@3x` 54 | 55 | -------------------------------------------------------------------------------- /atom/browser/atom_javascript_dialog_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_ 6 | #define ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_ 7 | 8 | #include 9 | 10 | #include "content/public/browser/javascript_dialog_manager.h" 11 | 12 | namespace atom { 13 | 14 | class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager { 15 | public: 16 | // content::JavaScriptDialogManager implementations. 17 | virtual void RunJavaScriptDialog( 18 | content::WebContents* web_contents, 19 | const GURL& origin_url, 20 | const std::string& accept_lang, 21 | content::JavaScriptMessageType javascript_message_type, 22 | const base::string16& message_text, 23 | const base::string16& default_prompt_text, 24 | const DialogClosedCallback& callback, 25 | bool* did_suppress_message) OVERRIDE; 26 | virtual void RunBeforeUnloadDialog( 27 | content::WebContents* web_contents, 28 | const base::string16& message_text, 29 | bool is_reload, 30 | const DialogClosedCallback& callback) OVERRIDE; 31 | virtual void CancelActiveAndPendingDialogs( 32 | content::WebContents* web_contents) OVERRIDE {} 33 | virtual void WebContentsDestroyed( 34 | content::WebContents* web_contents) OVERRIDE {} 35 | }; 36 | 37 | } // namespace atom 38 | 39 | #endif // ATOM_BROWSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_ 40 | -------------------------------------------------------------------------------- /atom/browser/mac/atom_application.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #import "atom/browser/mac/atom_application.h" 6 | 7 | #include "base/auto_reset.h" 8 | #include "base/strings/sys_string_conversions.h" 9 | #include "atom/browser/browser.h" 10 | 11 | @implementation AtomApplication 12 | 13 | + (AtomApplication*)sharedApplication { 14 | return (AtomApplication*)[super sharedApplication]; 15 | } 16 | 17 | - (BOOL)isHandlingSendEvent { 18 | return handlingSendEvent_; 19 | } 20 | 21 | - (void)sendEvent:(NSEvent*)event { 22 | base::AutoReset scoper(&handlingSendEvent_, YES); 23 | [super sendEvent:event]; 24 | } 25 | 26 | - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { 27 | handlingSendEvent_ = handlingSendEvent; 28 | } 29 | 30 | - (void)awakeFromNib { 31 | [[NSAppleEventManager sharedAppleEventManager] 32 | setEventHandler:self 33 | andSelector:@selector(handleURLEvent:withReplyEvent:) 34 | forEventClass:kInternetEventClass 35 | andEventID:kAEGetURL]; 36 | } 37 | 38 | - (IBAction)closeAllWindows:(id)sender { 39 | atom::Browser::Get()->Quit(); 40 | } 41 | 42 | - (void)handleURLEvent:(NSAppleEventDescriptor*)event 43 | withReplyEvent:(NSAppleEventDescriptor*)replyEvent { 44 | NSString* url = [ 45 | [event paramDescriptorForKeyword:keyDirectObject] stringValue]; 46 | atom::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url)); 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /atom/browser/net/asar/asar_protocol_handler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_ 6 | #define ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_ 7 | 8 | #include "base/containers/scoped_ptr_hash_map.h" 9 | #include "base/files/file_path.h" 10 | #include "base/memory/ref_counted.h" 11 | #include "net/url_request/url_request_job_factory.h" 12 | 13 | namespace base { 14 | class TaskRunner; 15 | } 16 | 17 | namespace asar { 18 | 19 | class Archive; 20 | 21 | class AsarProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { 22 | public: 23 | explicit AsarProtocolHandler( 24 | const scoped_refptr& file_task_runner); 25 | virtual ~AsarProtocolHandler(); 26 | 27 | Archive* GetOrCreateAsarArchive(const base::FilePath& path) const; 28 | 29 | // net::URLRequestJobFactory::ProtocolHandler: 30 | virtual net::URLRequestJob* MaybeCreateJob( 31 | net::URLRequest* request, 32 | net::NetworkDelegate* network_delegate) const OVERRIDE; 33 | virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE; 34 | 35 | private: 36 | const scoped_refptr file_task_runner_; 37 | 38 | mutable base::ScopedPtrHashMap archives_; 39 | 40 | DISALLOW_COPY_AND_ASSIGN(AsarProtocolHandler); 41 | }; 42 | 43 | } // namespace asar 44 | 45 | #endif // ATOM_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_ 46 | -------------------------------------------------------------------------------- /atom/browser/browser_observer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_BROWSER_OBSERVER_H_ 6 | #define ATOM_BROWSER_BROWSER_OBSERVER_H_ 7 | 8 | #include 9 | 10 | namespace atom { 11 | 12 | class BrowserObserver { 13 | public: 14 | // The browser has closed all windows and will quit. 15 | virtual void OnWillQuit(bool* prevent_default) {} 16 | 17 | // The browser has closed all windows. If the browser is quiting, then this 18 | // method will not be called, instead it will call OnWillQuit. 19 | virtual void OnWindowAllClosed() {} 20 | 21 | // The browser is quitting. 22 | virtual void OnQuit() {} 23 | 24 | // The browser has opened a file by double clicking in Finder or dragging the 25 | // file to the Dock icon. (OS X only) 26 | virtual void OnOpenFile(bool* prevent_default, 27 | const std::string& file_path) {} 28 | 29 | // Browser is used to open a url. 30 | virtual void OnOpenURL(const std::string& url) {} 31 | 32 | // The browser is activated with no open windows (usually by clicking on the 33 | // dock icon). 34 | virtual void OnActivateWithNoOpenWindows() {} 35 | 36 | // The browser has finished loading. 37 | virtual void OnWillFinishLaunching() {} 38 | virtual void OnFinishLaunching() {} 39 | 40 | protected: 41 | virtual ~BrowserObserver() {} 42 | }; 43 | 44 | } // namespace atom 45 | 46 | #endif // ATOM_BROWSER_BROWSER_OBSERVER_H_ 47 | -------------------------------------------------------------------------------- /atom/common/atom_version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_VERSION_H 6 | #define ATOM_VERSION_H 7 | 8 | #define ATOM_MAJOR_VERSION 0 9 | #define ATOM_MINOR_VERSION 18 10 | #define ATOM_PATCH_VERSION 2 11 | 12 | #define ATOM_VERSION_IS_RELEASE 1 13 | 14 | #ifndef ATOM_TAG 15 | # define ATOM_TAG "" 16 | #endif 17 | 18 | #ifndef ATOM_STRINGIFY 19 | #define ATOM_STRINGIFY(n) ATOM_STRINGIFY_HELPER(n) 20 | #define ATOM_STRINGIFY_HELPER(n) #n 21 | #endif 22 | 23 | #if ATOM_VERSION_IS_RELEASE 24 | # define ATOM_VERSION_STRING ATOM_STRINGIFY(ATOM_MAJOR_VERSION) "." \ 25 | ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." \ 26 | ATOM_STRINGIFY(ATOM_PATCH_VERSION) \ 27 | ATOM_TAG 28 | #else 29 | # define ATOM_VERSION_STRING ATOM_STRINGIFY(ATOM_MAJOR_VERSION) "." \ 30 | ATOM_STRINGIFY(ATOM_MINOR_VERSION) "." \ 31 | ATOM_STRINGIFY(ATOM_PATCH_VERSION) \ 32 | ATOM_TAG "-pre" 33 | #endif 34 | 35 | #define ATOM_VERSION "v" ATOM_VERSION_STRING 36 | 37 | 38 | #define ATOM_VERSION_AT_LEAST(major, minor, patch) \ 39 | (( (major) < ATOM_MAJOR_VERSION) \ 40 | || ((major) == ATOM_MAJOR_VERSION && (minor) < ATOM_MINOR_VERSION) \ 41 | || ((major) == ATOM_MAJOR_VERSION && (minor) == ATOM_MINOR_VERSION && (patch) <= ATOM_PATCH_VERSION)) 42 | 43 | #endif /* ATOM_VERSION_H */ 44 | -------------------------------------------------------------------------------- /atom/browser/atom_browser_context.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_ 6 | #define ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_ 7 | 8 | #include "brightray/browser/browser_context.h" 9 | 10 | class BrowserProcess; 11 | 12 | namespace atom { 13 | 14 | class AtomURLRequestJobFactory; 15 | class WebViewManager; 16 | 17 | class AtomBrowserContext : public brightray::BrowserContext { 18 | public: 19 | AtomBrowserContext(); 20 | virtual ~AtomBrowserContext(); 21 | 22 | // Returns the browser context singleton. 23 | static AtomBrowserContext* Get(); 24 | 25 | // brightray::URLRequestContextGetter::Delegate: 26 | virtual net::URLRequestJobFactory* CreateURLRequestJobFactory( 27 | content::ProtocolHandlerMap* handlers, 28 | content::URLRequestInterceptorScopedVector* interceptors) override; 29 | 30 | // content::BrowserContext: 31 | virtual content::BrowserPluginGuestManager* GetGuestManager() override; 32 | 33 | AtomURLRequestJobFactory* job_factory() const { return job_factory_; } 34 | 35 | private: 36 | // A fake BrowserProcess object that used to feed the source code from chrome. 37 | scoped_ptr fake_browser_process_; 38 | scoped_ptr guest_manager_; 39 | 40 | AtomURLRequestJobFactory* job_factory_; // Weak reference. 41 | 42 | DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext); 43 | }; 44 | 45 | } // namespace atom 46 | 47 | #endif // ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_ 48 | -------------------------------------------------------------------------------- /atom/common/crash_reporter/crash_reporter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/crash_reporter/crash_reporter.h" 6 | 7 | #include "atom/browser/browser.h" 8 | #include "atom/common/atom_version.h" 9 | #include "base/command_line.h" 10 | #include "content/public/common/content_switches.h" 11 | 12 | namespace crash_reporter { 13 | 14 | CrashReporter::CrashReporter() { 15 | const CommandLine& command = *CommandLine::ForCurrentProcess(); 16 | is_browser_ = command.GetSwitchValueASCII(switches::kProcessType).empty(); 17 | } 18 | 19 | CrashReporter::~CrashReporter() { 20 | } 21 | 22 | void CrashReporter::Start(const std::string& product_name, 23 | const std::string& company_name, 24 | const std::string& submit_url, 25 | bool auto_submit, 26 | bool skip_system_crash_handler, 27 | const StringMap& extra_parameters) { 28 | SetUploadParameters(extra_parameters); 29 | 30 | InitBreakpad(product_name, ATOM_VERSION_STRING, company_name, submit_url, 31 | auto_submit, skip_system_crash_handler); 32 | } 33 | 34 | void CrashReporter::SetUploadParameters(const StringMap& parameters) { 35 | upload_parameters_ = parameters; 36 | upload_parameters_["process_type"] = is_browser_ ? "browser" : "renderer"; 37 | 38 | // Setting platform dependent parameters. 39 | SetUploadParameters(); 40 | } 41 | 42 | } // namespace crash_reporter 43 | -------------------------------------------------------------------------------- /docs/api/synopsis.md: -------------------------------------------------------------------------------- 1 | # Synopsis 2 | 3 | All [node.js's built-in modules](http://nodejs.org/api/) are available in 4 | atom-shell, and third-party node modules are fully supported too (including the 5 | [native modules](../tutorial/use-native-node-modules.md)). 6 | 7 | Atom-shell also provides some extra built-in modules for developing native 8 | desktop applications. Some modules are only available on the browser side, some 9 | are only available on the client (renderer) side, and some can be used on both sides. 10 | The basic rule is: if a module is GUI or low-level system related, then it should 11 | be only available on the browser side. You need to be familiar with the concept of 12 | [browser-side vs. client-side](../tutorial/quick-start.md#the-browser-side) scripts 13 | to be able to use those modules. 14 | 15 | The browser-side script is just like a normal `node.js` script: 16 | 17 | ```javascript 18 | var app = require('app'); 19 | var BrowserWindow = require('browser-window'); 20 | 21 | var window = null; 22 | 23 | app.on('ready', function() { 24 | window = new BrowserWindow({width: 800, height: 600}); 25 | window.loadUrl('https://github.com'); 26 | }); 27 | 28 | ``` 29 | 30 | The web page is no different than a normal web page, except for the extra 31 | ability to use node modules: 32 | 33 | ```html 34 | 35 | 36 | 37 | 41 | 42 | 43 | ``` 44 | 45 | To run your app, read [Run your app](../tutorial/quick-start.md#run-your-app). 46 | -------------------------------------------------------------------------------- /atom/common/asar/scoped_temporary_file.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/asar/scoped_temporary_file.h" 6 | 7 | #include 8 | 9 | #include "base/file_util.h" 10 | #include "base/threading/thread_restrictions.h" 11 | 12 | namespace asar { 13 | 14 | ScopedTemporaryFile::ScopedTemporaryFile() { 15 | } 16 | 17 | ScopedTemporaryFile::~ScopedTemporaryFile() { 18 | if (!path_.empty()) { 19 | base::ThreadRestrictions::ScopedAllowIO allow_io; 20 | base::DeleteFile(path_, false); 21 | } 22 | } 23 | 24 | bool ScopedTemporaryFile::Init() { 25 | if (!path_.empty()) 26 | return true; 27 | 28 | base::ThreadRestrictions::ScopedAllowIO allow_io; 29 | return base::CreateTemporaryFile(&path_); 30 | } 31 | 32 | bool ScopedTemporaryFile::InitFromFile(const base::FilePath& path, 33 | uint64 offset, uint64 size) { 34 | if (!Init()) 35 | return false; 36 | 37 | base::File src(path, base::File::FLAG_OPEN | base::File::FLAG_READ); 38 | if (!src.IsValid()) 39 | return false; 40 | 41 | std::vector buf(size); 42 | int len = src.Read(offset, buf.data(), buf.size()); 43 | if (len != static_cast(size)) 44 | return false; 45 | 46 | base::File dest(path_, base::File::FLAG_OPEN | base::File::FLAG_WRITE); 47 | if (!dest.IsValid()) 48 | return false; 49 | 50 | return dest.WriteAtCurrentPos(buf.data(), buf.size()) == 51 | static_cast(size); 52 | } 53 | 54 | } // namespace asar 55 | -------------------------------------------------------------------------------- /atom/app/atom_main_delegate.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_APP_ATOM_MAIN_DELEGATE_H_ 6 | #define ATOM_APP_ATOM_MAIN_DELEGATE_H_ 7 | 8 | #include "brightray/common/main_delegate.h" 9 | #include "brightray/common/content_client.h" 10 | 11 | namespace atom { 12 | 13 | class AtomMainDelegate : public brightray::MainDelegate { 14 | public: 15 | AtomMainDelegate(); 16 | ~AtomMainDelegate(); 17 | 18 | protected: 19 | // content::ContentMainDelegate: 20 | virtual bool BasicStartupComplete(int* exit_code) OVERRIDE; 21 | virtual void PreSandboxStartup() OVERRIDE; 22 | virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE; 23 | virtual content::ContentRendererClient* 24 | CreateContentRendererClient() OVERRIDE; 25 | 26 | // brightray::MainDelegate: 27 | virtual scoped_ptr CreateContentClient() OVERRIDE; 28 | virtual void AddDataPackFromPath( 29 | ui::ResourceBundle* bundle, const base::FilePath& pak_dir) OVERRIDE; 30 | #if defined(OS_MACOSX) 31 | virtual void OverrideChildProcessPath() OVERRIDE; 32 | virtual void OverrideFrameworkBundlePath() OVERRIDE; 33 | #endif 34 | 35 | private: 36 | brightray::ContentClient content_client_; 37 | scoped_ptr browser_client_; 38 | scoped_ptr renderer_client_; 39 | 40 | DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate); 41 | }; 42 | 43 | } // namespace atom 44 | 45 | #endif // ATOM_APP_ATOM_MAIN_DELEGATE_H_ 46 | -------------------------------------------------------------------------------- /atom/browser/api/event_emitter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_EVENT_EMITTER_H_ 6 | #define ATOM_BROWSER_API_EVENT_EMITTER_H_ 7 | 8 | #include 9 | 10 | #include "native_mate/wrappable.h" 11 | 12 | namespace base { 13 | class ListValue; 14 | } 15 | 16 | namespace content { 17 | class WebContents; 18 | } 19 | 20 | namespace IPC { 21 | class Message; 22 | } 23 | 24 | namespace mate { 25 | 26 | // Provide helperers to emit event in JavaScript. 27 | class EventEmitter : public Wrappable { 28 | public: 29 | typedef std::vector> Arguments; 30 | 31 | protected: 32 | EventEmitter(); 33 | 34 | // this.emit(name, new Event()); 35 | bool Emit(const base::StringPiece& name); 36 | 37 | // this.emit(name, new Event(), args...); 38 | bool Emit(const base::StringPiece& name, const base::ListValue& args); 39 | 40 | // this.emit(name, new Event(sender, message), args...); 41 | bool Emit(const base::StringPiece& name, const base::ListValue& args, 42 | content::WebContents* sender, IPC::Message* message); 43 | 44 | // Lower level implementations. 45 | bool Emit(v8::Isolate* isolate, 46 | const base::StringPiece& name, 47 | Arguments args, 48 | content::WebContents* sender = nullptr, 49 | IPC::Message* message = nullptr); 50 | 51 | private: 52 | DISALLOW_COPY_AND_ASSIGN(EventEmitter); 53 | }; 54 | 55 | } // namespace mate 56 | 57 | #endif // ATOM_BROWSER_API_EVENT_EMITTER_H_ 58 | -------------------------------------------------------------------------------- /atom/browser/ui/tray_icon_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/tray_icon_gtk.h" 6 | 7 | #include "base/guid.h" 8 | #include "base/strings/utf_string_conversions.h" 9 | #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" 10 | #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" 11 | 12 | namespace atom { 13 | 14 | TrayIconGtk::TrayIconGtk() { 15 | } 16 | 17 | TrayIconGtk::~TrayIconGtk() { 18 | } 19 | 20 | void TrayIconGtk::SetImage(const gfx::ImageSkia& image) { 21 | if (icon_) { 22 | icon_->SetImage(image); 23 | return; 24 | } 25 | 26 | base::string16 empty; 27 | if (libgtk2ui::AppIndicatorIcon::CouldOpen()) 28 | icon_.reset( 29 | new libgtk2ui::AppIndicatorIcon(base::GenerateGUID(), image, empty)); 30 | else 31 | icon_.reset(new libgtk2ui::Gtk2StatusIcon(image, empty)); 32 | icon_->set_delegate(this); 33 | } 34 | 35 | void TrayIconGtk::SetPressedImage(const gfx::ImageSkia& image) { 36 | icon_->SetPressedImage(image); 37 | } 38 | 39 | void TrayIconGtk::SetToolTip(const std::string& tool_tip) { 40 | icon_->SetToolTip(base::UTF8ToUTF16(tool_tip)); 41 | } 42 | 43 | void TrayIconGtk::SetContextMenu(ui::SimpleMenuModel* menu_model) { 44 | icon_->UpdatePlatformContextMenu(menu_model); 45 | } 46 | 47 | void TrayIconGtk::OnClick() { 48 | } 49 | 50 | bool TrayIconGtk::HasClickAction() { 51 | return false; 52 | } 53 | 54 | // static 55 | TrayIcon* TrayIcon::Create() { 56 | return new TrayIconGtk; 57 | } 58 | 59 | } // namespace atom 60 | -------------------------------------------------------------------------------- /tools/mac/apply_locales.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 2009 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | # TODO: remove this script when GYP has for loops 7 | 8 | import sys 9 | import optparse 10 | 11 | def main(argv): 12 | 13 | parser = optparse.OptionParser() 14 | usage = 'usage: %s [options ...] format_string locale_list' 15 | parser.set_usage(usage.replace('%s', '%prog')) 16 | parser.add_option('-d', dest='dash_to_underscore', action="store_true", 17 | default=False, 18 | help='map "en-US" to "en" and "-" to "_" in locales') 19 | 20 | (options, arglist) = parser.parse_args(argv) 21 | 22 | if len(arglist) < 3: 23 | print 'ERROR: need string and list of locales' 24 | return 1 25 | 26 | str_template = arglist[1] 27 | locales = arglist[2:] 28 | 29 | results = [] 30 | for locale in locales: 31 | # For Cocoa to find the locale at runtime, it needs to use '_' instead 32 | # of '-' (http://crbug.com/20441). Also, 'en-US' should be represented 33 | # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578). 34 | if options.dash_to_underscore: 35 | if locale == 'en-US': 36 | locale = 'en' 37 | locale = locale.replace('-', '_') 38 | results.append(str_template.replace('ZZLOCALE', locale)) 39 | 40 | # Quote each element so filename spaces don't mess up GYP's attempt to parse 41 | # it into a list. 42 | print ' '.join(["'%s'" % x for x in results]) 43 | 44 | if __name__ == '__main__': 45 | sys.exit(main(sys.argv)) -------------------------------------------------------------------------------- /atom/browser/mac/atom_application_delegate.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #import "atom/browser/mac/atom_application_delegate.h" 6 | 7 | #import "atom/browser/mac/atom_application.h" 8 | #include "atom/browser/browser.h" 9 | #include "base/strings/sys_string_conversions.h" 10 | 11 | @implementation AtomApplicationDelegate 12 | 13 | - (void)applicationWillFinishLaunching:(NSNotification*)notify { 14 | atom::Browser::Get()->WillFinishLaunching(); 15 | } 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification*)notify { 18 | atom::Browser::Get()->DidFinishLaunching(); 19 | } 20 | 21 | - (BOOL)application:(NSApplication*)sender 22 | openFile:(NSString*)filename { 23 | std::string filename_str(base::SysNSStringToUTF8(filename)); 24 | return atom::Browser::Get()->OpenFile(filename_str) ? YES : NO; 25 | } 26 | 27 | - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender { 28 | atom::Browser* browser = atom::Browser::Get(); 29 | if (browser->is_quiting()) { 30 | return NSTerminateNow; 31 | } else { 32 | // System started termination. 33 | atom::Browser::Get()->Quit(); 34 | return NSTerminateCancel; 35 | } 36 | } 37 | 38 | - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication 39 | hasVisibleWindows:(BOOL)flag { 40 | atom::Browser* browser = atom::Browser::Get(); 41 | if (flag) { 42 | return YES; 43 | } else { 44 | browser->ActivateWithNoOpenWindows(); 45 | return NO; 46 | } 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /atom/common/native_mate_converters/value_converter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/native_mate_converters/value_converter.h" 6 | 7 | #include "atom/common/native_mate_converters/v8_value_converter.h" 8 | #include "base/values.h" 9 | 10 | namespace mate { 11 | 12 | bool Converter::FromV8(v8::Isolate* isolate, 13 | v8::Handle val, 14 | base::DictionaryValue* out) { 15 | scoped_ptr converter(new atom::V8ValueConverter); 16 | scoped_ptr value(converter->FromV8Value( 17 | val, isolate->GetCurrentContext())); 18 | if (value && value->IsType(base::Value::TYPE_DICTIONARY)) { 19 | out->Swap(static_cast(value.get())); 20 | return true; 21 | } else { 22 | return false; 23 | } 24 | } 25 | 26 | bool Converter::FromV8(v8::Isolate* isolate, 27 | v8::Handle val, 28 | base::ListValue* out) { 29 | scoped_ptr converter(new atom::V8ValueConverter); 30 | scoped_ptr value(converter->FromV8Value( 31 | val, isolate->GetCurrentContext())); 32 | if (value->IsType(base::Value::TYPE_LIST)) { 33 | out->Swap(static_cast(value.get())); 34 | return true; 35 | } else { 36 | return false; 37 | } 38 | } 39 | 40 | } // namespace mate 41 | -------------------------------------------------------------------------------- /chromium_src/LICENSE.chromium: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /atom/browser/api/atom_api_tray.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_ATOM_API_TRAY_H_ 6 | #define ATOM_BROWSER_API_ATOM_API_TRAY_H_ 7 | 8 | #include 9 | 10 | #include "atom/browser/api/event_emitter.h" 11 | #include "atom/browser/ui/tray_icon_observer.h" 12 | #include "base/memory/scoped_ptr.h" 13 | 14 | namespace gfx { 15 | class ImageSkia; 16 | } 17 | 18 | namespace atom { 19 | 20 | class TrayIcon; 21 | 22 | namespace api { 23 | 24 | class Menu; 25 | 26 | class Tray : public mate::EventEmitter, 27 | public TrayIconObserver { 28 | public: 29 | static mate::Wrappable* New(const gfx::ImageSkia& image); 30 | 31 | static void BuildPrototype(v8::Isolate* isolate, 32 | v8::Handle prototype); 33 | 34 | protected: 35 | explicit Tray(const gfx::ImageSkia& image); 36 | virtual ~Tray(); 37 | 38 | // TrayIcon implementations: 39 | virtual void OnClicked() OVERRIDE; 40 | virtual void OnDoubleClicked() OVERRIDE; 41 | 42 | void SetImage(const gfx::ImageSkia& image); 43 | void SetPressedImage(const gfx::ImageSkia& image); 44 | void SetToolTip(const std::string& tool_tip); 45 | void SetTitle(const std::string& title); 46 | void SetHighlightMode(bool highlight); 47 | void SetContextMenu(Menu* menu); 48 | 49 | private: 50 | scoped_ptr tray_icon_; 51 | 52 | DISALLOW_COPY_AND_ASSIGN(Tray); 53 | }; 54 | 55 | } // namespace api 56 | 57 | } // namespace atom 58 | 59 | #endif // ATOM_BROWSER_API_ATOM_API_TRAY_H_ 60 | -------------------------------------------------------------------------------- /chromium_src/library_loaders/libgio.h: -------------------------------------------------------------------------------- 1 | // This is generated file. Do not modify directly. 2 | // Path to the code generator: tools/generate_library_loader/generate_library_loader.py . 3 | 4 | #ifndef LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H 5 | #define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H 6 | 7 | #include 8 | #define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN 9 | 10 | 11 | #include 12 | 13 | class LibGioLoader { 14 | public: 15 | LibGioLoader(); 16 | ~LibGioLoader(); 17 | 18 | bool Load(const std::string& library_name) 19 | __attribute__((warn_unused_result)); 20 | 21 | bool loaded() const { return loaded_; } 22 | 23 | typeof(&::g_settings_new) g_settings_new; 24 | typeof(&::g_settings_get_child) g_settings_get_child; 25 | typeof(&::g_settings_get_string) g_settings_get_string; 26 | typeof(&::g_settings_get_boolean) g_settings_get_boolean; 27 | typeof(&::g_settings_get_uint) g_settings_get_uint; 28 | typeof(&::g_settings_get_strv) g_settings_get_strv; 29 | typeof(&::g_settings_is_writable) g_settings_is_writable; 30 | typeof(&::g_settings_list_schemas) g_settings_list_schemas; 31 | typeof(&::g_settings_list_keys) g_settings_list_keys; 32 | 33 | 34 | private: 35 | void CleanUp(bool unload); 36 | 37 | #if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) 38 | void* library_; 39 | #endif 40 | 41 | bool loaded_; 42 | 43 | // Disallow copy constructor and assignment operator. 44 | LibGioLoader(const LibGioLoader&); 45 | void operator=(const LibGioLoader&); 46 | }; 47 | 48 | #endif // LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H 49 | -------------------------------------------------------------------------------- /atom/common/api/atom_api_id_weak_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Copyright (c) 2012 Intel Corp. All rights reserved. 3 | // Use of this source code is governed by the MIT license that can be 4 | // found in the LICENSE file. 5 | 6 | #ifndef ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_ 7 | #define ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_ 8 | 9 | #include 10 | #include 11 | 12 | #include "base/basictypes.h" 13 | #include "native_mate/scoped_persistent.h" 14 | #include "native_mate/wrappable.h" 15 | 16 | namespace atom { 17 | 18 | namespace api { 19 | 20 | // Like ES6's WeakMap, but the key is Integer and the value is Weak Pointer. 21 | class IDWeakMap : public mate::Wrappable { 22 | public: 23 | IDWeakMap(); 24 | 25 | static void BuildPrototype(v8::Isolate* isolate, 26 | v8::Handle prototype); 27 | 28 | private: 29 | virtual ~IDWeakMap(); 30 | 31 | int32_t Add(v8::Isolate* isolate, v8::Handle object); 32 | v8::Handle Get(v8::Isolate* isolate, int32_t key); 33 | bool Has(int32_t key) const; 34 | std::vector Keys() const; 35 | void Remove(int32_t key); 36 | int GetNextID(); 37 | 38 | static void WeakCallback( 39 | const v8::WeakCallbackData& data); 40 | 41 | int32_t next_id_; 42 | 43 | typedef scoped_refptr > 44 | RefCountedV8Object; 45 | std::map map_; 46 | 47 | DISALLOW_COPY_AND_ASSIGN(IDWeakMap); 48 | }; 49 | 50 | } // namespace api 51 | 52 | } // namespace atom 53 | 54 | #endif // ATOM_COMMON_API_ATOM_API_ID_WEAK_MAP_H_ 55 | -------------------------------------------------------------------------------- /atom/common/api/api_messages.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | // Multiply-included file, no traditional include guard. 6 | 7 | #include "atom/common/draggable_region.h" 8 | #include "base/strings/string16.h" 9 | #include "base/values.h" 10 | #include "content/public/common/common_param_traits.h" 11 | #include "ipc/ipc_message_macros.h" 12 | #include "ui/gfx/ipc/gfx_param_traits.h" 13 | 14 | // The message starter should be declared in ipc/ipc_message_start.h. Since 15 | // we don't want to patch Chromium, we just pretend to be Content Shell. 16 | 17 | #define IPC_MESSAGE_START ShellMsgStart 18 | 19 | IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion) 20 | IPC_STRUCT_TRAITS_MEMBER(draggable) 21 | IPC_STRUCT_TRAITS_MEMBER(bounds) 22 | IPC_STRUCT_TRAITS_END() 23 | 24 | IPC_MESSAGE_ROUTED2(AtomViewHostMsg_Message, 25 | base::string16 /* channel */, 26 | base::ListValue /* arguments */) 27 | 28 | IPC_SYNC_MESSAGE_ROUTED2_1(AtomViewHostMsg_Message_Sync, 29 | base::string16 /* channel */, 30 | base::ListValue /* arguments */, 31 | base::string16 /* result (in JSON) */) 32 | 33 | IPC_MESSAGE_ROUTED2(AtomViewMsg_Message, 34 | base::string16 /* channel */, 35 | base::ListValue /* arguments */) 36 | 37 | // Sent by the renderer when the draggable regions are updated. 38 | IPC_MESSAGE_ROUTED1(AtomViewHostMsg_UpdateDraggableRegions, 39 | std::vector /* regions */) 40 | -------------------------------------------------------------------------------- /atom/common/api/atom_api_crash_reporter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | #include 7 | 8 | #include "atom/common/crash_reporter/crash_reporter.h" 9 | #include "base/bind.h" 10 | #include "native_mate/dictionary.h" 11 | 12 | #include "atom/common/node_includes.h" 13 | 14 | namespace mate { 15 | 16 | template<> 17 | struct Converter > { 18 | static bool FromV8(v8::Isolate* isolate, 19 | v8::Handle val, 20 | std::map* out) { 21 | if (!val->IsObject()) 22 | return false; 23 | 24 | v8::Handle dict = val->ToObject(); 25 | v8::Handle keys = dict->GetOwnPropertyNames(); 26 | for (uint32_t i = 0; i < keys->Length(); ++i) { 27 | v8::Handle key = keys->Get(i); 28 | (*out)[V8ToString(key)] = V8ToString(dict->Get(key)); 29 | } 30 | return true; 31 | } 32 | }; 33 | 34 | } // namespace mate 35 | 36 | namespace { 37 | 38 | void Initialize(v8::Handle exports, v8::Handle unused, 39 | v8::Handle context, void* priv) { 40 | using crash_reporter::CrashReporter; 41 | mate::Dictionary dict(context->GetIsolate(), exports); 42 | dict.SetMethod("start", 43 | base::Bind(&CrashReporter::Start, 44 | base::Unretained(CrashReporter::GetInstance()))); 45 | } 46 | 47 | } // namespace 48 | 49 | NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_crash_reporter, Initialize) 50 | -------------------------------------------------------------------------------- /docs/tutorial/application-distribution.md: -------------------------------------------------------------------------------- 1 | # Application distribution 2 | 3 | To distribute your app with atom-shell, you should name the folder of your app 4 | as `app`, and put it under atom-shell's resources directory (on OS X it is 5 | `Atom.app/Contents/Resources/`, and on Linux and Windows it is `resources/`), 6 | like this: 7 | 8 | On Mac OS X: 9 | 10 | ```text 11 | atom-shell/Atom.app/Contents/Resources/app/ 12 | ├── package.json 13 | ├── main.js 14 | └── index.html 15 | ``` 16 | 17 | On Windows and Linux: 18 | 19 | ```text 20 | atom-shell/resources/app 21 | ├── package.json 22 | ├── main.js 23 | └── index.html 24 | ``` 25 | 26 | Then execute `Atom.app` (or `atom` on Linux, and `atom.exe` on Windows), and 27 | atom-shell will start as your app. The `atom-shell` directory would then be 28 | your distribution that should be delivered to final users. 29 | 30 | ## Packaging your app into a file 31 | 32 | Apart from shipping your app by copying all its sources files, you can also 33 | package your app into an [asar](https://github.com/atom/asar) archive to avoid 34 | exposing your app's source code to users. 35 | 36 | To use an `asar` archive to replace the `app` folder, you need to rename the 37 | archive to `app.asar`, and put it under atom-shell's resources directory, 38 | atom-shell will then try read the archive and start from it. 39 | 40 | More details can be found in [Application packaging](application-packaging.md). 41 | 42 | ## Building with grunt 43 | 44 | If you build your application with `grunt` there is a grunt task that can 45 | download atom-shell for your current platform automatically: 46 | [grunt-download-atom-shell](https://github.com/atom/grunt-download-atom-shell). 47 | -------------------------------------------------------------------------------- /atom/common/crash_reporter/crash_reporter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_ 6 | #define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "base/basictypes.h" 12 | 13 | namespace crash_reporter { 14 | 15 | class CrashReporter { 16 | public: 17 | typedef std::map StringMap; 18 | 19 | static CrashReporter* GetInstance(); 20 | 21 | void Start(const std::string& product_name, 22 | const std::string& company_name, 23 | const std::string& submit_url, 24 | bool auto_submit, 25 | bool skip_system_crash_handler, 26 | const StringMap& extra_parameters); 27 | 28 | protected: 29 | CrashReporter(); 30 | virtual ~CrashReporter(); 31 | 32 | virtual void InitBreakpad(const std::string& product_name, 33 | const std::string& version, 34 | const std::string& company_name, 35 | const std::string& submit_url, 36 | bool auto_submit, 37 | bool skip_system_crash_handler) = 0; 38 | virtual void SetUploadParameters() = 0; 39 | 40 | StringMap upload_parameters_; 41 | bool is_browser_; 42 | 43 | private: 44 | void SetUploadParameters(const StringMap& parameters); 45 | 46 | DISALLOW_COPY_AND_ASSIGN(CrashReporter); 47 | }; 48 | 49 | } // namespace crash_reporter 50 | 51 | #endif // ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_ 52 | -------------------------------------------------------------------------------- /atom/browser/api/event.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_EVENT_H_ 6 | #define ATOM_BROWSER_API_EVENT_H_ 7 | 8 | #include "content/public/browser/web_contents_observer.h" 9 | #include "native_mate/wrappable.h" 10 | #include "native_mate/handle.h" 11 | 12 | namespace IPC { 13 | class Message; 14 | } 15 | 16 | namespace mate { 17 | 18 | class Event : public Wrappable, 19 | public content::WebContentsObserver { 20 | public: 21 | static Handle Create(v8::Isolate* isolate); 22 | 23 | // Pass the sender and message to be replied. 24 | void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message); 25 | 26 | // event.PreventDefault(). 27 | void PreventDefault(); 28 | 29 | // event.sendReply(json), used for replying synchronous message. 30 | bool SendReply(const base::string16& json); 31 | 32 | // Whether event.preventDefault() is called. 33 | bool prevent_default() const { return prevent_default_; } 34 | 35 | protected: 36 | Event(); 37 | virtual ~Event(); 38 | 39 | // Wrappable implementations: 40 | virtual ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate); 41 | 42 | // content::WebContentsObserver implementations: 43 | virtual void WebContentsDestroyed() OVERRIDE; 44 | 45 | private: 46 | // Replyer for the synchronous messages. 47 | content::WebContents* sender_; 48 | IPC::Message* message_; 49 | 50 | bool prevent_default_; 51 | 52 | DISALLOW_COPY_AND_ASSIGN(Event); 53 | }; 54 | 55 | } // namespace mate 56 | 57 | #endif // ATOM_BROWSER_API_EVENT_H_ 58 | -------------------------------------------------------------------------------- /atom/common/lib/init.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | timers = require 'timers' 3 | Module = require 'module' 4 | 5 | process.atomBinding = (name) -> 6 | try 7 | process.binding "atom_#{process.type}_#{name}" 8 | catch e 9 | process.binding "atom_common_#{name}" if /No such module/.test e.message 10 | 11 | # Add common/api/lib to module search paths. 12 | globalPaths = Module.globalPaths 13 | globalPaths.push path.join(process.resourcesPath, 'atom', 'common', 'api', 'lib') 14 | 15 | # setImmediate and process.nextTick makes use of uv_check and uv_prepare to 16 | # run the callbacks, however since we only run uv loop on requests, the 17 | # callbacks wouldn't be called until something else activated the uv loop, 18 | # which would delay the callbacks for arbitrary long time. So we should 19 | # initiatively activate the uv loop once setImmediate and process.nextTick is 20 | # called. 21 | wrapWithActivateUvLoop = (func) -> 22 | -> 23 | process.activateUvLoop() 24 | func.apply this, arguments 25 | process.nextTick = wrapWithActivateUvLoop process.nextTick 26 | global.setImmediate = wrapWithActivateUvLoop timers.setImmediate 27 | global.clearImmediate = timers.clearImmediate 28 | 29 | # setTimeout needs to update the polling timeout of the event loop, when called 30 | # under Chromium's event loop the node's event loop won't get a chance to update 31 | # the timeout, so we have to force the node's event loop to recalculate the 32 | # timeout in browser process. 33 | if process.type is 'browser' 34 | global.setTimeout = wrapWithActivateUvLoop timers.setTimeout 35 | global.setInterval = wrapWithActivateUvLoop timers.setInterval 36 | 37 | # Add support for asar packages. 38 | require './asar' 39 | -------------------------------------------------------------------------------- /atom/browser/web_view/web_view_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_WEB_VIEW_WEB_VIEW_MANAGER_H_ 6 | #define ATOM_BROWSER_WEB_VIEW_WEB_VIEW_MANAGER_H_ 7 | 8 | #include 9 | 10 | #include "content/public/browser/browser_plugin_guest_manager.h" 11 | 12 | namespace content { 13 | class BrowserContext; 14 | } 15 | 16 | namespace atom { 17 | 18 | class WebViewManager : public content::BrowserPluginGuestManager { 19 | public: 20 | explicit WebViewManager(content::BrowserContext* context); 21 | virtual ~WebViewManager(); 22 | 23 | void AddGuest(int guest_instance_id, 24 | content::WebContents* embedder, 25 | content::WebContents* web_contents, 26 | bool node_integration); 27 | void RemoveGuest(int guest_instance_id); 28 | 29 | protected: 30 | // content::BrowserPluginGuestManager: 31 | virtual void MaybeGetGuestByInstanceIDOrKill( 32 | int guest_instance_id, 33 | int embedder_render_process_id, 34 | const GuestByInstanceIDCallback& callback) override; 35 | virtual bool ForEachGuest(content::WebContents* embedder_web_contents, 36 | const GuestCallback& callback) override; 37 | 38 | private: 39 | struct WebContentsWithEmbedder { 40 | content::WebContents* web_contents; // Weak ref. 41 | content::WebContents* embedder; 42 | }; 43 | std::map web_contents_map_; 44 | 45 | DISALLOW_COPY_AND_ASSIGN(WebViewManager); 46 | }; 47 | 48 | } // namespace atom 49 | 50 | #endif // ATOM_BROWSER_WEB_VIEW_WEB_VIEW_MANAGER_H_ 51 | -------------------------------------------------------------------------------- /atom/browser/ui/views/menu_layout.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/ui/views/menu_layout.h" 6 | 7 | namespace atom { 8 | 9 | MenuLayout::MenuLayout(int menu_height) 10 | : menu_height_(menu_height) { 11 | } 12 | 13 | MenuLayout::~MenuLayout() { 14 | } 15 | 16 | void MenuLayout::Layout(views::View* host) { 17 | if (!HasMenu(host)) { 18 | views::FillLayout::Layout(host); 19 | return; 20 | } 21 | 22 | gfx::Size size = host->GetContentsBounds().size(); 23 | gfx::Rect menu_Bar_bounds = gfx::Rect(0, 0, size.width(), menu_height_); 24 | gfx::Rect web_view_bounds = gfx::Rect( 25 | 0, menu_height_, size.width(), size.height() - menu_height_); 26 | 27 | views::View* web_view = host->child_at(0); 28 | views::View* menu_bar = host->child_at(1); 29 | web_view->SetBoundsRect(web_view_bounds); 30 | menu_bar->SetBoundsRect(menu_Bar_bounds); 31 | } 32 | 33 | gfx::Size MenuLayout::GetPreferredSize(const views::View* host) const { 34 | gfx::Size size = views::FillLayout::GetPreferredSize(host); 35 | if (!HasMenu(host)) 36 | return size; 37 | 38 | size.set_height(size.height() + menu_height_); 39 | return size; 40 | } 41 | 42 | int MenuLayout::GetPreferredHeightForWidth( 43 | const views::View* host, int width) const { 44 | int height = views::FillLayout::GetPreferredHeightForWidth(host, width); 45 | if (!HasMenu(host)) 46 | return height; 47 | 48 | return height + menu_height_; 49 | } 50 | 51 | bool MenuLayout::HasMenu(const views::View* host) const { 52 | return host->child_count() == 2; 53 | } 54 | 55 | } // namespace atom 56 | -------------------------------------------------------------------------------- /atom/browser/ui/views/submenu_button.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_ 6 | #define ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_ 7 | 8 | #include "ui/views/controls/button/menu_button.h" 9 | 10 | namespace atom { 11 | 12 | // Special button that used by menu bar to show submenus. 13 | class SubmenuButton : public views::MenuButton { 14 | public: 15 | SubmenuButton(views::ButtonListener* listener, 16 | const base::string16& title, 17 | views::MenuButtonListener* menu_button_listener); 18 | virtual ~SubmenuButton(); 19 | 20 | void SetAcceleratorVisibility(bool visible); 21 | void SetUnderlineColor(SkColor color); 22 | 23 | void SetEnabledColor(SkColor color); 24 | void SetBackgroundColor(SkColor color); 25 | 26 | base::char16 accelerator() const { return accelerator_; } 27 | 28 | // views::MenuButton: 29 | virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 30 | 31 | private: 32 | bool GetUnderlinePosition(const base::string16& text, 33 | base::char16* accelerator, 34 | int* start, int* end); 35 | void GetCharacterPosition( 36 | const base::string16& text, int index, int* pos); 37 | 38 | base::char16 accelerator_; 39 | 40 | bool show_underline_; 41 | 42 | int underline_start_; 43 | int underline_end_; 44 | int text_width_; 45 | int text_height_; 46 | SkColor underline_color_; 47 | 48 | DISALLOW_COPY_AND_ASSIGN(SubmenuButton); 49 | }; 50 | 51 | } // namespace atom 52 | 53 | #endif // ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_ 54 | -------------------------------------------------------------------------------- /chromium_src/chrome/common/print_messages.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "chrome/common/print_messages.h" 6 | 7 | #include "base/basictypes.h" 8 | #include "base/strings/string16.h" 9 | #include "ui/gfx/size.h" 10 | 11 | PrintMsg_Print_Params::PrintMsg_Print_Params() 12 | : page_size(), 13 | content_size(), 14 | printable_area(), 15 | margin_top(0), 16 | margin_left(0), 17 | dpi(0), 18 | min_shrink(0), 19 | max_shrink(0), 20 | desired_dpi(0), 21 | document_cookie(0), 22 | selection_only(false), 23 | supports_alpha_blend(false), 24 | print_scaling_option(blink::WebPrintScalingOptionSourceSize), 25 | title(), 26 | url(), 27 | should_print_backgrounds(false) { 28 | } 29 | 30 | PrintMsg_Print_Params::~PrintMsg_Print_Params() {} 31 | 32 | void PrintMsg_Print_Params::Reset() { 33 | page_size = gfx::Size(); 34 | content_size = gfx::Size(); 35 | printable_area = gfx::Rect(); 36 | margin_top = 0; 37 | margin_left = 0; 38 | dpi = 0; 39 | min_shrink = 0; 40 | max_shrink = 0; 41 | desired_dpi = 0; 42 | document_cookie = 0; 43 | selection_only = false; 44 | supports_alpha_blend = false; 45 | print_scaling_option = blink::WebPrintScalingOptionSourceSize; 46 | title.clear(); 47 | url.clear(); 48 | should_print_backgrounds = false; 49 | } 50 | 51 | PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params() 52 | : pages() { 53 | } 54 | 55 | PrintMsg_PrintPages_Params::~PrintMsg_PrintPages_Params() {} 56 | 57 | void PrintMsg_PrintPages_Params::Reset() { 58 | params.Reset(); 59 | pages = std::vector(); 60 | } 61 | -------------------------------------------------------------------------------- /atom/common/crash_reporter/linux/crash_dump_handler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 | // Use of this source code is governed by the MIT license that can be 4 | // found in the LICENSE file. 5 | 6 | #ifndef ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_ 7 | #define ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_ 8 | 9 | #include "base/basictypes.h" 10 | #include "vendor/breakpad/src/common/simple_string_dictionary.h" 11 | 12 | namespace crash_reporter { 13 | 14 | typedef google_breakpad::NonAllocatingMap<256, 256, 64> CrashKeyStorage; 15 | 16 | // BreakpadInfo describes a crash report. 17 | // The minidump information can either be contained in a file descriptor (fd) or 18 | // in a file (whose path is in filename). 19 | struct BreakpadInfo { 20 | int fd; // File descriptor to the Breakpad dump data. 21 | const char* filename; // Path to the Breakpad dump data. 22 | const char* distro; // Linux distro string. 23 | unsigned distro_length; // Length of |distro|. 24 | bool upload; // Whether to upload or save crash dump. 25 | uint64_t process_start_time; // Uptime of the crashing process. 26 | size_t oom_size; // Amount of memory requested if OOM. 27 | uint64_t pid; // PID where applicable. 28 | const char* upload_url; // URL to upload the minidump. 29 | CrashKeyStorage* crash_keys; 30 | }; 31 | 32 | void HandleCrashDump(const BreakpadInfo& info); 33 | 34 | size_t WriteLog(const char* buf, size_t nbytes); 35 | 36 | } // namespace crash_reporter 37 | 38 | #endif // ATOM_COMMON_CRASH_REPORTER_LINUX_CRASH_DUMP_HANDLER_H_ 39 | -------------------------------------------------------------------------------- /atom/common/node_bindings_linux.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/common/node_bindings_linux.h" 6 | 7 | #include 8 | 9 | namespace atom { 10 | 11 | NodeBindingsLinux::NodeBindingsLinux(bool is_browser) 12 | : NodeBindings(is_browser), 13 | epoll_(epoll_create(1)) { 14 | int backend_fd = uv_backend_fd(uv_loop_); 15 | struct epoll_event ev = { 0 }; 16 | ev.events = EPOLLIN; 17 | ev.data.fd = backend_fd; 18 | epoll_ctl(epoll_, EPOLL_CTL_ADD, backend_fd, &ev); 19 | } 20 | 21 | NodeBindingsLinux::~NodeBindingsLinux() { 22 | } 23 | 24 | void NodeBindingsLinux::RunMessageLoop() { 25 | // Get notified when libuv's watcher queue changes. 26 | uv_loop_->data = this; 27 | uv_loop_->on_watcher_queue_updated = OnWatcherQueueChanged; 28 | 29 | NodeBindings::RunMessageLoop(); 30 | } 31 | 32 | // static 33 | void NodeBindingsLinux::OnWatcherQueueChanged(uv_loop_t* loop) { 34 | NodeBindingsLinux* self = static_cast(loop->data); 35 | 36 | // We need to break the io polling in the epoll thread when loop's watcher 37 | // queue changes, otherwise new events cannot be notified. 38 | self->WakeupEmbedThread(); 39 | } 40 | 41 | void NodeBindingsLinux::PollEvents() { 42 | int timeout = uv_backend_timeout(uv_loop_); 43 | 44 | // Wait for new libuv events. 45 | int r; 46 | do { 47 | struct epoll_event ev; 48 | r = epoll_wait(epoll_, &ev, 1, timeout); 49 | } while (r == -1 && errno == EINTR); 50 | } 51 | 52 | // static 53 | NodeBindings* NodeBindings::Create(bool is_browser) { 54 | return new NodeBindingsLinux(is_browser); 55 | } 56 | 57 | } // namespace atom 58 | -------------------------------------------------------------------------------- /spec/api-crash-reporter-spec.coffee: -------------------------------------------------------------------------------- 1 | assert = require 'assert' 2 | path = require 'path' 3 | http = require 'http' 4 | url = require 'url' 5 | remote = require 'remote' 6 | formidable = require 'formidable' 7 | 8 | BrowserWindow = remote.require 'browser-window' 9 | 10 | describe 'crash-reporter module', -> 11 | fixtures = path.resolve __dirname, 'fixtures' 12 | 13 | w = null 14 | beforeEach -> w = new BrowserWindow(show: false) 15 | afterEach -> w.destroy() 16 | 17 | it 'should send minidump when renderer crashes', (done) -> 18 | @timeout 60000 19 | server = http.createServer (req, res) -> 20 | form = new formidable.IncomingForm() 21 | process.throwDeprecation = false 22 | form.parse req, (error, fields, files) -> 23 | process.throwDeprecation = true 24 | assert.equal fields['prod'], 'Atom-Shell' 25 | assert.equal fields['ver'], process.versions['atom-shell'] 26 | assert.equal fields['process_type'], 'renderer' 27 | assert.equal fields['platform'], process.platform 28 | assert.equal fields['extra1'], 'extra1' 29 | assert.equal fields['extra2'], 'extra2' 30 | assert.equal fields['_productName'], 'Zombies' 31 | assert.equal fields['_companyName'], 'Umbrella Corporation' 32 | assert.equal fields['_version'], require('remote').require('app').getVersion() 33 | assert files['upload_file_minidump']['name']? 34 | 35 | res.end() 36 | server.close() 37 | done() 38 | server.listen 0, '127.0.0.1', -> 39 | {port} = server.address() 40 | url = url.format 41 | protocol: 'file' 42 | pathname: path.join fixtures, 'api', 'crash.html' 43 | search: "?port=#{port}" 44 | w.loadUrl url 45 | -------------------------------------------------------------------------------- /atom/browser/api/lib/menu-item.coffee: -------------------------------------------------------------------------------- 1 | BrowserWindow = require 'browser-window' 2 | v8Util = process.atomBinding 'v8_util' 3 | 4 | nextCommandId = 0 5 | 6 | class MenuItem 7 | @types = ['normal', 'separator', 'submenu', 'checkbox', 'radio'] 8 | 9 | constructor: (options) -> 10 | Menu = require 'menu' 11 | 12 | {click, @selector, @type, @label, @sublabel, @accelerator, @enabled, @visible, @checked, @submenu} = options 13 | 14 | @type = 'submenu' if not @type? and @submenu? 15 | throw new Error('Invalid submenu') if @type is 'submenu' and @submenu?.constructor isnt Menu 16 | 17 | @overrideReadOnlyProperty 'type', 'normal' 18 | @overrideReadOnlyProperty 'accelerator' 19 | @overrideReadOnlyProperty 'submenu' 20 | @overrideProperty 'label', '' 21 | @overrideProperty 'sublabel', '' 22 | @overrideProperty 'enabled', true 23 | @overrideProperty 'visible', true 24 | @overrideProperty 'checked', false 25 | 26 | throw new Error("Unknown menu type #{@type}") if MenuItem.types.indexOf(@type) is -1 27 | 28 | @commandId = ++nextCommandId 29 | @click = => 30 | # Manually flip the checked flags when clicked. 31 | @checked = !@checked if @type in ['checkbox', 'radio'] 32 | 33 | if typeof click is 'function' 34 | click this, BrowserWindow.getFocusedWindow() 35 | else if typeof @selector is 'string' 36 | Menu.sendActionToFirstResponder @selector 37 | 38 | overrideProperty: (name, defaultValue=null) -> 39 | this[name] ?= defaultValue 40 | 41 | overrideReadOnlyProperty: (name, defaultValue=null) -> 42 | this[name] ?= defaultValue 43 | Object.defineProperty this, name, 44 | enumerable: true 45 | writable: false 46 | value: this[name] 47 | 48 | module.exports = MenuItem 49 | -------------------------------------------------------------------------------- /atom/browser/api/atom_api_auto_updater.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_API_ATOM_API_AUTO_UPDATER_H_ 6 | #define ATOM_BROWSER_API_ATOM_API_AUTO_UPDATER_H_ 7 | 8 | #include 9 | 10 | #include "base/callback.h" 11 | #include "atom/browser/api/event_emitter.h" 12 | #include "atom/browser/auto_updater_delegate.h" 13 | #include "native_mate/handle.h" 14 | 15 | namespace atom { 16 | 17 | namespace api { 18 | 19 | class AutoUpdater : public mate::EventEmitter, 20 | public auto_updater::AutoUpdaterDelegate { 21 | public: 22 | static mate::Handle Create(v8::Isolate* isolate); 23 | 24 | protected: 25 | AutoUpdater(); 26 | virtual ~AutoUpdater(); 27 | 28 | // AutoUpdaterDelegate implementations. 29 | virtual void OnError(const std::string& error) OVERRIDE; 30 | virtual void OnCheckingForUpdate() OVERRIDE; 31 | virtual void OnUpdateAvailable() OVERRIDE; 32 | virtual void OnUpdateNotAvailable() OVERRIDE; 33 | virtual void OnUpdateDownloaded( 34 | const std::string& release_notes, 35 | const std::string& release_name, 36 | const base::Time& release_date, 37 | const std::string& update_url, 38 | const base::Closure& quit_and_install) OVERRIDE; 39 | 40 | // mate::Wrappable implementations: 41 | virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder( 42 | v8::Isolate* isolate); 43 | 44 | private: 45 | void QuitAndInstall(); 46 | 47 | base::Closure quit_and_install_; 48 | 49 | DISALLOW_COPY_AND_ASSIGN(AutoUpdater); 50 | }; 51 | 52 | } // namespace api 53 | 54 | } // namespace atom 55 | 56 | #endif // ATOM_BROWSER_API_ATOM_API_AUTO_UPDATER_H_ 57 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/printing/print_job_worker_owner.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ 6 | #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ 7 | 8 | #include "base/memory/ref_counted.h" 9 | #include "printing/printing_context.h" 10 | 11 | namespace base { 12 | class MessageLoop; 13 | } 14 | 15 | 16 | namespace printing { 17 | 18 | class PrintJobWorker; 19 | class PrintSettings; 20 | 21 | class PrintJobWorkerOwner 22 | : public base::RefCountedThreadSafe { 23 | public: 24 | // Finishes the initialization began by PrintJobWorker::GetSettings(). 25 | // Creates a new PrintedDocument if necessary. Solely meant to be called by 26 | // PrintJobWorker. 27 | virtual void GetSettingsDone(const PrintSettings& new_settings, 28 | PrintingContext::Result result) = 0; 29 | 30 | // Detach the PrintJobWorker associated to this object. 31 | virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) = 0; 32 | 33 | // Retrieves the message loop that is expected to process GetSettingsDone. 34 | virtual base::MessageLoop* message_loop() = 0; 35 | 36 | // Access the current settings. 37 | virtual const PrintSettings& settings() const = 0; 38 | 39 | // Cookie uniquely identifying the PrintedDocument and/or loaded settings. 40 | virtual int cookie() const = 0; 41 | 42 | protected: 43 | friend class base::RefCountedThreadSafe; 44 | 45 | virtual ~PrintJobWorkerOwner() {} 46 | }; 47 | 48 | } // namespace printing 49 | 50 | #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ 51 | -------------------------------------------------------------------------------- /atom/browser/atom_access_token_store.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "atom/browser/atom_access_token_store.h" 6 | 7 | #include 8 | 9 | #include "atom/browser/atom_browser_context.h" 10 | #include "atom/common/google_api_key.h" 11 | 12 | namespace atom { 13 | 14 | namespace { 15 | 16 | // Notice that we just combined the api key with the url together here, because 17 | // if we use the standard {url: key} format Chromium would override our key with 18 | // the predefined one in common.gypi of libchromiumcontent, which is empty. 19 | const char* kGeolocationProviderUrl = 20 | "https://www.googleapis.com/geolocation/v1/geolocate?key=" 21 | GOOGLEAPIS_API_KEY; 22 | 23 | } // namespace 24 | 25 | AtomAccessTokenStore::AtomAccessTokenStore() { 26 | } 27 | 28 | AtomAccessTokenStore::~AtomAccessTokenStore() { 29 | } 30 | 31 | void AtomAccessTokenStore::LoadAccessTokens( 32 | const LoadAccessTokensCallbackType& callback) { 33 | AccessTokenSet access_token_set; 34 | 35 | // Equivelent to access_token_set[kGeolocationProviderUrl]. 36 | // Somehow base::string16 is causing compilation errors when used in a pair 37 | // of std::map on Linux, this can work around it. 38 | std::pair token_pair; 39 | token_pair.first = GURL(kGeolocationProviderUrl); 40 | access_token_set.insert(token_pair); 41 | 42 | callback.Run(access_token_set, 43 | AtomBrowserContext::Get()->url_request_context_getter()); 44 | } 45 | 46 | void AtomAccessTokenStore::SaveAccessToken(const GURL& server_url, 47 | const base::string16& access_token) { 48 | } 49 | 50 | } // namespace atom 51 | -------------------------------------------------------------------------------- /atom/common/options_switches.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_COMMON_OPTIONS_SWITCHES_H_ 6 | #define ATOM_COMMON_OPTIONS_SWITCHES_H_ 7 | 8 | namespace atom { 9 | 10 | namespace switches { 11 | 12 | extern const char kTitle[]; 13 | extern const char kIcon[]; 14 | extern const char kFrame[]; 15 | extern const char kShow[]; 16 | extern const char kCenter[]; 17 | extern const char kX[]; 18 | extern const char kY[]; 19 | extern const char kWidth[]; 20 | extern const char kHeight[]; 21 | extern const char kMinWidth[]; 22 | extern const char kMinHeight[]; 23 | extern const char kMaxWidth[]; 24 | extern const char kMaxHeight[]; 25 | extern const char kResizable[]; 26 | extern const char kFullscreen[]; 27 | extern const char kSkipTaskbar[]; 28 | extern const char kKiosk[]; 29 | extern const char kAlwaysOnTop[]; 30 | extern const char kNodeIntegration[]; 31 | extern const char kAcceptFirstMouse[]; 32 | extern const char kUseContentSize[]; 33 | extern const char kWebPreferences[]; 34 | extern const char kZoomFactor[]; 35 | extern const char kAutoHideMenuBar[]; 36 | extern const char kEnableLargerThanScreen[]; 37 | extern const char kDarkTheme[]; 38 | extern const char kDirectWrite[]; 39 | extern const char kEnablePlugins[]; 40 | extern const char kGuestInstanceID[]; 41 | 42 | extern const char kExperimentalFeatures[]; 43 | extern const char kExperimentalCanvasFeatures[]; 44 | extern const char kSubpixelFontScaling[]; 45 | extern const char kOverlayScrollbars[]; 46 | extern const char kOverlayFullscreenVideo[]; 47 | extern const char kSharedWorker[]; 48 | 49 | } // namespace switches 50 | 51 | } // namespace atom 52 | 53 | #endif // ATOM_COMMON_OPTIONS_SWITCHES_H_ 54 | -------------------------------------------------------------------------------- /docs/api/crash-reporter.md: -------------------------------------------------------------------------------- 1 | # crash-reporter 2 | 3 | An example of automatically submitting crash reporters to remote server: 4 | 5 | ```javascript 6 | crashReporter = require('crash-reporter'); 7 | crashReporter.start({ 8 | productName: 'YourName', 9 | companyName: 'YourCompany', 10 | submitUrl: 'https://your-domain.com/url-to-submit', 11 | autoSubmit: true 12 | }); 13 | ``` 14 | 15 | ## crashReporter.start(options) 16 | 17 | * `options` Object 18 | * `productName` String, default: Atom-Shell 19 | * `companyName` String, default: GitHub, Inc 20 | * `submitUrl` String, default: http://54.249.141.255:1127/post 21 | * URL that crash reports would be sent to as POST 22 | * `autoSubmit` Boolean, default: true 23 | * Send the crash report without user interaction 24 | * `ignoreSystemCrashHandler` Boolean, default: false 25 | * `extra` Object 26 | * An object you can define which content will be send along with the report. 27 | * Only string properties are send correctly. 28 | * Nested objects are not supported. 29 | 30 | # crash-reporter payload 31 | 32 | The crash reporter will send the following data to the `submitUrl` as `POST`: 33 | 34 | * `rept` String - eg. atom-shell-crash-service 35 | * `ver` String - The version of atom-shell 36 | * `platform` String - eg. win32 37 | * `process_type` String - eg. browser 38 | * `ptime` Number 39 | * `_version` String - The version in `package.json` 40 | * `_productName` String - The product name in the crashReporter `options` object 41 | * `prod` String - Name of the underlying product. In this case Atom-Shell 42 | * `_companyName` String - The company name in the crashReporter `options` object 43 | * `upload_file_minidump` File - The crashreport as file 44 | * All level one properties of the `extra` object in the crashReporter `options` object 45 | -------------------------------------------------------------------------------- /atom/browser/web_view/web_view_renderer_state.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 GitHub, Inc. All rights reserved. 2 | // Use of this source code is governed by the MIT license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef ATOM_BROWSER_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ 6 | #define ATOM_BROWSER_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "base/memory/singleton.h" 13 | 14 | namespace atom { 15 | 16 | class WebViewManager; 17 | 18 | // This class keeps track of renderer state for use on the IO thread. 19 | // All methods should be called on the IO thread. 20 | class WebViewRendererState { 21 | public: 22 | struct WebViewInfo { 23 | int guest_instance_id; 24 | bool node_integration; 25 | }; 26 | 27 | static WebViewRendererState* GetInstance(); 28 | 29 | // Looks up the information for the embedder for a given render 30 | // view, if one exists. Called on the IO thread. 31 | bool GetInfo(int guest_process_id, WebViewInfo* webview_info); 32 | 33 | // Returns true if the given renderer is used by webviews. 34 | bool IsGuest(int render_process_id); 35 | 36 | private: 37 | friend class WebViewManager; 38 | friend struct DefaultSingletonTraits; 39 | 40 | typedef std::map WebViewInfoMap; 41 | 42 | WebViewRendererState(); 43 | ~WebViewRendererState(); 44 | 45 | // Adds or removes a guest render process from the set. 46 | void AddGuest(int render_process_id, const WebViewInfo& webview_info); 47 | void RemoveGuest(int render_process_id); 48 | 49 | WebViewInfoMap webview_info_map_; 50 | 51 | DISALLOW_COPY_AND_ASSIGN(WebViewRendererState); 52 | }; 53 | 54 | } // namespace atom 55 | 56 | #endif // ATOM_BROWSER_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ 57 | -------------------------------------------------------------------------------- /chromium_src/chrome/browser/printing/print_view_manager_basic.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "chrome/browser/printing/print_view_manager_basic.h" 6 | 7 | #if defined(OS_ANDROID) 8 | #include "base/file_descriptor_posix.h" 9 | #include "chrome/common/print_messages.h" 10 | #include "printing/printing_context_android.h" 11 | #endif 12 | 13 | DEFINE_WEB_CONTENTS_USER_DATA_KEY(printing::PrintViewManagerBasic); 14 | 15 | namespace printing { 16 | 17 | PrintViewManagerBasic::PrintViewManagerBasic(content::WebContents* web_contents) 18 | : PrintViewManagerBase(web_contents) { 19 | } 20 | 21 | PrintViewManagerBasic::~PrintViewManagerBasic() { 22 | } 23 | 24 | #if defined(OS_ANDROID) 25 | void PrintViewManagerBasic::RenderProcessGone(base::TerminationStatus status) { 26 | PrintingContextAndroid::PdfWritingDone(file_descriptor_.fd, false); 27 | file_descriptor_ = base::FileDescriptor(-1, false); 28 | PrintViewManagerBase::RenderProcessGone(status); 29 | } 30 | 31 | void PrintViewManagerBasic::OnPrintingFailed(int cookie) { 32 | PrintingContextAndroid::PdfWritingDone(file_descriptor_.fd, false); 33 | file_descriptor_ = base::FileDescriptor(-1, false); 34 | PrintViewManagerBase::OnPrintingFailed(cookie); 35 | } 36 | 37 | bool PrintViewManagerBasic::OnMessageReceived(const IPC::Message& message) { 38 | bool handled = true; 39 | IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBasic, message) 40 | IPC_MESSAGE_HANDLER(PrintHostMsg_PrintingFailed, OnPrintingFailed) 41 | IPC_MESSAGE_UNHANDLED(handled = false) 42 | IPC_END_MESSAGE_MAP() 43 | 44 | return handled ? true : PrintViewManagerBase::OnMessageReceived(message); 45 | } 46 | #endif 47 | 48 | } // namespace printing 49 | --------------------------------------------------------------------------------