Add API to override browser version.

This commit is contained in:
Cheng Zhao 2013-12-05 10:26:01 +08:00
parent 02bbf07d3a
commit 420ae1a2cc
6 changed files with 40 additions and 3 deletions

View file

@ -108,6 +108,19 @@ v8::Handle<v8::Value> App::GetVersion(const v8::Arguments &args) {
return v8::String::New(version.data(), version.size());
}
// static
v8::Handle<v8::Value> App::SetVersion(const v8::Arguments &args) {
v8::HandleScope scope;
std::string version;
if (!FromV8Arguments(args, &version))
return node::ThrowError("Bad argument");
Browser::Get()->SetVersion(version);
return v8::Undefined();
}
// static
v8::Handle<v8::Value> App::AppendSwitch(const v8::Arguments &args) {
v8::HandleScope scope;
@ -190,6 +203,7 @@ void App::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "terminate", Terminate);
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
NODE_SET_PROTOTYPE_METHOD(t, "getVersion", GetVersion);
NODE_SET_PROTOTYPE_METHOD(t, "setVersion", SetVersion);
target->Set(v8::String::NewSymbol("Application"), t->GetFunction());