OLD | NEW |
1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 5 #ifndef CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
6 #define CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 6 #define CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 #include "chrome/browser/tab_contents/constrained_window.h" | 11 #include "chrome/browser/tab_contents/constrained_window.h" |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/logging.h" |
14 #include "base/scoped_nsobject.h" | 15 #include "base/scoped_nsobject.h" |
15 | 16 |
16 @class BrowserWindowController; | 17 @class BrowserWindowController; |
17 @class GTMWindowSheetController; | 18 @class GTMWindowSheetController; |
18 @class NSView; | 19 @class NSView; |
19 @class NSWindow; | 20 @class NSWindow; |
20 class TabContents; | 21 class TabContents; |
21 | 22 |
22 // Base class for constrained dialog delegates. Never inherit from this | 23 // Base class for constrained dialog delegates. Never inherit from this |
23 // directly. | 24 // directly. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 delegate_(nil), | 88 delegate_(nil), |
88 didEndSelector_(NULL) { } | 89 didEndSelector_(NULL) { } |
89 | 90 |
90 ConstrainedWindowMacDelegateCustomSheet(id delegate, SEL didEndSelector) | 91 ConstrainedWindowMacDelegateCustomSheet(id delegate, SEL didEndSelector) |
91 : customSheet_(nil), | 92 : customSheet_(nil), |
92 delegate_([delegate retain]), | 93 delegate_([delegate retain]), |
93 didEndSelector_(didEndSelector) { } | 94 didEndSelector_(didEndSelector) { } |
94 | 95 |
95 protected: | 96 protected: |
96 // For when you need to delay initalization after the constructor call. | 97 // For when you need to delay initalization after the constructor call. |
97 void init(NSWindow* sheet, id delegate, SEL didEndSelector); | 98 void init(NSWindow* sheet, id delegate, SEL didEndSelector) { |
| 99 DCHECK(!delegate_.get()); |
| 100 DCHECK(!didEndSelector_); |
| 101 customSheet_.reset([sheet retain]); |
| 102 delegate_.reset([delegate retain]); |
| 103 didEndSelector_ = didEndSelector; |
| 104 DCHECK(delegate_.get()); |
| 105 DCHECK(didEndSelector_); |
| 106 } |
98 void set_sheet(NSWindow* sheet) { customSheet_.reset([sheet retain]); } | 107 void set_sheet(NSWindow* sheet) { customSheet_.reset([sheet retain]); } |
99 NSWindow* sheet() { return customSheet_; } | 108 NSWindow* sheet() { return customSheet_; } |
100 | 109 |
101 private: | 110 private: |
102 virtual void RunSheet(GTMWindowSheetController* sheetController, | 111 virtual void RunSheet(GTMWindowSheetController* sheetController, |
103 NSView* view); | 112 NSView* view); |
104 scoped_nsobject<NSWindow> customSheet_; | 113 scoped_nsobject<NSWindow> customSheet_; |
105 scoped_nsobject<id> delegate_; | 114 scoped_nsobject<id> delegate_; |
106 SEL didEndSelector_; | 115 SEL didEndSelector_; |
107 }; | 116 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Controller of the window that contains this sheet. | 155 // Controller of the window that contains this sheet. |
147 BrowserWindowController* controller_; | 156 BrowserWindowController* controller_; |
148 | 157 |
149 // Stores if |ShowConstrainedWindow()| was called. | 158 // Stores if |ShowConstrainedWindow()| was called. |
150 bool should_be_visible_; | 159 bool should_be_visible_; |
151 | 160 |
152 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); | 161 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); |
153 }; | 162 }; |
154 | 163 |
155 #endif // CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 164 #endif // CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
| 165 |
OLD | NEW |