| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/simple_message_box.h" | 5 #include "chrome/browser/ui/simple_message_box.h" |
| 6 | 6 |
| 7 #include "chrome/common/startup_metric_utils.h" | 7 #include "chrome/common/startup_metric_utils.h" |
| 8 #include "ui/base/win/hwnd_util.h" |
| 8 #include "ui/base/win/message_box_win.h" | 9 #include "ui/base/win/message_box_win.h" |
| 9 | 10 |
| 10 namespace chrome { | 11 namespace chrome { |
| 11 | 12 |
| 12 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, | 13 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, |
| 13 const string16& title, | 14 const string16& title, |
| 14 const string16& message, | 15 const string16& message, |
| 15 MessageBoxType type) { | 16 MessageBoxType type) { |
| 16 startup_metric_utils::SetNonBrowserUIDisplayed(); | 17 startup_metric_utils::SetNonBrowserUIDisplayed(); |
| 17 | 18 |
| 19 if (!parent) |
| 20 parent = ui::GetWindowToParentTo(true); |
| 21 |
| 18 UINT flags = MB_SETFOREGROUND; | 22 UINT flags = MB_SETFOREGROUND; |
| 19 flags |= ((type == MESSAGE_BOX_TYPE_QUESTION) ? MB_YESNO : MB_OK); | 23 flags |= ((type == MESSAGE_BOX_TYPE_QUESTION) ? MB_YESNO : MB_OK); |
| 20 flags |= ((type == MESSAGE_BOX_TYPE_INFORMATION) ? | 24 flags |= ((type == MESSAGE_BOX_TYPE_INFORMATION) ? |
| 21 MB_ICONINFORMATION : MB_ICONWARNING); | 25 MB_ICONINFORMATION : MB_ICONWARNING); |
| 22 return (ui::MessageBox(parent, message, title, flags) == IDNO) ? | 26 return (ui::MessageBox(parent, message, title, flags) == IDNO) ? |
| 23 MESSAGE_BOX_RESULT_NO : MESSAGE_BOX_RESULT_YES; | 27 MESSAGE_BOX_RESULT_NO : MESSAGE_BOX_RESULT_YES; |
| 24 } | 28 } |
| 25 | 29 |
| 26 } // namespace chrome | 30 } // namespace chrome |
| OLD | NEW |