Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window_mac.mm

Issue 10871082: Constrained Windows Cocoa: Part 4 Refactor ConstrainedWindowSupport (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" 5 #include "chrome/browser/ui/cocoa/constrained_window_mac.h"
6 6
7 #include "chrome/browser/ui/browser_finder.h"
8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
7 #include "chrome/browser/ui/constrained_window_tab_helper.h" 10 #include "chrome/browser/ui/constrained_window_tab_helper.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
9 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents_view.h" 13 #include "content/public/browser/web_contents_view.h"
11 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" 14 #import "third_party/GTM/AppKit/GTMWindowSheetController.h"
12 15
13 ConstrainedWindowMacDelegateSystemSheet:: 16 ConstrainedWindowMacDelegateSystemSheet::
14 ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector) 17 ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector)
15 : systemSheet_(nil), 18 : systemSheet_(nil),
16 delegate_([delegate retain]), 19 delegate_([delegate retain]),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 118 }
116 window = [window parentWindow]; 119 window = [window parentWindow];
117 } 120 }
118 121
119 // It's valid for the window to be nil. For example, background tabs don't 122 // It's valid for the window to be nil. For example, background tabs don't
120 // have a window set. However, if a window exists then there should always 123 // have a window set. However, if a window exists then there should always
121 // be a window controller that implements the ConstrainedWindowSupport 124 // be a window controller that implements the ConstrainedWindowSupport
122 // protocol. 125 // protocol.
123 DCHECK(!window || window_controller); 126 DCHECK(!window || window_controller);
124 127
125 if ([window_controller canAttachConstrainedWindow]) 128 if (window_controller)
126 Realize(window_controller); 129 Realize(window_controller);
127 } 130 }
128 131
129 void ConstrainedWindowMac::CloseConstrainedWindow() { 132 void ConstrainedWindowMac::CloseConstrainedWindow() {
130 // Protection against reentrancy, which might otherwise become a problem if 133 // Protection against reentrancy, which might otherwise become a problem if
131 // DeleteDelegate forcibly closes a constrained window in a way that results 134 // DeleteDelegate forcibly closes a constrained window in a way that results
132 // in CloseConstrainedWindow being called again. 135 // in CloseConstrainedWindow being called again.
133 if (closing_) 136 if (closing_)
134 return; 137 return;
135 138
136 closing_ = true; 139 closing_ = true;
137 140
138 // Note: controller_ can be `nil` here if the sheet was never realized. That's
139 // ok.
140 [controller_ removeConstrainedWindow:this];
141 delegate_->DeleteDelegate(); 141 delegate_->DeleteDelegate();
142 tab_contents_->constrained_window_tab_helper()->WillClose(this); 142 tab_contents_->constrained_window_tab_helper()->WillClose(this);
143 143
144 delete this; 144 delete this;
145 } 145 }
146 146
147 bool ConstrainedWindowMac::CanShowConstrainedWindow() {
148 Browser* browser =
149 browser::FindBrowserWithWebContents(tab_contents_->web_contents());
150 if (!browser)
151 return true;
152 return !browser->window()->IsInstantTabShowing();
153 }
154
147 void ConstrainedWindowMac::Realize( 155 void ConstrainedWindowMac::Realize(
148 NSWindowController<ConstrainedWindowSupport>* controller) { 156 NSWindowController<ConstrainedWindowSupport>* controller) {
149 if (!should_be_visible_) 157 if (!should_be_visible_)
150 return; 158 return;
151 159
152 if (controller_ != nil) { 160 if (controller_ != nil) {
153 DCHECK(controller_ == controller); 161 DCHECK(controller_ == controller);
154 return; 162 return;
155 } 163 }
156 DCHECK(controller != nil); 164 DCHECK(controller != nil);
157 165
158 // Remember the controller we're adding ourselves to, so that we can later 166 // Remember the controller we're adding ourselves to, so that we can later
159 // remove us from it. 167 // remove us from it.
160 controller_ = controller; 168 controller_ = controller;
161 [controller_ attachConstrainedWindow:this]; 169 delegate_->RunSheet([controller_ sheetController],
170 GetSheetParentViewForTabContents(tab_contents_));
162 delegate_->set_sheet_open(true); 171 delegate_->set_sheet_open(true);
163 } 172 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window_mac.h ('k') | chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698