OLD | NEW |
1 // Copyright (c) 2009 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 #include "chrome/browser/cocoa/constrained_window_mac.h" | 5 #include "chrome/browser/cocoa/constrained_window_mac.h" |
6 | 6 |
7 #import "chrome/browser/cocoa/browser_window_controller.h" | 7 #import "chrome/browser/cocoa/browser_window_controller.h" |
8 #include "chrome/browser/tab_contents/tab_contents.h" | 8 #include "chrome/browser/tab_contents/tab_contents.h" |
9 #include "chrome/browser/tab_contents/tab_contents_view.h" | 9 #include "chrome/browser/tab_contents/tab_contents_view.h" |
10 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" | 10 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 void ConstrainedWindowMac::ShowConstrainedWindow() { | 63 void ConstrainedWindowMac::ShowConstrainedWindow() { |
64 should_be_visible_ = true; | 64 should_be_visible_ = true; |
65 // The TabContents only has a native window if it is currently visible. In | 65 // The TabContents only has a native window if it is currently visible. In |
66 // this case, open the sheet now. Else, Realize() will be called later, when | 66 // this case, open the sheet now. Else, Realize() will be called later, when |
67 // our tab becomes visible. | 67 // our tab becomes visible. |
68 NSWindow* browserWindow = owner_->view()->GetTopLevelNativeWindow(); | 68 NSWindow* browserWindow = owner_->view()->GetTopLevelNativeWindow(); |
69 NSWindowController* controller = [browserWindow windowController]; | 69 NSWindowController* controller = [browserWindow windowController]; |
70 if (controller != nil) { | 70 if (controller != nil) { |
71 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); | 71 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); |
72 Realize(static_cast<BrowserWindowController*>(controller)); | 72 BrowserWindowController* browser_controller = |
| 73 static_cast<BrowserWindowController*>(controller); |
| 74 if ([browser_controller canAttachConstrainedWindow]) |
| 75 Realize(browser_controller); |
73 } | 76 } |
74 } | 77 } |
75 | 78 |
76 void ConstrainedWindowMac::CloseConstrainedWindow() { | 79 void ConstrainedWindowMac::CloseConstrainedWindow() { |
77 // Note: controller_ can be `nil` here if the sheet was never realized. That's | 80 // Note: controller_ can be `nil` here if the sheet was never realized. That's |
78 // ok. | 81 // ok. |
79 [controller_ removeConstrainedWindow:this]; | 82 [controller_ removeConstrainedWindow:this]; |
80 delegate_->DeleteDelegate(); | 83 delegate_->DeleteDelegate(); |
81 owner_->WillClose(this); | 84 owner_->WillClose(this); |
82 | 85 |
83 delete this; | 86 delete this; |
84 } | 87 } |
85 | 88 |
86 void ConstrainedWindowMac::Realize(BrowserWindowController* controller) { | 89 void ConstrainedWindowMac::Realize(BrowserWindowController* controller) { |
87 if (!should_be_visible_) | 90 if (!should_be_visible_) |
88 return; | 91 return; |
89 | 92 |
90 if (controller_ != nil) { | 93 if (controller_ != nil) { |
91 DCHECK(controller_ == controller); | 94 DCHECK(controller_ == controller); |
92 return; | 95 return; |
93 } | 96 } |
94 DCHECK(controller != nil); | 97 DCHECK(controller != nil); |
95 | 98 |
96 // Remember the controller we're adding ourselves to, so that we can later | 99 // Remember the controller we're adding ourselves to, so that we can later |
97 // remove us from it. | 100 // remove us from it. |
98 controller_ = controller; | 101 controller_ = controller; |
99 [controller_ attachConstrainedWindow:this]; | 102 [controller_ attachConstrainedWindow:this]; |
100 delegate_->set_sheet_open(true); | 103 delegate_->set_sheet_open(true); |
101 } | 104 } |
OLD | NEW |