OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #include "chrome/browser/simple_message_box.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "base/sys_string_conversions.h" |
| 10 #include "grit/generated_resources.h" |
| 11 #include "ui/base/l10n/l10n_util_mac.h" |
| 12 |
| 13 namespace browser { |
| 14 |
| 15 void ShowErrorBox(gfx::NativeWindow parent, |
| 16 const string16& title, |
| 17 const string16& message) { |
| 18 // Ignore the title; it's the window title on other platforms and ignorable. |
| 19 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; |
| 20 [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)]; |
| 21 [alert setMessageText:base::SysUTF16ToNSString(message)]; |
| 22 [alert setAlertStyle:NSWarningAlertStyle]; |
| 23 [alert runModal]; |
| 24 } |
| 25 |
| 26 bool ShowYesNoBox(gfx::NativeWindow parent, |
| 27 const string16& title, |
| 28 const string16& message) { |
| 29 // Ignore the title; it's the window title on other platforms and ignorable. |
| 30 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; |
| 31 [alert setMessageText:base::SysUTF16ToNSString(message)]; |
| 32 [alert setAlertStyle:NSWarningAlertStyle]; |
| 33 |
| 34 [alert addButtonWithTitle: |
| 35 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)]; |
| 36 [alert addButtonWithTitle: |
| 37 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)]; |
| 38 |
| 39 NSInteger result = [alert runModal]; |
| 40 return result == NSAlertFirstButtonReturn; |
| 41 } |
| 42 |
| 43 } // namespace browser |
OLD | NEW |