]> khamidou — GitHub mirrors - electron.git/commitdiff
dialog.showMessageBox doesn't require window as parameter any more.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 18 May 2013 02:47:06 +0000 (10:47 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 18 May 2013 02:47:06 +0000 (10:47 +0800)
browser/api/atom_api_dialog.cc
browser/api/lib/dialog.coffee
browser/message_box.h
browser/message_box_mac.mm

index 2fa01fd114f263c156642053e32af033e342e68e..6ba1e64d08de081a1c8f76b81fe98f028d209606 100644 (file)
@@ -28,34 +28,26 @@ base::FilePath V8ValueToFilePath(v8::Handle<v8::Value> path) {
 v8::Handle<v8::Value> ShowMessageBox(const v8::Arguments &args) {
   v8::HandleScope scope;
 
-  if (!args[0]->IsObject() ||  // window
-      !args[1]->IsNumber() ||  // type
-      !args[2]->IsArray() ||   // buttons
-      !args[3]->IsString() ||  // title
-      !args[4]->IsString() ||  // message
-      !args[5]->IsString())    // detail
+  if (!args[0]->IsNumber() ||  // type
+      !args[1]->IsArray() ||   // buttons
+      !args[2]->IsString() ||  // title
+      !args[3]->IsString() ||  // message
+      !args[4]->IsString())    // detail
     return node::ThrowTypeError("Bad argument");
 
-  Window* window = Window::Unwrap<Window>(args[0]->ToObject());
-  if (!window || !window->window())
-    return node::ThrowError("Invalid window");
-
-  gfx::NativeWindow owning_window = window->window()->GetNativeWindow();
-
-  MessageBoxType type = (MessageBoxType)(args[1]->IntegerValue());
+  MessageBoxType type = (MessageBoxType)(args[0]->IntegerValue());
 
   std::vector<std::string> buttons;
-  v8::Handle<v8::Array> v8_buttons = v8::Handle<v8::Array>::Cast(args[2]);
+  v8::Handle<v8::Array> v8_buttons = v8::Handle<v8::Array>::Cast(args[1]);
   for (uint32_t i = 0; i < v8_buttons->Length(); ++i)
     buttons.push_back(*v8::String::Utf8Value(v8_buttons->Get(i)));
 
-  std::string title(*v8::String::Utf8Value(args[3]));
-  std::string message(*v8::String::Utf8Value(args[4]));
-  std::string detail(*v8::String::Utf8Value(args[5]));
+  std::string title(*v8::String::Utf8Value(args[2]));
+  std::string message(*v8::String::Utf8Value(args[3]));
+  std::string detail(*v8::String::Utf8Value(args[4]));
 
-  int result = atom::ShowMessageBox(
-      owning_window, type, buttons, title, message, detail);
-  return v8::Integer::New(result);
+  int chosen = atom::ShowMessageBox(type, buttons, title, message, detail);
+  return scope.Close(v8::Integer::New(chosen));
 }
 
 FileDialog::FileDialog(v8::Handle<v8::Object> wrapper)
index f87884c9e580bcb2f798bc54b2d1bfe2705b60e6..afd98d9a0ba92355df338ec98feafc167d4c20b2 100644 (file)
@@ -68,10 +68,8 @@ module.exports =
   openMultiFiles: (args...) ->
     selectFileWrap args..., 4, 'Open Files'
 
-  showMessageBox: (window, options) ->
-    throw new TypeError('Need Window object') unless window.constructor is BrowserWindow
-
-    options = {} unless options?
+  showMessageBox: (options) ->
+    options = type: 'none' unless options?
     options.type = options.type ? 'none'
     options.type = messageBoxTypes.indexOf options.type
     throw new TypeError('Invalid message box type') unless options.type > -1
@@ -82,7 +80,7 @@ module.exports =
     options.message = options.message ? ''
     options.detail = options.detail ? ''
 
-    binding.showMessageBox window, options.type, options.buttons,
+    binding.showMessageBox options.type, options.buttons,
                            String(options.title),
                            String(options.message),
                            String(options.detail)
index 65ca6da3f9b8c8c0da8a9b6408012168a8faa91a..eef4180d6333fa27cd4b975b8b17e4010b3e4153 100644 (file)
@@ -8,8 +8,6 @@
 #include <string>
 #include <vector>
 
-#include "ui/gfx/native_widget_types.h"
-
 namespace atom {
 
 enum MessageBoxType {
@@ -18,8 +16,7 @@ enum MessageBoxType {
   MESSAGE_BOX_TYPE_WARNING
 };
 
-int ShowMessageBox(gfx::NativeWindow parent,
-                   MessageBoxType type,
+int ShowMessageBox(MessageBoxType type,
                    const std::vector<std::string>& buttons,
                    const std::string& title,
                    const std::string& message,
index d03fe0efa756ecac151b3a2b6c692d49f8f0450f..79dba234eaa15d45b15d5df949bb574c7da9504b 100644 (file)
@@ -10,8 +10,7 @@
 
 namespace atom {
 
-int ShowMessageBox(gfx::NativeWindow parent,
-                   MessageBoxType type,
+int ShowMessageBox(MessageBoxType type,
                    const std::vector<std::string>& buttons,
                    const std::string& title,
                    const std::string& message,