mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Load atom.js on startup.
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user