Chromium Code Reviews| Index: chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm |
| diff --git a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm |
| index 47664811ee8636d1864ee55de20306426d38a261..25822c393a9f8d7bf1df67c4b9351732bdd42584 100644 |
| --- a/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm |
| +++ b/chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.mm |
| @@ -16,6 +16,20 @@ |
| #include "ui/base/l10n/l10n_util_mac.h" |
| #include "ui/gfx/image/image.h" |
| +// static |
| +TabModalConfirmDialog* TabModalConfirmDialog::Create( |
| + TabModalConfirmDialogDelegate* delegate, |
| + TabContents* tab_contents) { |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableFramelessConstrainedDialogs)) { |
| + // Deletes itself when closed. |
| + return new TabModalConfirmDialogMac2(delegate, tab_contents); |
| + } else { |
|
Peter Kasting
2012/09/25 21:08:42
Nit: No else after return
|
| + // Deletes itself when closed. |
| + return new TabModalConfirmDialogMac(delegate, tab_contents); |
| + } |
| +} |
| + |
| // The delegate of the NSAlert used to display the dialog. Forwards the alert's |
| // completion event to the C++ class |TabModalConfirmDialogDelegate|. |
| @interface TabModalConfirmDialogMacBridge : NSObject { |
| @@ -46,23 +60,6 @@ |
| } |
| @end |
| -namespace chrome { |
| - |
| -// Declared in browser_dialogs.h so others don't have to depend on our header. |
| -void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate, |
| - TabContents* tab_contents) { |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableFramelessConstrainedDialogs)) { |
| - // Deletes itself when closed. |
| - new TabModalConfirmDialogMac2(delegate, tab_contents); |
| - } else { |
| - // Deletes itself when closed. |
| - new TabModalConfirmDialogMac(delegate, tab_contents); |
| - } |
| -} |
| - |
| -} // namespace chrome |
| - |
| TabModalConfirmDialogMac::TabModalConfirmDialogMac( |
| TabModalConfirmDialogDelegate* delegate, |
| TabContents* tab_contents) |
| @@ -90,11 +87,7 @@ TabModalConfirmDialogMac::TabModalConfirmDialogMac( |
| } |
| TabModalConfirmDialogMac::~TabModalConfirmDialogMac() { |
| - NSWindow* window = [(NSAlert*)sheet() window]; |
| - if (window && is_sheet_open()) { |
| - [NSApp endSheet:window |
| - returnCode:NSAlertSecondButtonReturn]; |
| - } |
| + CancelTabModalDialog(); |
| } |
| // "DeleteDelegate" refers to this class being a ConstrainedWindow delegate |
| @@ -103,6 +96,23 @@ void TabModalConfirmDialogMac::DeleteDelegate() { |
| delete this; |
| } |
| +void TabModalConfirmDialogMac::AcceptTabModalDialog() { |
| + NSWindow* window = [(NSAlert*)sheet() window]; |
| + if (window && is_sheet_open()) { |
| + [NSApp endSheet:window |
| + returnCode:NSAlertFirstButtonReturn]; |
| + } |
| +} |
| + |
| +void TabModalConfirmDialogMac::CancelTabModalDialog() { |
| + NSWindow* window = [(NSAlert*)sheet() window]; |
| + if (window && is_sheet_open()) { |
| + [NSApp endSheet:window |
| + returnCode:NSAlertSecondButtonReturn]; |
| + } |
| +} |
| + |
| + |
| @interface TabModalConfirmDialogMacBridge2 : NSObject { |
| TabModalConfirmDialogDelegate* delegate_; // weak |
| } |
| @@ -160,3 +170,9 @@ TabModalConfirmDialogMac2::TabModalConfirmDialogMac2( |
| TabModalConfirmDialogMac2::~TabModalConfirmDialogMac2() { |
| } |
| + |
| +void TabModalConfirmDialogMac2::AcceptTabModalDialog() { |
| +} |
| + |
| +void TabModalConfirmDialogMac2::CancelTabModalDialog() { |
| +} |