Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / simple_message_box_mac.mm
blob767c963df23b7f26c7232de25fe2f7c4a5c223b8
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 #import <Cocoa/Cocoa.h>
9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "components/startup_metric_utils/startup_metric_utils.h"
12 #include "ui/base/l10n/l10n_util_mac.h"
14 namespace chrome {
16 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
17                                 const base::string16& title,
18                                 const base::string16& message,
19                                 MessageBoxType type) {
20   if (type == MESSAGE_BOX_TYPE_OK_CANCEL)
21     NOTIMPLEMENTED();
23   startup_metric_utils::SetNonBrowserUIDisplayed();
25   // Ignore the title; it's the window title on other platforms and ignorable.
26   NSAlert* alert = [[[NSAlert alloc] init] autorelease];
27   [alert setMessageText:base::SysUTF16ToNSString(message)];
28   NSUInteger style = (type == MESSAGE_BOX_TYPE_INFORMATION) ?
29       NSInformationalAlertStyle : NSWarningAlertStyle;
30   [alert setAlertStyle:style];
31   if (type == MESSAGE_BOX_TYPE_QUESTION) {
32     [alert addButtonWithTitle:
33         l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)];
34     [alert addButtonWithTitle:
35         l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)];
36   } else {
37     [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)];
38   }
39   NSInteger result = [alert runModal];
40   return (result == NSAlertSecondButtonReturn) ?
41       MESSAGE_BOX_RESULT_NO : MESSAGE_BOX_RESULT_YES;
44 }  // namespace chrome