#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/ui/message_box.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
+#include "atom/common/native_mate_converters/image_converter.h"
#include "native_mate/callback.h"
#include "native_mate/dictionary.h"
void ShowMessageBox(int type,
const std::vector<std::string>& buttons,
- const std::string& title,
- const std::string& message,
- const std::string& detail,
+ const std::vector<std::string>& texts,
+ const gfx::ImageSkia& icon,
atom::NativeWindow* window,
mate::Arguments* args) {
+ // FIXME We are exceeding the parameters limit of base::Bind here, so we have
+ // to pass some parameters in an array. We should remove this once we have
+ // variadic template support in base::Bind.
+ const std::string& title = texts[0];
+ const std::string& message = texts[1];
+ const std::string& detail = texts[2];
+
v8::Handle<v8::Value> peek = args->PeekNext();
atom::MessageBoxCallback callback;
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
peek,
&callback)) {
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title,
- message, detail, callback);
+ message, detail, icon, callback);
} else {
int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type,
- buttons, title, message, detail);
+ buttons, title, message, detail, icon);
args->Return(chosen);
}
}
void ShowOpenDialog(const std::string& title,
const base::FilePath& default_path,
const file_dialog::Filters& filters,
+ const gfx::ImageSkia& icon,
int properties,
atom::NativeWindow* window,
mate::Arguments* args) {
void ShowSaveDialog(const std::string& title,
const base::FilePath& default_path,
const file_dialog::Filters& filters,
+ const gfx::ImageSkia& icon,
atom::NativeWindow* window,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();
options.title ?= ''
options.defaultPath ?= ''
options.filters ?= []
+ options.icon ?= null
wrappedCallback =
if typeof callback is 'function'
options.title ?= ''
options.defaultPath ?= ''
options.filters ?= []
+ options.icon ?= null
wrappedCallback =
if typeof callback is 'function'
options.title ?= ''
options.message ?= ''
options.detail ?= ''
+ options.icon ?= null
binding.showMessageBox options.type,
options.buttons,
- String(options.title),
- String(options.message),
- String(options.detail),
+ [options.title, options.message, options.detail],
+ options.icon,
window,
callback
#include "base/callback_forward.h"
#include "base/strings/string16.h"
+namespace gfx {
+class ImageSkia;
+}
+
namespace atom {
class NativeWindow;
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
- const std::string& detail);
+ const std::string& detail,
+ const gfx::ImageSkia& icon);
void ShowMessageBox(NativeWindow* parent_window,
MessageBoxType type,
const std::string& title,
const std::string& message,
const std::string& detail,
+ const gfx::ImageSkia& icon,
const MessageBoxCallback& callback);
// Like ShowMessageBox with simplest settings, but safe to call at very early
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
- const std::string& detail) {
+ const std::string& detail,
+ const gfx::ImageSkia& icon) {
NSAlert* alert = CreateNSAlert(
parent_window, type, buttons, title, message, detail);
const std::string& title,
const std::string& message,
const std::string& detail,
+ const gfx::ImageSkia& icon,
const MessageBoxCallback& callback) {
NSAlert* alert = CreateNSAlert(
parent_window, type, buttons, title, message, detail);
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
- const std::string& detail);
+ const std::string& detail,
+ const gfx::ImageSkia& icon);
virtual ~MessageDialog();
void Show(base::RunLoop* run_loop = NULL);
private:
// Overridden from views::WidgetDelegate:
- virtual base::string16 GetWindowTitle() const;
- virtual views::Widget* GetWidget() OVERRIDE;
- virtual const views::Widget* GetWidget() const OVERRIDE;
- virtual views::View* GetContentsView() OVERRIDE;
- virtual views::View* GetInitiallyFocusedView() OVERRIDE;
- virtual ui::ModalType GetModalType() const OVERRIDE;
- virtual views::NonClientFrameView* CreateNonClientFrameView(
- views::Widget* widget) OVERRIDE;
- virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
+ base::string16 GetWindowTitle() const override;
+ gfx::ImageSkia GetWindowAppIcon() override;
+ gfx::ImageSkia GetWindowIcon() override;
+ views::Widget* GetWidget() override;
+ const views::Widget* GetWidget() const override;
+ views::View* GetContentsView() override;
+ views::View* GetInitiallyFocusedView() override;
+ ui::ModalType GetModalType() const override;
+ views::NonClientFrameView* CreateNonClientFrameView(
+ views::Widget* widget) override;
+ views::ClientView* CreateClientView(views::Widget* widget) override;
// Overridden from views::View:
- virtual gfx::Size GetPreferredSize() const OVERRIDE;
- virtual void Layout() OVERRIDE;
- virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
+ gfx::Size GetPreferredSize() const override;
+ void Layout() override;
+ bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender,
- const ui::Event& event) OVERRIDE;
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+
+ gfx::ImageSkia icon_;
bool delete_on_close_;
int result_;
}
// views::ClientView:
- virtual bool CanClose() OVERRIDE {
+ bool CanClose() override {
dialog_->Close();
return false;
}
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
- const std::string& detail)
- : delete_on_close_(false),
+ const std::string& detail,
+ const gfx::ImageSkia& icon)
+ : icon_(icon),
+ delete_on_close_(false),
result_(-1),
title_(base::UTF8ToUTF16(title)),
parent_(parent_window),
////////////////////////////////////////////////////////////////////////////////
// MessageDialog, private:
+gfx::ImageSkia MessageDialog::GetWindowAppIcon() {
+ return icon_;
+}
+
+gfx::ImageSkia MessageDialog::GetWindowIcon() {
+ return icon_;
+}
+
base::string16 MessageDialog::GetWindowTitle() const {
return title_;
}
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
- const std::string& detail) {
+ const std::string& detail,
+ const gfx::ImageSkia& icon) {
MessageDialog dialog(parent_window, type, buttons, title, message, detail);
{
base::MessageLoop::ScopedNestableTaskAllower allow(
const std::string& title,
const std::string& message,
const std::string& detail,
+ const gfx::ImageSkia& icon,
const MessageBoxCallback& callback) {
// The dialog would be deleted when the dialog is closed.
MessageDialog* dialog = new MessageDialog(