refactor: make util::Promise type safe when chaining in native (#19809)
* refactor: make util::Promise type safe when chaining in native * fixup! refactor: make util::Promise type safe when chaining in native * chore: remove spare brackets
This commit is contained in:
parent
f7e3e1f97a
commit
6a3922d330
39 changed files with 275 additions and 343 deletions
|
@ -300,7 +300,7 @@ bool ShowOpenDialogSync(const DialogSettings& settings,
|
|||
void OpenDialogCompletion(int chosen,
|
||||
NSOpenPanel* dialog,
|
||||
bool security_scoped_bookmarks,
|
||||
electron::util::Promise promise) {
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
dict.Set("canceled", true);
|
||||
|
@ -308,7 +308,7 @@ void OpenDialogCompletion(int chosen,
|
|||
#if defined(MAS_BUILD)
|
||||
dict.Set("bookmarks", std::vector<std::string>());
|
||||
#endif
|
||||
promise.Resolve(dict.GetHandle());
|
||||
promise.Resolve(dict);
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
dict.Set("canceled", false);
|
||||
|
@ -324,12 +324,12 @@ void OpenDialogCompletion(int chosen,
|
|||
ReadDialogPaths(dialog, &paths);
|
||||
dict.Set("filePaths", paths);
|
||||
#endif
|
||||
promise.Resolve(dict.GetHandle());
|
||||
promise.Resolve(dict);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowOpenDialog(const DialogSettings& settings,
|
||||
electron::util::Promise promise) {
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
NSOpenPanel* dialog = [NSOpenPanel openPanel];
|
||||
|
||||
SetupDialog(dialog, settings);
|
||||
|
@ -339,7 +339,7 @@ void ShowOpenDialog(const DialogSettings& settings,
|
|||
// and pass it to the completion handler.
|
||||
bool security_scoped_bookmarks = settings.security_scoped_bookmarks;
|
||||
|
||||
__block electron::util::Promise p = std::move(promise);
|
||||
__block electron::util::Promise<mate::Dictionary> p = std::move(promise);
|
||||
|
||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||
settings.force_detached) {
|
||||
|
@ -377,7 +377,7 @@ bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path) {
|
|||
void SaveDialogCompletion(int chosen,
|
||||
NSSavePanel* dialog,
|
||||
bool security_scoped_bookmarks,
|
||||
electron::util::Promise promise) {
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
dict.Set("canceled", true);
|
||||
|
@ -397,11 +397,11 @@ void SaveDialogCompletion(int chosen,
|
|||
}
|
||||
#endif
|
||||
}
|
||||
promise.Resolve(dict.GetHandle());
|
||||
promise.Resolve(dict);
|
||||
}
|
||||
|
||||
void ShowSaveDialog(const DialogSettings& settings,
|
||||
electron::util::Promise promise) {
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
NSSavePanel* dialog = [NSSavePanel savePanel];
|
||||
|
||||
SetupDialog(dialog, settings);
|
||||
|
@ -412,7 +412,7 @@ void ShowSaveDialog(const DialogSettings& settings,
|
|||
// and pass it to the completion handler.
|
||||
bool security_scoped_bookmarks = settings.security_scoped_bookmarks;
|
||||
|
||||
__block electron::util::Promise p = std::move(promise);
|
||||
__block electron::util::Promise<mate::Dictionary> p = std::move(promise);
|
||||
|
||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||
settings.force_detached) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue