Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/ui/cocoa/repost_form_warning_mac.mm

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/cocoa/repost_form_warning_mac.h"
6
7 #include "base/memory/scoped_nsobject.h"
8 #include "chrome/browser/repost_form_warning_controller.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "grit/generated_resources.h"
11 #include "ui/base/l10n/l10n_util_mac.h"
12
13 // The delegate of the NSAlert used to display the dialog. Forwards the alert's
14 // completion event to the C++ class |RepostFormWarningController|.
15 @interface RepostDelegate : NSObject {
16 RepostFormWarningController* warning_; // weak
17 }
18 - (id)initWithWarning:(RepostFormWarningController*)warning;
19 - (void)alertDidEnd:(NSAlert*)alert
20 returnCode:(int)returnCode
21 contextInfo:(void*)contextInfo;
22 @end
23
24 @implementation RepostDelegate
25 - (id)initWithWarning:(RepostFormWarningController*)warning {
26 if ((self = [super init])) {
27 warning_ = warning;
28 }
29 return self;
30 }
31
32 - (void)alertDidEnd:(NSAlert*)alert
33 returnCode:(int)returnCode
34 contextInfo:(void*)contextInfo {
35 if (returnCode == NSAlertFirstButtonReturn) {
36 warning_->Continue();
37 } else {
38 warning_->Cancel();
39 }
40 }
41 @end
42
43 RepostFormWarningMac* RepostFormWarningMac::Create(NSWindow* parent,
44 TabContents* tab_contents) {
45 return new RepostFormWarningMac(
46 parent,
47 new RepostFormWarningController(tab_contents),
48 tab_contents);
49 }
50
51 RepostFormWarningMac::RepostFormWarningMac(
52 NSWindow* parent,
53 RepostFormWarningController* controller,
54 TabContents* tab_contents)
55 : ConstrainedWindowMacDelegateSystemSheet(
56 [[[RepostDelegate alloc] initWithWarning:controller]
57 autorelease],
58 @selector(alertDidEnd:returnCode:contextInfo:)),
59 controller_(controller),
60 tab_contents_(tab_contents) {
61 scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]);
62 [alert setMessageText:
63 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_TITLE)];
64 [alert setInformativeText:
65 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING)];
66 [alert addButtonWithTitle:
67 l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_RESEND)];
68 [alert addButtonWithTitle:
69 l10n_util::GetNSStringWithFixup(IDS_CANCEL)];
70
71 set_sheet(alert);
72
73 TabContentsWrapper* wrapper =
74 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
75 controller->set_window(new ConstrainedWindowMac(wrapper, this));
76 }
77
78 RepostFormWarningMac::~RepostFormWarningMac() {
79 NSWindow* window = [(NSAlert*)sheet() window];
80 if (window && is_sheet_open()) {
81 [NSApp endSheet:window
82 returnCode:NSAlertSecondButtonReturn];
83 }
84 }
85
86 void RepostFormWarningMac::DeleteDelegate() {
87 delete this;
88 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/repost_form_warning_mac.h ('k') | chrome/browser/ui/cocoa/tab_modal_dialog_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698