#include "atom/browser/native_window.h"
#include "base/callback.h"
+#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h"
+#include "skia/ext/skia_utils_mac.h"
@interface ModalDelegate : NSObject {
@private
int default_id,
const std::string& title,
const std::string& message,
- const std::string& detail) {
+ const std::string& detail,
+ const gfx::ImageSkia& icon) {
// Ignore the title; it's the window title on other platforms and ignorable.
NSAlert* alert = [[NSAlert alloc] init];
[alert setMessageText:base::SysUTF8ToNSString(message)];
[[ns_buttons objectAtIndex:default_id] setKeyEquivalent:@"\r"];
}
+ if (!icon.isNull()) {
+ NSImage* image = gfx::SkBitmapToNSImageWithColorSpace(
+ *icon.bitmap(), base::mac::GetGenericRGBColorSpace());
+ [alert setIcon:image];
+ }
+
return alert;
}
const gfx::ImageSkia& icon) {
NSAlert* alert = CreateNSAlert(
parent_window, type, buttons, default_id, title, message,
- detail);
+ detail, icon);
// Use runModal for synchronous alert without parent, since we don't have a
// window to wait for.
const MessageBoxCallback& callback) {
NSAlert* alert = CreateNSAlert(
parent_window, type, buttons, default_id, title, message,
- detail);
+ detail, icon);
ModalDelegate* delegate = [[ModalDelegate alloc] initWithCallback:callback
andAlert:alert
callEndModal:false];