Make BrowserWindow inheritable. Fixed #23.

This commit is contained in:
Cheng Zhao 2013-06-18 18:35:08 +08:00
parent eaa03facee
commit 5a0aab2e4f
5 changed files with 87 additions and 28 deletions

View file

@ -71,6 +71,26 @@ bool EventEmitter::Emit(const std::string& name, base::ListValue* args) {
return prevent_default;
}
// static
v8::Handle<v8::Value> EventEmitter::FromConstructorTemplate(
v8::Persistent<v8::FunctionTemplate> t,
const v8::Arguments& args) {
v8::Handle<v8::Value> new_object = node::FromConstructorTemplate(t, args);
args.This()->SetHiddenValue(v8::String::New("native_object"), new_object);
return new_object;
}
// static
v8::Handle<v8::Object> EventEmitter::SearchNativeObject(
v8::Handle<v8::Object> handle) {
if (handle->InternalFieldCount() > 0)
return handle;
// If the object is not a native object, we assume the native object is
// stored in it.
return handle->GetHiddenValue(v8::String::New("native_object"))->ToObject();
}
} // namespace api
} // namespace atom