| 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 ConstrainedWindowMac; | 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 |
| 20 namespace content { |
| 21 class WebContents; |
| 22 } |
| 20 | 23 |
| 21 // Window controllers that allow hosting constrained windows should | 24 // Window controllers that allow hosting constrained windows should |
| 22 // implement this protocol. | 25 // implement this protocol. |
| 23 @protocol ConstrainedWindowSupport | 26 @protocol ConstrainedWindowSupport |
| 24 | 27 |
| 25 - (GTMWindowSheetController*)sheetController; | 28 - (GTMWindowSheetController*)sheetController; |
| 26 | 29 |
| 27 @end | 30 @end |
| 28 | 31 |
| 29 // Base class for constrained dialog delegates. Never inherit from this | 32 // Base class for constrained dialog delegates. Never inherit from this |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // Constrained window implementation for the Mac port. A constrained window | 113 // Constrained window implementation for the Mac port. A constrained window |
| 111 // is a per-tab sheet on OS X. | 114 // is a per-tab sheet on OS X. |
| 112 // | 115 // |
| 113 // Constrained windows work slightly differently on OS X than on the other | 116 // Constrained windows work slightly differently on OS X than on the other |
| 114 // platforms: | 117 // platforms: |
| 115 // 1. A constrained window is bound to both a tab and window on OS X. | 118 // 1. A constrained window is bound to both a tab and window on OS X. |
| 116 // 2. The delegate is responsible for closing the sheet again when it is | 119 // 2. The delegate is responsible for closing the sheet again when it is |
| 117 // deleted. | 120 // deleted. |
| 118 class ConstrainedWindowMac : public ConstrainedWindow { | 121 class ConstrainedWindowMac : public ConstrainedWindow { |
| 119 public: | 122 public: |
| 120 ConstrainedWindowMac(TabContents* tab_contents, | 123 ConstrainedWindowMac(content::WebContents* web_contents, |
| 121 ConstrainedWindowMacDelegate* delegate); | 124 ConstrainedWindowMacDelegate* delegate); |
| 122 virtual ~ConstrainedWindowMac(); | 125 virtual ~ConstrainedWindowMac(); |
| 123 | 126 |
| 124 // Overridden from ConstrainedWindow: | 127 // Overridden from ConstrainedWindow: |
| 125 virtual void ShowConstrainedWindow() OVERRIDE; | 128 virtual void ShowConstrainedWindow() OVERRIDE; |
| 126 virtual void CloseConstrainedWindow() OVERRIDE; | 129 virtual void CloseConstrainedWindow() OVERRIDE; |
| 127 virtual bool CanShowConstrainedWindow() OVERRIDE; | 130 virtual bool CanShowConstrainedWindow() OVERRIDE; |
| 128 | 131 |
| 129 // Returns the TabContents that constrains this Constrained Window. | 132 // Returns the WebContents that constrains this Constrained Window. |
| 130 TabContents* owner() const { return tab_contents_; } | 133 content::WebContents* owner() const { return web_contents_; } |
| 131 | 134 |
| 132 // Returns the window's delegate. | 135 // Returns the window's delegate. |
| 133 ConstrainedWindowMacDelegate* delegate() { return delegate_; } | 136 ConstrainedWindowMacDelegate* delegate() { return delegate_; } |
| 134 | 137 |
| 135 // Makes the constrained window visible, if it is not yet visible. | 138 // Makes the constrained window visible, if it is not yet visible. |
| 136 void Realize(NSWindowController<ConstrainedWindowSupport>* controller); | 139 void Realize(NSWindowController<ConstrainedWindowSupport>* controller); |
| 137 | 140 |
| 138 private: | 141 private: |
| 139 friend class ConstrainedWindow; | 142 friend class ConstrainedWindow; |
| 140 | 143 |
| 141 // The TabContents that owns and constrains this ConstrainedWindow. | 144 // The WebContents that owns and constrains this ConstrainedWindow. |
| 142 TabContents* tab_contents_; | 145 content::WebContents* web_contents_; |
| 143 | 146 |
| 144 // Delegate that provides the contents of this constrained window. | 147 // Delegate that provides the contents of this constrained window. |
| 145 ConstrainedWindowMacDelegate* delegate_; | 148 ConstrainedWindowMacDelegate* delegate_; |
| 146 | 149 |
| 147 // Controller of the window that contains this sheet. | 150 // Controller of the window that contains this sheet. |
| 148 NSWindowController<ConstrainedWindowSupport>* controller_; | 151 NSWindowController<ConstrainedWindowSupport>* controller_; |
| 149 | 152 |
| 150 // Stores if |ShowConstrainedWindow()| was called. | 153 // Stores if |ShowConstrainedWindow()| was called. |
| 151 bool should_be_visible_; | 154 bool should_be_visible_; |
| 152 | 155 |
| 153 // True when CloseConstrainedWindow has been called. | 156 // True when CloseConstrainedWindow has been called. |
| 154 bool closing_; | 157 bool closing_; |
| 155 | 158 |
| 156 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); | 159 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); |
| 157 }; | 160 }; |
| 158 | 161 |
| 159 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 162 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
| OLD | NEW |