OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_nsobject.h" |
8 #include "chrome/browser/repost_form_warning_controller.h" | 9 #include "chrome/browser/repost_form_warning_controller.h" |
9 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
10 | 11 |
11 // The delegate of the NSAlert used to display the dialog. Forwards the alert's | 12 // The delegate of the NSAlert used to display the dialog. Forwards the alert's |
12 // completion event to the C++ class |RepostFormWarningController|. | 13 // completion event to the C++ class |RepostFormWarningController|. |
13 @interface RepostDelegate : NSObject { | 14 @interface RepostDelegate : NSObject { |
14 RepostFormWarningController* warning_; // weak | 15 RepostFormWarningController* warning_; // weak |
15 } | 16 } |
16 - (id)initWithWarning:(RepostFormWarningController*)warning; | 17 - (id)initWithWarning:(RepostFormWarningController*)warning; |
17 - (void)alertDidEnd:(NSAlert*)alert | 18 - (void)alertDidEnd:(NSAlert*)alert |
(...skipping 26 matching lines...) Expand all Loading... |
44 parent, | 45 parent, |
45 new RepostFormWarningController(tab_contents)); | 46 new RepostFormWarningController(tab_contents)); |
46 } | 47 } |
47 | 48 |
48 RepostFormWarningMac::RepostFormWarningMac( | 49 RepostFormWarningMac::RepostFormWarningMac( |
49 NSWindow* parent, | 50 NSWindow* parent, |
50 RepostFormWarningController* controller) | 51 RepostFormWarningController* controller) |
51 : ConstrainedWindowMacDelegateSystemSheet( | 52 : ConstrainedWindowMacDelegateSystemSheet( |
52 [[[RepostDelegate alloc] initWithWarning:controller] | 53 [[[RepostDelegate alloc] initWithWarning:controller] |
53 autorelease], | 54 autorelease], |
54 @selector(alertDidEnd:returnCode:contextInfo:)) { | 55 @selector(alertDidEnd:returnCode:contextInfo:)), |
| 56 controller_(controller) { |
55 scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]); | 57 scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]); |
56 [alert setMessageText: | 58 [alert setMessageText: |
57 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_TITLE)]; | 59 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_TITLE)]; |
58 [alert setInformativeText: | 60 [alert setInformativeText: |
59 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING)]; | 61 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING)]; |
60 [alert addButtonWithTitle: | 62 [alert addButtonWithTitle: |
61 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_RESEND)]; | 63 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_RESEND)]; |
62 [alert addButtonWithTitle: | 64 [alert addButtonWithTitle: |
63 l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; | 65 l10n_util::GetNSStringWithFixup(IDS_CANCEL)]; |
64 | 66 |
65 set_sheet(alert); | 67 set_sheet(alert); |
66 | 68 |
67 controller->Show(this); | 69 controller->Show(this); |
68 } | 70 } |
69 | 71 |
70 RepostFormWarningMac::~RepostFormWarningMac() { | 72 RepostFormWarningMac::~RepostFormWarningMac() { |
71 } | |
72 | |
73 void RepostFormWarningMac::DeleteDelegate() { | |
74 Dismiss(); | |
75 delete this; | |
76 } | |
77 | |
78 void RepostFormWarningMac::Dismiss() { | |
79 NSWindow* window = [(NSAlert*)sheet() window]; | 73 NSWindow* window = [(NSAlert*)sheet() window]; |
80 if (window && is_sheet_open()) { | 74 if (window && is_sheet_open()) { |
81 [NSApp endSheet:window | 75 [NSApp endSheet:window |
82 returnCode:NSAlertSecondButtonReturn]; | 76 returnCode:NSAlertSecondButtonReturn]; |
83 } | 77 } |
84 } | 78 } |
| 79 |
| 80 void RepostFormWarningMac::DeleteDelegate() { |
| 81 delete this; |
| 82 } |
OLD | NEW |