]> khamidou — GitHub mirrors - electron.git/commitdiff
Add header for asynchronous version of ShowMessageBox.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 22 Sep 2013 09:11:09 +0000 (17:11 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 22 Sep 2013 09:11:09 +0000 (17:11 +0800)
browser/ui/message_box.h
browser/ui/message_box_mac.mm
browser/ui/message_box_win.cc

index dfe7198ba67cf60e19b87fb4e5b917f345a79f81..a538eea9b7f834bb6afa437dc6ed2db7c137380c 100644 (file)
@@ -8,6 +8,8 @@
 #include <string>
 #include <vector>
 
+#include "base/callback_forward.h"
+
 namespace atom {
 
 class NativeWindow;
@@ -18,6 +20,8 @@ enum MessageBoxType {
   MESSAGE_BOX_TYPE_WARNING
 };
 
+typedef base::Callback<void(int)> MessageBoxCallback;
+
 int ShowMessageBox(NativeWindow* parent_window,
                    MessageBoxType type,
                    const std::vector<std::string>& buttons,
@@ -25,6 +29,14 @@ int ShowMessageBox(NativeWindow* parent_window,
                    const std::string& message,
                    const std::string& detail);
 
+void ShowMessageBox(NativeWindow* parent_window,
+                    MessageBoxType type,
+                    const std::vector<std::string>& buttons,
+                    const std::string& title,
+                    const std::string& message,
+                    const std::string& detail,
+                    const MessageBoxCallback& callback);
+
 }  // namespace atom
 
 #endif  // BROWSER_UI_MESSAGE_BOX_H_
index c6fb14555b0b93370d58660481a67cbf8553d467..8da5a4002fec58fb86ed6205f9e312f9ac1e1da3 100644 (file)
@@ -6,6 +6,7 @@
 
 #import <Cocoa/Cocoa.h>
 
+#include "base/callback.h"
 #include "base/strings/sys_string_conversions.h"
 #include "browser/native_window.h"
 #include "browser/ui/nsalert_synchronous_sheet_mac.h"
@@ -46,4 +47,15 @@ int ShowMessageBox(NativeWindow* parent_window,
     return [alert runModal];
 }
 
+void ShowMessageBox(NativeWindow* parent_window,
+                    MessageBoxType type,
+                    const std::vector<std::string>& buttons,
+                    const std::string& title,
+                    const std::string& message,
+                    const std::string& detail,
+                    const MessageBoxCallback& callback) {
+  callback.Run(ShowMessageBox(
+      parent_window, type, buttons, title, message, detail));
+}
+
 }  // namespace atom
index 52181e407806d1aac75e75dba07c0d0c61eebcc5..99da31fabd8cfa621c351f193113b309803b4f1f 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "browser/ui/message_box.h"
 
+#include "base/callback.h"
 #include "base/message_loop.h"
 #include "base/run_loop.h"
 #include "base/string_util.h"
@@ -253,4 +254,15 @@ int ShowMessageBox(NativeWindow* parent_window,
   }
 }
 
+void ShowMessageBox(NativeWindow* parent_window,
+                    MessageBoxType type,
+                    const std::vector<std::string>& buttons,
+                    const std::string& title,
+                    const std::string& message,
+                    const std::string& detail,
+                    const MessageBoxCallback& callback) {
+  callback.Run(ShowMessageBox(
+      parent_window, type, buttons, title, message, detail));
+}
+
 }  // namespace atom