Load atom.js on startup.
This commit is contained in:
parent
f853fc3df5
commit
40307126d7
8 changed files with 24 additions and 9 deletions
6
atom.gyp
6
atom.gyp
|
@ -71,6 +71,12 @@
|
|||
'<(PRODUCT_DIR)/<(product_name).framework',
|
||||
],
|
||||
},
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
|
||||
'files': [
|
||||
'browser/atom',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
|
|
1
browser/atom/atom.js
Normal file
1
browser/atom/atom.js
Normal file
|
@ -0,0 +1 @@
|
|||
console.log(process.argv);
|
0
browser/atom/atom_content_demo.js
Normal file
0
browser/atom/atom_content_demo.js
Normal file
0
browser/atom/index.html
Normal file
0
browser/atom/index.html
Normal file
|
@ -15,7 +15,7 @@
|
|||
namespace atom {
|
||||
|
||||
AtomBrowserMainParts::AtomBrowserMainParts()
|
||||
: node_bindings_(new NodeBindings) {
|
||||
: node_bindings_(new NodeBindings(true)) {
|
||||
}
|
||||
|
||||
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
||||
|
|
|
@ -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<char*> 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<char*>(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<v8::Object> process = node::SetupProcessObject(
|
||||
argv.size(), &argv[0]);
|
||||
|
||||
// Tell node.js we are in browser or renderer.
|
||||
v8::Handle<v8::String> 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
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
2
vendor/node
vendored
2
vendor/node
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 4ca67139123acff24c884377ebfd6f31eb4efa01
|
||||
Subproject commit 6dadfdb1f5fbaf0d7132fa2b4e4ed084bddead8a
|
Loading…
Reference in a new issue