diff --git a/atom.gyp b/atom.gyp index 48adf5f69215..fccacc4ef6c2 100644 --- a/atom.gyp +++ b/atom.gyp @@ -71,6 +71,12 @@ '<(PRODUCT_DIR)/<(product_name).framework', ], }, + { + 'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources', + 'files': [ + 'browser/atom', + ], + }, ], 'postbuilds': [ { diff --git a/browser/atom/atom.js b/browser/atom/atom.js new file mode 100644 index 000000000000..ab74fd7b7996 --- /dev/null +++ b/browser/atom/atom.js @@ -0,0 +1 @@ +console.log(process.argv); diff --git a/browser/atom/atom_content_demo.js b/browser/atom/atom_content_demo.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/browser/atom/index.html b/browser/atom/index.html new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/browser/atom_browser_main_parts.cc b/browser/atom_browser_main_parts.cc index fc70e3df94d9..6d05af74668a 100644 --- a/browser/atom_browser_main_parts.cc +++ b/browser/atom_browser_main_parts.cc @@ -15,7 +15,7 @@ namespace atom { AtomBrowserMainParts::AtomBrowserMainParts() - : node_bindings_(new NodeBindings) { + : node_bindings_(new NodeBindings(true)) { } AtomBrowserMainParts::~AtomBrowserMainParts() { diff --git a/common/node_bindings.cc b/common/node_bindings.cc index f0a997ce9b98..bcca002da589 100644 --- a/common/node_bindings.cc +++ b/common/node_bindings.cc @@ -5,6 +5,7 @@ #include "common/node_bindings.h" #include "base/command_line.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "v8/include/v8.h" #include "vendor/node/src/node.h" @@ -12,7 +13,8 @@ namespace atom { -NodeBindings::NodeBindings() { +NodeBindings::NodeBindings(bool is_browser) + : is_browser_(is_browser) { } NodeBindings::~NodeBindings() { @@ -23,10 +25,8 @@ void NodeBindings::Initialize() { // Convert string vector to char* array. std::vector argv(str_argv.size(), NULL); - for (size_t i = 0; i < str_argv.size(); ++i) { - LOG(ERROR) << str_argv[i]; + for (size_t i = 0; i < str_argv.size(); ++i) argv[i] = const_cast(str_argv[i].c_str()); - } // Init node. node::Init(argv.size(), &argv[0]); @@ -39,8 +39,14 @@ void NodeBindings::Initialize() { v8::Context::Scope context_scope(node::g_context); v8::Handle process = node::SetupProcessObject( argv.size(), &argv[0]); + + // Tell node.js we are in browser or renderer. + v8::Handle type = + is_browser_ ? v8::String::New("browser") : v8::String::New("renderer"); + process->Set(v8::String::New("__atom_type"), type); + node::Load(process); } } - -} // namespace at + +} // namespace atom diff --git a/common/node_bindings.h b/common/node_bindings.h index 77d6f91b34b0..c73e79844c18 100644 --- a/common/node_bindings.h +++ b/common/node_bindings.h @@ -11,13 +11,15 @@ namespace atom { class NodeBindings { public: - NodeBindings(); + NodeBindings(bool is_browser); virtual ~NodeBindings(); // Setup everything including V8, libuv and node.js main script. void Initialize(); private: + bool is_browser_; + DISALLOW_COPY_AND_ASSIGN(NodeBindings); }; diff --git a/vendor/node b/vendor/node index 4ca67139123a..6dadfdb1f5fb 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 4ca67139123acff24c884377ebfd6f31eb4efa01 +Subproject commit 6dadfdb1f5fbaf0d7132fa2b4e4ed084bddead8a