| OLD | NEW |
| 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 #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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // beginSheetForWindow:... method. The window argument must be [NSNull null]. | 62 // beginSheetForWindow:... method. The window argument must be [NSNull null]. |
| 63 // | 63 // |
| 64 // The default implementation returns | 64 // The default implementation returns |
| 65 // [null window, delegate, didEndSelector, null contextInfo] | 65 // [null window, delegate, didEndSelector, null contextInfo] |
| 66 // Subclasses may override this if they show a system sheet which takes | 66 // Subclasses may override this if they show a system sheet which takes |
| 67 // different parameters. | 67 // different parameters. |
| 68 virtual NSArray* GetSheetParameters(id delegate, SEL didEndSelector); | 68 virtual NSArray* GetSheetParameters(id delegate, SEL didEndSelector); |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 virtual void RunSheet(GTMWindowSheetController* sheetController, | 71 virtual void RunSheet(GTMWindowSheetController* sheetController, |
| 72 NSView* view); | 72 NSView* view) OVERRIDE; |
| 73 scoped_nsobject<id> systemSheet_; | 73 scoped_nsobject<id> systemSheet_; |
| 74 scoped_nsobject<id> delegate_; | 74 scoped_nsobject<id> delegate_; |
| 75 SEL didEndSelector_; | 75 SEL didEndSelector_; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // Subclass this for a dialog delegate that displays a custom sheet, e.g. loaded | 78 // Subclass this for a dialog delegate that displays a custom sheet, e.g. loaded |
| 79 // from a nib file. | 79 // from a nib file. |
| 80 class ConstrainedWindowMacDelegateCustomSheet | 80 class ConstrainedWindowMacDelegateCustomSheet |
| 81 : public ConstrainedWindowMacDelegate { | 81 : public ConstrainedWindowMacDelegate { |
| 82 public: | 82 public: |
| 83 ConstrainedWindowMacDelegateCustomSheet(); | 83 ConstrainedWindowMacDelegateCustomSheet(); |
| 84 ConstrainedWindowMacDelegateCustomSheet(id delegate, SEL didEndSelector); | 84 ConstrainedWindowMacDelegateCustomSheet(id delegate, SEL didEndSelector); |
| 85 virtual ~ConstrainedWindowMacDelegateCustomSheet(); | 85 virtual ~ConstrainedWindowMacDelegateCustomSheet(); |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 // For when you need to delay initalization after the constructor call. | 88 // For when you need to delay initalization after the constructor call. |
| 89 void init(NSWindow* sheet, id delegate, SEL didEndSelector); | 89 void init(NSWindow* sheet, id delegate, SEL didEndSelector); |
| 90 void set_sheet(NSWindow* sheet); | 90 void set_sheet(NSWindow* sheet); |
| 91 NSWindow* sheet() { return customSheet_; } | 91 NSWindow* sheet() { return customSheet_; } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 virtual void RunSheet(GTMWindowSheetController* sheetController, | 94 virtual void RunSheet(GTMWindowSheetController* sheetController, |
| 95 NSView* view); | 95 NSView* view) OVERRIDE; |
| 96 scoped_nsobject<NSWindow> customSheet_; | 96 scoped_nsobject<NSWindow> customSheet_; |
| 97 scoped_nsobject<id> delegate_; | 97 scoped_nsobject<id> delegate_; |
| 98 SEL didEndSelector_; | 98 SEL didEndSelector_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 // Constrained window implementation for the Mac port. A constrained window | 101 // Constrained window implementation for the Mac port. A constrained window |
| 102 // is a per-tab sheet on OS X. | 102 // is a per-tab sheet on OS X. |
| 103 // | 103 // |
| 104 // Constrained windows work slightly differently on OS X than on the other | 104 // Constrained windows work slightly differently on OS X than on the other |
| 105 // platforms: | 105 // platforms: |
| 106 // 1. A constrained window is bound to both a tab and window on OS X. | 106 // 1. A constrained window is bound to both a tab and window on OS X. |
| 107 // 2. The delegate is responsible for closing the sheet again when it is | 107 // 2. The delegate is responsible for closing the sheet again when it is |
| 108 // deleted. | 108 // deleted. |
| 109 class ConstrainedWindowMac : public ConstrainedWindow { | 109 class ConstrainedWindowMac : public ConstrainedWindow { |
| 110 public: | 110 public: |
| 111 ConstrainedWindowMac(TabContentsWrapper* wrapper, | 111 ConstrainedWindowMac(TabContentsWrapper* wrapper, |
| 112 ConstrainedWindowMacDelegate* delegate); | 112 ConstrainedWindowMacDelegate* delegate); |
| 113 virtual ~ConstrainedWindowMac(); | 113 virtual ~ConstrainedWindowMac(); |
| 114 | 114 |
| 115 // Overridden from ConstrainedWindow: | 115 // Overridden from ConstrainedWindow: |
| 116 virtual void ShowConstrainedWindow(); | 116 virtual void ShowConstrainedWindow() OVERRIDE; |
| 117 virtual void CloseConstrainedWindow(); | 117 virtual void CloseConstrainedWindow() OVERRIDE; |
| 118 | 118 |
| 119 // Returns the TabContentsWrapper that constrains this Constrained Window. | 119 // Returns the TabContentsWrapper that constrains this Constrained Window. |
| 120 TabContentsWrapper* owner() const { return wrapper_; } | 120 TabContentsWrapper* owner() const { return wrapper_; } |
| 121 | 121 |
| 122 // Returns the window's delegate. | 122 // Returns the window's delegate. |
| 123 ConstrainedWindowMacDelegate* delegate() { return delegate_; } | 123 ConstrainedWindowMacDelegate* delegate() { return delegate_; } |
| 124 | 124 |
| 125 // Makes the constrained window visible, if it is not yet visible. | 125 // Makes the constrained window visible, if it is not yet visible. |
| 126 void Realize(BrowserWindowController* controller); | 126 void Realize(BrowserWindowController* controller); |
| 127 | 127 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 140 // Stores if |ShowConstrainedWindow()| was called. | 140 // Stores if |ShowConstrainedWindow()| was called. |
| 141 bool should_be_visible_; | 141 bool should_be_visible_; |
| 142 | 142 |
| 143 // True when CloseConstrainedWindow has been called. | 143 // True when CloseConstrainedWindow has been called. |
| 144 bool closing_; | 144 bool closing_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); | 146 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ | 149 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_MAC_H_ |
| OLD | NEW |