Make dialog.showSaveDialog accept a callback.
This commit is contained in:
parent
c7637c78d1
commit
26f0e49c9a
1 changed files with 24 additions and 8 deletions
|
@ -180,7 +180,7 @@ v8::Handle<v8::Value> ShowOpenDialog(const v8::Arguments &args) {
|
||||||
title,
|
title,
|
||||||
default_path,
|
default_path,
|
||||||
properties,
|
properties,
|
||||||
base::Bind(&CallV8Function2<const std::vector<base::FilePath>>,
|
base::Bind(&CallV8Function2<const std::vector<base::FilePath>&>,
|
||||||
callback));
|
callback));
|
||||||
return v8::Undefined();
|
return v8::Undefined();
|
||||||
}
|
}
|
||||||
|
@ -202,9 +202,17 @@ v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args) {
|
||||||
native_window = window->window();
|
native_window = window->window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v8::Persistent<v8::Function> callback;
|
||||||
|
if (args[3]->IsFunction()) {
|
||||||
|
callback = v8::Persistent<v8::Function>::New(
|
||||||
|
node_isolate,
|
||||||
|
v8::Local<v8::Function>::Cast(args[3]));
|
||||||
|
}
|
||||||
|
|
||||||
std::string title(*v8::String::Utf8Value(args[0]));
|
std::string title(*v8::String::Utf8Value(args[0]));
|
||||||
base::FilePath default_path(V8ValueToFilePath(args[1]));
|
base::FilePath default_path(V8ValueToFilePath(args[1]));
|
||||||
|
|
||||||
|
if (callback.IsEmpty()) {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
if (!file_dialog::ShowSaveDialog(native_window,
|
if (!file_dialog::ShowSaveDialog(native_window,
|
||||||
title,
|
title,
|
||||||
|
@ -213,6 +221,14 @@ v8::Handle<v8::Value> ShowSaveDialog(const v8::Arguments &args) {
|
||||||
return v8::Undefined();
|
return v8::Undefined();
|
||||||
|
|
||||||
return scope.Close(ToV8Value(path));
|
return scope.Close(ToV8Value(path));
|
||||||
|
} else {
|
||||||
|
file_dialog::ShowSaveDialog(
|
||||||
|
native_window,
|
||||||
|
title,
|
||||||
|
default_path,
|
||||||
|
base::Bind(&CallV8Function2<const base::FilePath&>, callback));
|
||||||
|
return v8::Undefined();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
Loading…
Add table
Reference in a new issue