Add API to get and override application name.

This commit is contained in:
Cheng Zhao 2013-12-05 10:32:58 +08:00
parent 420ae1a2cc
commit 5670ee7693
4 changed files with 41 additions and 0 deletions

View file

@ -121,6 +121,28 @@ v8::Handle<v8::Value> App::SetVersion(const v8::Arguments &args) {
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::GetName(const v8::Arguments &args) {
v8::HandleScope scope;
std::string name(Browser::Get()->GetName());
return v8::String::New(name.data(), version.size());
}
// static
v8::Handle<v8::Value> App::SetName(const v8::Arguments &args) {
v8::HandleScope scope;
std::string name;
if (!FromV8Arguments(args, &name))
return node::ThrowError("Bad argument");
Browser::Get()->SetName(name);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
v8::HandleScope scope;
@ -204,6 +226,8 @@ void App::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
NODE_SET_PROTOTYPE_METHOD(t, "getVersion", GetVersion);
NODE_SET_PROTOTYPE_METHOD(t, "setVersion", SetVersion);
NODE_SET_PROTOTYPE_METHOD(t, "getName", GetName);
NODE_SET_PROTOTYPE_METHOD(t, "setName", SetName);
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());