| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/platform_util.h" | 5 #include "chrome/browser/platform_util.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <CoreServices/CoreServices.h> | 9 #include <CoreServices/CoreServices.h> |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool IsVisible(gfx::NativeView view) { | 147 bool IsVisible(gfx::NativeView view) { |
| 148 // A reasonable approximation of how you'd expect this to behave. | 148 // A reasonable approximation of how you'd expect this to behave. |
| 149 return (view && | 149 return (view && |
| 150 ![view isHiddenOrHasHiddenAncestor] && | 150 ![view isHiddenOrHasHiddenAncestor] && |
| 151 [view window] && | 151 [view window] && |
| 152 [[view window] isVisible]); | 152 [[view window] isVisible]); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void SimpleErrorBox(gfx::NativeWindow parent, | |
| 156 const string16& title, | |
| 157 const string16& message) { | |
| 158 // Ignore the title; it's the window title on other platforms and ignorable. | |
| 159 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; | |
| 160 [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)]; | |
| 161 [alert setMessageText:base::SysUTF16ToNSString(message)]; | |
| 162 [alert setAlertStyle:NSWarningAlertStyle]; | |
| 163 [alert runModal]; | |
| 164 } | |
| 165 | |
| 166 bool SimpleYesNoBox(gfx::NativeWindow parent, | |
| 167 const string16& title, | |
| 168 const string16& message) { | |
| 169 // Ignore the title; it's the window title on other platforms and ignorable. | |
| 170 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; | |
| 171 [alert setMessageText:base::SysUTF16ToNSString(message)]; | |
| 172 [alert setAlertStyle:NSWarningAlertStyle]; | |
| 173 | |
| 174 [alert addButtonWithTitle: | |
| 175 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)]; | |
| 176 [alert addButtonWithTitle: | |
| 177 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)]; | |
| 178 | |
| 179 NSInteger result = [alert runModal]; | |
| 180 return result == NSAlertFirstButtonReturn; | |
| 181 } | |
| 182 | |
| 183 } // namespace platform_util | 155 } // namespace platform_util |
| OLD | NEW |