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/repost_form_warning_mac.h" | 5 #include "chrome/browser/cocoa/repost_form_warning_mac.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/tab_contents/navigation_controller.h" | 9 #include "chrome/browser/tab_contents/navigation_controller.h" |
10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
12 | 12 |
| 13 // The delegate of the NSAlert used to display the dialog. Forwards the alert's |
| 14 // completion event to the C++ class |RepostFormWarningMac|. |
| 15 @interface RepostDelegate : NSObject { |
| 16 RepostFormWarningMac* warning_; // weak, owns us. |
| 17 } |
| 18 - (id)initWithWarning:(RepostFormWarningMac*)warning; |
| 19 - (void)alertDidEnd:(NSAlert*)alert |
| 20 returnCode:(int)returnCode |
| 21 contextInfo:(void*)contextInfo; |
| 22 @end |
| 23 |
13 @implementation RepostDelegate | 24 @implementation RepostDelegate |
14 - (id)initWithWarning:(RepostFormWarningMac*)warning { | 25 - (id)initWithWarning:(RepostFormWarningMac*)warning { |
15 if ((self = [super init])) { | 26 if ((self = [super init])) { |
16 warning_ = warning; | 27 warning_ = warning; |
17 } | 28 } |
18 return self; | 29 return self; |
19 } | 30 } |
20 | 31 |
21 - (void)alertDidEnd:(NSAlert*)alert | 32 - (void)alertDidEnd:(NSAlert*)alert |
22 returnCode:(int)returnCode | 33 returnCode:(int)returnCode |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 [NSApp endSheet:[alert_ window] returnCode:NSAlertSecondButtonReturn]; | 95 [NSApp endSheet:[alert_ window] returnCode:NSAlertSecondButtonReturn]; |
85 } | 96 } |
86 } | 97 } |
87 | 98 |
88 void RepostFormWarningMac::Destroy() { | 99 void RepostFormWarningMac::Destroy() { |
89 if (alert_) { | 100 if (alert_) { |
90 alert_.reset(NULL); | 101 alert_.reset(NULL); |
91 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 102 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
92 } | 103 } |
93 } | 104 } |
OLD | NEW |