Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / simple_message_box_win.cc
blob1cea29357c5dfd28224bca897d291c24d5a6c359
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/simple_message_box.h"
7 #include "components/startup_metric_utils/startup_metric_utils.h"
8 #include "ui/base/win/message_box_win.h"
9 #include "ui/gfx/win/hwnd_util.h"
11 namespace chrome {
13 MessageBoxResult NativeShowMessageBox(HWND parent,
14 const base::string16& title,
15 const base::string16& message,
16 MessageBoxType type) {
17 UINT flags = MB_SETFOREGROUND;
18 if (type == MESSAGE_BOX_TYPE_QUESTION) {
19 flags |= MB_YESNO;
20 } else if (type == MESSAGE_BOX_TYPE_OK_CANCEL) {
21 flags |= MB_OKCANCEL;
22 } else {
23 flags |= MB_OK;
25 flags |= ((type == MESSAGE_BOX_TYPE_INFORMATION) ?
26 MB_ICONINFORMATION : MB_ICONWARNING);
27 int result = ui::MessageBox(parent, message, title, flags);
28 return (result == IDYES || result == IDOK) ?
29 MESSAGE_BOX_RESULT_YES : MESSAGE_BOX_RESULT_NO;
32 #if !defined(USE_AURA)
33 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
34 const base::string16& title,
35 const base::string16& message,
36 MessageBoxType type) {
37 startup_metric_utils::SetNonBrowserUIDisplayed();
39 if (!parent)
40 parent = gfx::GetWindowToParentTo(true);
42 return NativeShowMessageBox(parent, title, message, type);
44 #endif
46 } // namespace chrome