OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
6 #define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_nsobject.h" | 12 #include "base/memory/scoped_nsobject.h" |
13 #include "chrome/browser/ui/constrained_window.h" | 13 #include "chrome/browser/ui/constrained_window.h" |
14 | 14 |
15 @class BrowserWindowController; | 15 class ConstrainedWindowMac; |
16 @class GTMWindowSheetController; | 16 @class GTMWindowSheetController; |
17 @class NSView; | 17 @class NSView; |
18 @class NSWindow; | 18 @class NSWindow; |
19 class TabContents; | 19 class TabContents; |
20 | 20 |
| 21 // Window controllers that allow hosting constrained windows should |
| 22 // implement this protocol. |
| 23 @protocol ConstrainedWindowSupport |
| 24 |
| 25 // Requests that |window| is opened as a per-tab sheet to the current tab. |
| 26 - (void)attachConstrainedWindow:(ConstrainedWindowMac*)window; |
| 27 |
| 28 // Closes the tab sheet |window| and potentially shows the next sheet in the |
| 29 // tab's sheet queue. |
| 30 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; |
| 31 |
| 32 // Returns NO if constrained windows cannot be attached to this window. |
| 33 - (BOOL)canAttachConstrainedWindow; |
| 34 |
| 35 @end |
| 36 |
21 // Base class for constrained dialog delegates. Never inherit from this | 37 // Base class for constrained dialog delegates. Never inherit from this |
22 // directly. | 38 // directly. |
23 class ConstrainedWindowMacDelegate { | 39 class ConstrainedWindowMacDelegate { |
24 public: | 40 public: |
25 ConstrainedWindowMacDelegate() : is_sheet_open_(false) {} | 41 ConstrainedWindowMacDelegate() : is_sheet_open_(false) {} |
26 virtual ~ConstrainedWindowMacDelegate() {} | 42 virtual ~ConstrainedWindowMacDelegate() {} |
27 | 43 |
28 // Tells the delegate to either delete itself or set up a task to delete | 44 // Tells the delegate to either delete itself or set up a task to delete |
29 // itself later. Note that you MUST close the sheet belonging to your delegate | 45 // itself later. Note that you MUST close the sheet belonging to your delegate |
30 // in this method. | 46 // in this method. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 virtual void ShowConstrainedWindow() OVERRIDE; | 133 virtual void ShowConstrainedWindow() OVERRIDE; |
118 virtual void CloseConstrainedWindow() OVERRIDE; | 134 virtual void CloseConstrainedWindow() OVERRIDE; |
119 | 135 |
120 // Returns the TabContents that constrains this Constrained Window. | 136 // Returns the TabContents that constrains this Constrained Window. |
121 TabContents* owner() const { return tab_contents_; } | 137 TabContents* owner() const { return tab_contents_; } |
122 | 138 |
123 // Returns the window's delegate. | 139 // Returns the window's delegate. |
124 ConstrainedWindowMacDelegate* delegate() { return delegate_; } | 140 ConstrainedWindowMacDelegate* delegate() { return delegate_; } |
125 | 141 |
126 // Makes the constrained window visible, if it is not yet visible. | 142 // Makes the constrained window visible, if it is not yet visible. |
127 void Realize(BrowserWindowController* controller); | 143 void Realize(NSWindowController<ConstrainedWindowSupport>* controller); |
128 | 144 |
129 private: | 145 private: |
130 friend class ConstrainedWindow; | 146 friend class ConstrainedWindow; |
131 | 147 |
132 // The TabContents that owns and constrains this ConstrainedWindow. | 148 // The TabContents that owns and constrains this ConstrainedWindow. |
133 TabContents* tab_contents_; | 149 TabContents* tab_contents_; |
134 | 150 |
135 // Delegate that provides the contents of this constrained window. | 151 // Delegate that provides the contents of this constrained window. |
136 ConstrainedWindowMacDelegate* delegate_; | 152 ConstrainedWindowMacDelegate* delegate_; |
137 | 153 |
138 // Controller of the window that contains this sheet. | 154 // Controller of the window that contains this sheet. |
139 BrowserWindowController* controller_; | 155 NSWindowController<ConstrainedWindowSupport>* controller_; |
140 | 156 |
141 // Stores if |ShowConstrainedWindow()| was called. | 157 // Stores if |ShowConstrainedWindow()| was called. |
142 bool should_be_visible_; | 158 bool should_be_visible_; |
143 | 159 |
144 // True when CloseConstrainedWindow has been called. | 160 // True when CloseConstrainedWindow has been called. |
145 bool closing_; | 161 bool closing_; |
146 | 162 |
147 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); | 163 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); |
148 }; | 164 }; |
149 | 165 |
150 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 166 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
OLD | NEW |