Add the App.commandLine API to control Chromium's command line.
This commit is contained in:
parent
394bf0a8d9
commit
61bca04dfd
4 changed files with 50 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "browser/api/atom_api_app.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "browser/browser.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
|
||||
|
@ -58,6 +59,38 @@ v8::Handle<v8::Value> App::Terminate(const v8::Arguments &args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (!args[0]->IsString())
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
std::string switch_string(*v8::String::Utf8Value(args[0]));
|
||||
if (args.Length() == 1) {
|
||||
CommandLine::ForCurrentProcess()->AppendSwitch(switch_string);
|
||||
} else {
|
||||
std::string value(*v8::String::Utf8Value(args[1]));
|
||||
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
switch_string, value);
|
||||
}
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> App::AppendArgument(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (!args[0]->IsString())
|
||||
return node::ThrowError("Bad argument");
|
||||
|
||||
std::string value(*v8::String::Utf8Value(args[0]));
|
||||
CommandLine::ForCurrentProcess()->AppendArg(value);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
void App::Initialize(v8::Handle<v8::Object> target) {
|
||||
v8::HandleScope scope;
|
||||
|
@ -70,6 +103,9 @@ void App::Initialize(v8::Handle<v8::Object> target) {
|
|||
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
|
||||
|
||||
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());
|
||||
|
||||
NODE_SET_METHOD(target, "appendSwitch", AppendSwitch);
|
||||
NODE_SET_METHOD(target, "appendArgument", AppendArgument);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue