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 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 ScopedCAActionDisabler disabler; | 171 ScopedCAActionDisabler disabler; |
172 [[self layer] setBackgroundColor:cgBackgroundColor]; | 172 [[self layer] setBackgroundColor:cgBackgroundColor]; |
173 } | 173 } |
174 | 174 |
175 @end // @implementation TabContentsContainerView | 175 @end // @implementation TabContentsContainerView |
176 | 176 |
177 @implementation TabContentsController | 177 @implementation TabContentsController |
178 @synthesize webContents = contents_; | 178 @synthesize webContents = contents_; |
179 | 179 |
180 - (id)initWithContents:(WebContents*)contents | 180 - (id)initWithContents:(WebContents*)contents { |
181 andAutoEmbedFullscreen:(BOOL)enableEmbeddedFullscreen { | |
182 if ((self = [super initWithNibName:nil bundle:nil])) { | 181 if ((self = [super initWithNibName:nil bundle:nil])) { |
183 if (enableEmbeddedFullscreen) | 182 fullscreenObserver_.reset(new FullscreenObserver(self)); |
184 fullscreenObserver_.reset(new FullscreenObserver(self)); | |
185 [self changeWebContents:contents]; | 183 [self changeWebContents:contents]; |
186 } | 184 } |
187 return self; | 185 return self; |
188 } | 186 } |
189 | 187 |
190 - (void)dealloc { | 188 - (void)dealloc { |
191 [static_cast<TabContentsContainerView*>([self view]) delegateDestroyed]; | 189 [static_cast<TabContentsContainerView*>([self view]) delegateDestroyed]; |
192 // Make sure the contents view has been removed from the container view to | 190 // Make sure the contents view has been removed from the container view to |
193 // allow objects to be released. | 191 // allow objects to be released. |
194 [[self view] removeFromSuperview]; | 192 [[self view] removeFromSuperview]; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 239 |
242 // The rendering path with overlapping views disabled causes bugs when | 240 // The rendering path with overlapping views disabled causes bugs when |
243 // transitioning between composited and non-composited mode. | 241 // transitioning between composited and non-composited mode. |
244 // http://crbug.com/279472 | 242 // http://crbug.com/279472 |
245 if (!fullscreenView) | 243 if (!fullscreenView) |
246 contents_->SetAllowOverlappingViews(true); | 244 contents_->SetAllowOverlappingViews(true); |
247 } | 245 } |
248 | 246 |
249 - (void)changeWebContents:(WebContents*)newContents { | 247 - (void)changeWebContents:(WebContents*)newContents { |
250 contents_ = newContents; | 248 contents_ = newContents; |
251 if (fullscreenObserver_) { | 249 fullscreenObserver_->Observe(contents_); |
252 fullscreenObserver_->Observe(contents_); | 250 isEmbeddingFullscreenWidget_ = |
253 isEmbeddingFullscreenWidget_ = | 251 contents_ && contents_->GetFullscreenRenderWidgetHostView(); |
254 contents_ && contents_->GetFullscreenRenderWidgetHostView(); | |
255 } else { | |
256 isEmbeddingFullscreenWidget_ = NO; | |
257 } | |
258 } | 252 } |
259 | 253 |
260 // Returns YES if the tab represented by this controller is the front-most. | 254 // Returns YES if the tab represented by this controller is the front-most. |
261 - (BOOL)isCurrentTab { | 255 - (BOOL)isCurrentTab { |
262 // We're the current tab if we're in the view hierarchy, otherwise some other | 256 // We're the current tab if we're in the view hierarchy, otherwise some other |
263 // tab is. | 257 // tab is. |
264 return [[self view] superview] ? YES : NO; | 258 return [[self view] superview] ? YES : NO; |
265 } | 259 } |
266 | 260 |
267 - (void)willBecomeUnselectedTab { | 261 - (void)willBecomeUnselectedTab { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 296 } |
303 } | 297 } |
304 | 298 |
305 - (void)toggleFullscreenWidget:(BOOL)enterFullscreen { | 299 - (void)toggleFullscreenWidget:(BOOL)enterFullscreen { |
306 isEmbeddingFullscreenWidget_ = enterFullscreen && | 300 isEmbeddingFullscreenWidget_ = enterFullscreen && |
307 contents_ && contents_->GetFullscreenRenderWidgetHostView(); | 301 contents_ && contents_->GetFullscreenRenderWidgetHostView(); |
308 [self ensureContentsVisible]; | 302 [self ensureContentsVisible]; |
309 } | 303 } |
310 | 304 |
311 - (BOOL)contentsInFullscreenCaptureMode { | 305 - (BOOL)contentsInFullscreenCaptureMode { |
312 if (!fullscreenObserver_) | |
313 return NO; | |
314 // Note: Grab a known-valid WebContents pointer from |fullscreenObserver_|. | 306 // Note: Grab a known-valid WebContents pointer from |fullscreenObserver_|. |
315 content::WebContents* const wc = fullscreenObserver_->web_contents(); | 307 content::WebContents* const wc = fullscreenObserver_->web_contents(); |
316 if (!wc || | 308 if (!wc || |
317 wc->GetCapturerCount() == 0 || | 309 wc->GetCapturerCount() == 0 || |
318 wc->GetPreferredSize().IsEmpty() || | 310 wc->GetPreferredSize().IsEmpty() || |
319 !(isEmbeddingFullscreenWidget_ || | 311 !(isEmbeddingFullscreenWidget_ || |
320 (wc->GetDelegate() && | 312 (wc->GetDelegate() && |
321 wc->GetDelegate()->IsFullscreenForTabOrPending(wc)))) { | 313 wc->GetDelegate()->IsFullscreenForTabOrPending(wc)))) { |
322 return NO; | 314 return NO; |
323 } | 315 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 } else { | 350 } else { |
359 rect.ClampToCenteredSize(gfx::Size( | 351 rect.ClampToCenteredSize(gfx::Size( |
360 static_cast<int>(x / captureSize.height()), rect.height())); | 352 static_cast<int>(x / captureSize.height()), rect.height())); |
361 } | 353 } |
362 } | 354 } |
363 | 355 |
364 return NSRectFromCGRect(rect.ToCGRect()); | 356 return NSRectFromCGRect(rect.ToCGRect()); |
365 } | 357 } |
366 | 358 |
367 @end | 359 @end |
OLD | NEW |