Show user's icon when specified
This commit is contained in:
parent
6fb8b2ce4f
commit
989351a41d
1 changed files with 24 additions and 13 deletions
|
@ -11,7 +11,9 @@
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/threading/thread.h"
|
#include "base/threading/thread.h"
|
||||||
|
#include "base/win/scoped_gdi_object.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
|
#include "ui/gfx/icon_util.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -27,7 +29,8 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
const base::string16& title,
|
const base::string16& title,
|
||||||
const base::string16& message,
|
const base::string16& message,
|
||||||
const base::string16& detail) {
|
const base::string16& detail,
|
||||||
|
const gfx::ImageSkia& icon) {
|
||||||
std::vector<TASKDIALOG_BUTTON> dialog_buttons;
|
std::vector<TASKDIALOG_BUTTON> dialog_buttons;
|
||||||
for (size_t i = 0; i < buttons.size(); ++i)
|
for (size_t i = 0; i < buttons.size(); ++i)
|
||||||
dialog_buttons.push_back({i + kIDStart, buttons[i].c_str()});
|
dialog_buttons.push_back({i + kIDStart, buttons[i].c_str()});
|
||||||
|
@ -45,6 +48,12 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||||
config.pButtons = &dialog_buttons.front();
|
config.pButtons = &dialog_buttons.front();
|
||||||
config.cButtons = dialog_buttons.size();
|
config.cButtons = dialog_buttons.size();
|
||||||
|
|
||||||
|
base::win::ScopedHICON hicon;
|
||||||
|
if (!icon.isNull()) {
|
||||||
|
hicon.Set(IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()));
|
||||||
|
config.dwFlags |= TDF_USE_HICON_MAIN;
|
||||||
|
config.hMainIcon = hicon.Get();
|
||||||
|
} else {
|
||||||
// Show icon according to dialog's type.
|
// Show icon according to dialog's type.
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MESSAGE_BOX_TYPE_INFORMATION:
|
case MESSAGE_BOX_TYPE_INFORMATION:
|
||||||
|
@ -57,6 +66,7 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||||
config.pszMainIcon = TD_ERROR_ICON;
|
config.pszMainIcon = TD_ERROR_ICON;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If "detail" is empty then don't make message hilighted.
|
// If "detail" is empty then don't make message hilighted.
|
||||||
if (detail.empty()) {
|
if (detail.empty()) {
|
||||||
|
@ -117,7 +127,8 @@ int ShowMessageBox(NativeWindow* parent,
|
||||||
cancel_id,
|
cancel_id,
|
||||||
base::UTF8ToUTF16(title),
|
base::UTF8ToUTF16(title),
|
||||||
base::UTF8ToUTF16(message),
|
base::UTF8ToUTF16(message),
|
||||||
base::UTF8ToUTF16(detail));
|
base::UTF8ToUTF16(detail),
|
||||||
|
icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowMessageBox(NativeWindow* parent,
|
void ShowMessageBox(NativeWindow* parent,
|
||||||
|
|
Loading…
Reference in a new issue