Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Unified Diff: chrome/browser/ui/views/simple_message_box_views.cc

Issue 172633004: Refactor Windows MessageBox fallback code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/simple_message_box.h ('k') | chrome/browser/ui/views/simple_message_box_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/simple_message_box_views.cc
diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc
index 3e85e682801ae7e81d72f5bfd0c917303d82f1f7..146924bbe072fb220fd23fad2839ae648f7767c7 100644
--- a/chrome/browser/ui/views/simple_message_box_views.cc
+++ b/chrome/browser/ui/views/simple_message_box_views.cc
@@ -23,7 +23,8 @@
#include "ui/views/window/dialog_delegate.h"
#if defined(OS_WIN)
-#include "chrome/browser/ui/views/simple_message_box_win.h"
+#include "ui/base/win/message_box_win.h"
+#include "ui/views/win/hwnd_util.h"
#endif
namespace chrome {
@@ -185,18 +186,38 @@ uint32_t SimpleMessageBoxViews::Dispatch(const base::NativeEvent& event) {
SimpleMessageBoxViews::~SimpleMessageBoxViews() {
}
+#if defined(OS_WIN)
+UINT GetMessageBoxFlagsFromType(MessageBoxType type) {
+ UINT flags = MB_SETFOREGROUND;
+ switch (type) {
+ case MESSAGE_BOX_TYPE_INFORMATION:
+ return flags | MB_OK | MB_ICONINFORMATION;
+ case MESSAGE_BOX_TYPE_WARNING:
+ return flags | MB_OK | MB_ICONWARNING;
+ case MESSAGE_BOX_TYPE_QUESTION:
+ return flags | MB_YESNO | MB_ICONQUESTION;
+ case MESSAGE_BOX_TYPE_OK_CANCEL:
+ return flags | MB_OKCANCEL | MB_ICONWARNING;
+ }
+ NOTREACHED();
+ return flags | MB_OK | MB_ICONWARNING;
+}
+#endif
+
MessageBoxResult ShowMessageBoxImpl(gfx::NativeWindow parent,
const base::string16& title,
const base::string16& message,
MessageBoxType type,
const base::string16& yes_text,
const base::string16& no_text) {
-
#if defined(OS_WIN)
- // If we're very early, we can't show a GPU-based dialog, so fallback to
- // plain Windows MessageBox.
- if (!ui::ContextFactory::GetInstance())
- return NativeShowMessageBox(NULL, title, message, type);
+ // GPU-based dialogs can't be used early on; fallback to a Windows MessageBox.
+ if (!ui::ContextFactory::GetInstance()) {
+ int result = ui::MessageBox(views::HWNDForNativeWindow(parent), message,
+ title, GetMessageBoxFlagsFromType(type));
+ return (result == IDYES || result == IDOK) ?
+ MESSAGE_BOX_RESULT_YES : MESSAGE_BOX_RESULT_NO;
+ }
#endif
scoped_refptr<SimpleMessageBoxViews> dialog(
« no previous file with comments | « chrome/browser/ui/simple_message_box.h ('k') | chrome/browser/ui/views/simple_message_box_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698