diff --git a/browser/api/atom_api_dialog.cc b/browser/api/atom_api_dialog.cc index e5d52c43472a..063ed0d4cffb 100644 --- a/browser/api/atom_api_dialog.cc +++ b/browser/api/atom_api_dialog.cc @@ -59,9 +59,8 @@ v8::Handle ShowMessageBox(const v8::Arguments &args) { return node::ThrowTypeError("Bad argument"); NativeWindow* native_window = FromV8Value(args[5]); - v8::Persistent callback = FromV8Value(args[6]); - if (callback.IsEmpty()) { + if (!args[6]->IsFunction()) { int chosen = atom::ShowMessageBox( native_window, (MessageBoxType)type, @@ -71,6 +70,7 @@ v8::Handle ShowMessageBox(const v8::Arguments &args) { detail); return scope.Close(v8::Integer::New(chosen)); } else { + v8::Persistent callback = FromV8Value(args[6]); atom::ShowMessageBox( native_window, (MessageBoxType)type, @@ -93,9 +93,8 @@ v8::Handle ShowOpenDialog(const v8::Arguments &args) { return node::ThrowTypeError("Bad argument"); NativeWindow* native_window = FromV8Value(args[3]); - v8::Persistent callback = FromV8Value(args[4]); - if (callback.IsEmpty()) { + if (!args[4]->IsFunction()) { std::vector paths; if (!file_dialog::ShowOpenDialog(native_window, title, @@ -110,6 +109,7 @@ v8::Handle ShowOpenDialog(const v8::Arguments &args) { return scope.Close(result); } else { + v8::Persistent callback = FromV8Value(args[4]); file_dialog::ShowOpenDialog( native_window, title, @@ -130,9 +130,8 @@ v8::Handle ShowSaveDialog(const v8::Arguments &args) { return node::ThrowTypeError("Bad argument"); NativeWindow* native_window = FromV8Value(args[2]); - v8::Persistent callback = FromV8Value(args[3]); - if (callback.IsEmpty()) { + if (!args[3]->IsFunction()) { base::FilePath path; if (!file_dialog::ShowSaveDialog(native_window, title, @@ -142,6 +141,7 @@ v8::Handle ShowSaveDialog(const v8::Arguments &args) { return scope.Close(ToV8Value(path)); } else { + v8::Persistent callback = FromV8Value(args[3]); file_dialog::ShowSaveDialog( native_window, title,