41
41
42
42
namespace nwapi {
43
43
44
+ static inline v8::Local<v8::String> v8_str (const char * x) {
45
+ return v8::String::New (x);
46
+ }
47
+
44
48
Dispatcher::Dispatcher (content::RenderView* render_view)
45
49
: content::RenderViewObserver(render_view) {
46
50
}
@@ -85,11 +89,11 @@ void Dispatcher::OnEvent(int object_id,
85
89
v8::Handle<v8::Value> args = converter.ToV8Value (&arguments, node::g_context);
86
90
DCHECK (!args.IsEmpty ()) << " Invalid 'arguments' in Dispatcher::OnEvent" ;
87
91
v8::Handle<v8::Value> argv[] = {
88
- v8::Integer::New (object_id), v8::String::New (event.c_str ()), args };
92
+ v8::Integer::New (object_id), v8_str (event.c_str ()), args };
89
93
90
94
// __nwObjectsRegistry.handleEvent(object_id, event, arguments);
91
95
v8::Handle<v8::Value> val =
92
- node::g_context->Global ()->Get (v8::String::New (" __nwObjectsRegistry" ));
96
+ node::g_context->Global ()->Get (v8_str (" __nwObjectsRegistry" ));
93
97
if (val->IsNull () || val->IsUndefined ())
94
98
return ; // need to find out why it's undefined here in debugger
95
99
v8::Handle<v8::Object> objects_registry = val->ToObject ();
@@ -99,15 +103,15 @@ void Dispatcher::OnEvent(int object_id,
99
103
100
104
v8::Handle<v8::Object> Dispatcher::GetObjectRegistry () {
101
105
v8::Handle<v8::Value> registry =
102
- node::g_context->Global ()->Get (v8::String::New (" __nwObjectsRegistry" ));
106
+ node::g_context->Global ()->Get (v8_str (" __nwObjectsRegistry" ));
103
107
// if (registry->IsNull() || registry->IsUndefined())
104
108
// return v8::Undefined();
105
109
return registry->ToObject ();
106
110
}
107
111
108
112
v8::Handle<v8::Value> Dispatcher::GetWindowId (WebKit::WebFrame* frame) {
109
113
v8::Handle<v8::Value> v8win = frame->mainWorldScriptContext ()->Global ();
110
- v8::Handle<v8::Value> val = v8win->ToObject ()->Get (v8::String::New (" __nwWindowId" ));
114
+ v8::Handle<v8::Value> val = v8win->ToObject ()->Get (v8_str (" __nwWindowId" ));
111
115
112
116
return val;
113
117
}
@@ -127,7 +131,7 @@ void Dispatcher::ZoomLevelChanged() {
127
131
128
132
v8::Local<v8::Array> args = v8::Array::New ();
129
133
args->Set (0 , v8::Number::New (zoom_level));
130
- v8::Handle<v8::Value> argv[] = {val, v8::String::New (" zoom" ), args };
134
+ v8::Handle<v8::Value> argv[] = {val, v8_str (" zoom" ), args };
131
135
132
136
node::MakeCallback (objects_registry, " handleEvent" , 3 , argv);
133
137
}
0 commit comments