| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/download_request_dialog_delegate_mac.h" | 5 #include "chrome/browser/cocoa/download_request_dialog_delegate_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
| 10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 contextInfo:(void *)contextInfo; | 23 contextInfo:(void *)contextInfo; |
| 24 @end | 24 @end |
| 25 | 25 |
| 26 @implementation SheetCallback | 26 @implementation SheetCallback |
| 27 - (id)initWithTarget:(DownloadRequestDialogDelegateMac*)target { | 27 - (id)initWithTarget:(DownloadRequestDialogDelegateMac*)target { |
| 28 if ((self = [super init]) != nil) { | 28 if ((self = [super init]) != nil) { |
| 29 target_ = target; | 29 target_ = target; |
| 30 } | 30 } |
| 31 return self; | 31 return self; |
| 32 } | 32 } |
| 33 - (void) alertDidEnd:(NSAlert *)alert | 33 - (void)alertDidEnd:(NSAlert *)alert |
| 34 returnCode:(int)returnCode | 34 returnCode:(int)returnCode |
| 35 contextInfo:(void *)contextInfo { | 35 contextInfo:(void *)contextInfo { |
| 36 target_->SheetDidEnd(returnCode); | 36 target_->SheetDidEnd(returnCode); |
| 37 } | 37 } |
| 38 @end | 38 @end |
| 39 | 39 |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create( | 42 DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create( |
| 43 TabContents* tab, | 43 TabContents* tab, |
| 44 DownloadRequestManager::TabDownloadState* host) { | 44 DownloadRequestManager::TabDownloadState* host) { |
| 45 return new DownloadRequestDialogDelegateMac(tab, host); | 45 return new DownloadRequestDialogDelegateMac(tab, host); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 75 window_ = tab->CreateConstrainedDialog(this); | 75 window_ = tab->CreateConstrainedDialog(this); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void DownloadRequestDialogDelegateMac::CloseWindow() { | 78 void DownloadRequestDialogDelegateMac::CloseWindow() { |
| 79 window_->CloseConstrainedWindow(); | 79 window_->CloseConstrainedWindow(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void DownloadRequestDialogDelegateMac::DeleteDelegate() { | 82 void DownloadRequestDialogDelegateMac::DeleteDelegate() { |
| 83 if (is_sheet_open()) { | 83 if (is_sheet_open()) { |
| 84 // Close sheet if it's still open. | 84 // Close sheet if it's still open. |
| 85 [NSApp endSheet:[(NSAlert*)sheet() window]]; // class SheetDidEnd(). | 85 [NSApp endSheet:[(NSAlert*)sheet() window]]; // calls SheetDidEnd(). |
| 86 DCHECK(responded_); | 86 DCHECK(responded_); |
| 87 } | 87 } |
| 88 if (!responded_) { | 88 if (!responded_) { |
| 89 // Happens if the sheet was never visible | 89 // Happens if the sheet was never visible. |
| 90 responded_ = true; | 90 responded_ = true; |
| 91 DoCancel(); | 91 DoCancel(); |
| 92 } | 92 } |
| 93 DCHECK(!host_); | 93 DCHECK(!host_); |
| 94 delete this; | 94 delete this; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void DownloadRequestDialogDelegateMac::SheetDidEnd(int returnCode) { | 97 void DownloadRequestDialogDelegateMac::SheetDidEnd(int returnCode) { |
| 98 DCHECK(!responded_); | 98 DCHECK(!responded_); |
| 99 if (returnCode == NSAlertFirstButtonReturn) { | 99 if (returnCode == NSAlertFirstButtonReturn) { |
| 100 DoAccept(); | 100 DoAccept(); |
| 101 } else { | 101 } else { |
| 102 DoCancel(); | 102 DoCancel(); |
| 103 } | 103 } |
| 104 responded_ = true; | 104 responded_ = true; |
| 105 } | 105 } |
| OLD | NEW |