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

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

Issue 10534093: TabContentsWrapper -> TabContents, part 37. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/ui/cocoa/tab_modal_confirm_dialog_mac.h" 5 #include "chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h"
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #include "chrome/browser/ui/browser_dialogs.h" 8 #include "chrome/browser/ui/browser_dialogs.h"
9 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 9 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "ui/base/l10n/l10n_util_mac.h" 11 #include "ui/base/l10n/l10n_util_mac.h"
12 #include "ui/gfx/image/image.h" 12 #include "ui/gfx/image/image.h"
13 13
14 // The delegate of the NSAlert used to display the dialog. Forwards the alert's 14 // The delegate of the NSAlert used to display the dialog. Forwards the alert's
15 // completion event to the C++ class |TabModalConfirmDialogDelegate|. 15 // completion event to the C++ class |TabModalConfirmDialogDelegate|.
16 @interface TabModalConfirmDialogMacBridge : NSObject { 16 @interface TabModalConfirmDialogMacBridge : NSObject {
17 TabModalConfirmDialogDelegate* delegate_; // weak 17 TabModalConfirmDialogDelegate* delegate_; // weak
18 } 18 }
19 - (id)initWithDelegate:(TabModalConfirmDialogDelegate*)delegate; 19 - (id)initWithDelegate:(TabModalConfirmDialogDelegate*)delegate;
20 - (void)alertDidEnd:(NSAlert*)alert 20 - (void)alertDidEnd:(NSAlert*)alert
(...skipping 17 matching lines...) Expand all
38 } else { 38 } else {
39 delegate_->Cancel(); 39 delegate_->Cancel();
40 } 40 }
41 } 41 }
42 @end 42 @end
43 43
44 namespace browser { 44 namespace browser {
45 45
46 // Declared in browser_dialogs.h so others don't have to depend on our header. 46 // Declared in browser_dialogs.h so others don't have to depend on our header.
47 void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate, 47 void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate,
48 TabContentsWrapper* wrapper) { 48 TabContents* tab_contents) {
49 // Deletes itself when closed. 49 // Deletes itself when closed.
50 new TabModalConfirmDialogMac(delegate, wrapper); 50 new TabModalConfirmDialogMac(delegate, tab_contents);
51 } 51 }
52 52
53 } 53 }
54 54
55 TabModalConfirmDialogMac::TabModalConfirmDialogMac( 55 TabModalConfirmDialogMac::TabModalConfirmDialogMac(
56 TabModalConfirmDialogDelegate* delegate, 56 TabModalConfirmDialogDelegate* delegate,
57 TabContentsWrapper* wrapper) 57 TabContents* tab_contents)
58 : ConstrainedWindowMacDelegateSystemSheet( 58 : ConstrainedWindowMacDelegateSystemSheet(
59 [[[TabModalConfirmDialogMacBridge alloc] initWithDelegate:delegate] 59 [[[TabModalConfirmDialogMacBridge alloc] initWithDelegate:delegate]
60 autorelease], 60 autorelease],
61 @selector(alertDidEnd:returnCode:contextInfo:)), 61 @selector(alertDidEnd:returnCode:contextInfo:)),
62 delegate_(delegate) { 62 delegate_(delegate) {
63 scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]); 63 scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]);
64 [alert setMessageText: 64 [alert setMessageText:
65 l10n_util::FixUpWindowsStyleLabel(delegate->GetTitle())]; 65 l10n_util::FixUpWindowsStyleLabel(delegate->GetTitle())];
66 [alert setInformativeText: 66 [alert setInformativeText:
67 l10n_util::FixUpWindowsStyleLabel(delegate->GetMessage())]; 67 l10n_util::FixUpWindowsStyleLabel(delegate->GetMessage())];
68 [alert addButtonWithTitle: 68 [alert addButtonWithTitle:
69 l10n_util::FixUpWindowsStyleLabel(delegate->GetAcceptButtonTitle())]; 69 l10n_util::FixUpWindowsStyleLabel(delegate->GetAcceptButtonTitle())];
70 [alert addButtonWithTitle: 70 [alert addButtonWithTitle:
71 l10n_util::FixUpWindowsStyleLabel(delegate->GetCancelButtonTitle())]; 71 l10n_util::FixUpWindowsStyleLabel(delegate->GetCancelButtonTitle())];
72 gfx::Image* icon = delegate->GetIcon(); 72 gfx::Image* icon = delegate->GetIcon();
73 if (icon) 73 if (icon)
74 [alert setIcon:icon->ToNSImage()]; 74 [alert setIcon:icon->ToNSImage()];
75 75
76 set_sheet(alert); 76 set_sheet(alert);
77 77
78 delegate->set_window(new ConstrainedWindowMac(wrapper, this)); 78 delegate->set_window(new ConstrainedWindowMac(tab_contents, this));
79 } 79 }
80 80
81 TabModalConfirmDialogMac::~TabModalConfirmDialogMac() { 81 TabModalConfirmDialogMac::~TabModalConfirmDialogMac() {
82 NSWindow* window = [(NSAlert*)sheet() window]; 82 NSWindow* window = [(NSAlert*)sheet() window];
83 if (window && is_sheet_open()) { 83 if (window && is_sheet_open()) {
84 [NSApp endSheet:window 84 [NSApp endSheet:window
85 returnCode:NSAlertSecondButtonReturn]; 85 returnCode:NSAlertSecondButtonReturn];
86 } 86 }
87 } 87 }
88 88
89 // "DeleteDelegate" refers to this class being a ConstrainedWindow delegate 89 // "DeleteDelegate" refers to this class being a ConstrainedWindow delegate
90 // and deleting itself, not to deleting the member variable |delegate_|. 90 // and deleting itself, not to deleting the member variable |delegate_|.
91 void TabModalConfirmDialogMac::DeleteDelegate() { 91 void TabModalConfirmDialogMac::DeleteDelegate() {
92 delete this; 92 delete this;
93 } 93 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h ('k') | chrome/browser/ui/cocoa/tabpose_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698