Chromium Code Reviews| 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/browser_window_controller_private.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/mac_util.h" | 12 #include "base/mac/mac_util.h" |
| 13 #import "base/mac/scoped_nsobject.h" | 13 #import "base/mac/scoped_nsobject.h" |
| 14 #import "base/mac/sdk_forward_declarations.h" | 14 #import "base/mac/sdk_forward_declarations.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/fullscreen.h" | 19 #include "chrome/browser/fullscreen.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 21 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_window_state.h" | 24 #include "chrome/browser/ui/browser_window_state.h" |
| 25 #include "chrome/browser/ui/chrome_bubble_manager.h" | |
| 26 #include "chrome/browser/ui/chrome_bubble_manager_factory.h" | |
| 25 #import "chrome/browser/ui/cocoa/browser_window_enter_fullscreen_transition.h" | 27 #import "chrome/browser/ui/cocoa/browser_window_enter_fullscreen_transition.h" |
| 26 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 28 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 27 #import "chrome/browser/ui/cocoa/custom_frame_view.h" | 29 #import "chrome/browser/ui/cocoa/custom_frame_view.h" |
| 28 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 30 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
| 29 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 31 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 30 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 32 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 31 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" | 33 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" |
| 32 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 34 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 33 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 35 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
| 34 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 36 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 | 227 |
| 226 base::scoped_nsobject<BrowserWindowLayout> layout( | 228 base::scoped_nsobject<BrowserWindowLayout> layout( |
| 227 [[BrowserWindowLayout alloc] init]); | 229 [[BrowserWindowLayout alloc] init]); |
| 228 [self updateLayoutParameters:layout]; | 230 [self updateLayoutParameters:layout]; |
| 229 [self applyLayout:layout]; | 231 [self applyLayout:layout]; |
| 230 | 232 |
| 231 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; | 233 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
| 232 | 234 |
| 233 // Will update the location of the permission bubble when showing/hiding the | 235 // Will update the location of the permission bubble when showing/hiding the |
| 234 // top level toolbar in fullscreen. | 236 // top level toolbar in fullscreen. |
| 235 PermissionBubbleManager* manager = [self permissionBubbleManager]; | 237 WebContents* contents = [self webContents]; |
| 236 if (manager) | 238 if (contents) { |
| 237 manager->UpdateAnchorPosition(); | 239 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile()) |
| 240 ->UpdateAnchorPosition(contents); | |
|
groby-ooo-7-16
2015/08/14 18:26:04
Ideally, I'd like a way to do this platform-neutra
| |
| 241 } | |
| 238 } | 242 } |
| 239 | 243 |
| 240 - (void)applyTabStripLayout:(const chrome::TabStripLayout&)layout { | 244 - (void)applyTabStripLayout:(const chrome::TabStripLayout&)layout { |
| 241 // Update the presence of the window controls. | 245 // Update the presence of the window controls. |
| 242 if (layout.addCustomWindowControls) | 246 if (layout.addCustomWindowControls) |
| 243 [tabStripController_ addCustomWindowControls]; | 247 [tabStripController_ addCustomWindowControls]; |
| 244 else | 248 else |
| 245 [tabStripController_ removeCustomWindowControls]; | 249 [tabStripController_ removeCustomWindowControls]; |
| 246 | 250 |
| 247 // Update the layout of the avatar. | 251 // Update the layout of the avatar. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 [[destWindow contentView] addSubview:tabStripView]; | 393 [[destWindow contentView] addSubview:tabStripView]; |
| 390 | 394 |
| 391 [sourceWindow setWindowController:nil]; | 395 [sourceWindow setWindowController:nil]; |
| 392 [self setWindow:destWindow]; | 396 [self setWindow:destWindow]; |
| 393 [destWindow setWindowController:self]; | 397 [destWindow setWindowController:self]; |
| 394 | 398 |
| 395 // Move the status bubble over, if we have one. | 399 // Move the status bubble over, if we have one. |
| 396 if (statusBubble_) | 400 if (statusBubble_) |
| 397 statusBubble_->SwitchParentWindow(destWindow); | 401 statusBubble_->SwitchParentWindow(destWindow); |
| 398 | 402 |
| 399 // Updates the bubble position. | 403 ChromeBubbleManagerFactory::GetForBrowserContext(browser_->profile()) |
| 400 PermissionBubbleManager* manager = [self permissionBubbleManager]; | 404 ->FullscreenToggle([self webContents]); |
| 401 if (manager) | |
| 402 manager->UpdateAnchorPosition(); | |
| 403 | 405 |
| 404 // Move the title over. | 406 // Move the title over. |
| 405 [destWindow setTitle:[sourceWindow title]]; | 407 [destWindow setTitle:[sourceWindow title]]; |
| 406 | 408 |
| 407 // The window needs to be onscreen before we can set its first responder. | 409 // The window needs to be onscreen before we can set its first responder. |
| 408 // Ordering the window to the front can change the active Space (either to | 410 // Ordering the window to the front can change the active Space (either to |
| 409 // the window's old Space or to the application's assigned Space). To prevent | 411 // the window's old Space or to the application's assigned Space). To prevent |
| 410 // this by temporarily change the collectionBehavior. | 412 // this by temporarily change the collectionBehavior. |
| 411 NSWindowCollectionBehavior behavior = [sourceWindow collectionBehavior]; | 413 NSWindowCollectionBehavior behavior = [sourceWindow collectionBehavior]; |
| 412 [destWindow setCollectionBehavior: | 414 [destWindow setCollectionBehavior: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 439 | 441 |
| 440 - (void)configurePresentationModeController { | 442 - (void)configurePresentationModeController { |
| 441 BOOL fullscreen_for_tab = browser_->exclusive_access_manager() | 443 BOOL fullscreen_for_tab = browser_->exclusive_access_manager() |
| 442 ->fullscreen_controller() | 444 ->fullscreen_controller() |
| 443 ->IsWindowFullscreenForTabOrPending(); | 445 ->IsWindowFullscreenForTabOrPending(); |
| 444 BOOL kiosk_mode = | 446 BOOL kiosk_mode = |
| 445 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 447 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 446 BOOL showDropdown = | 448 BOOL showDropdown = |
| 447 !fullscreen_for_tab && !kiosk_mode && ([self floatingBarHasFocus]); | 449 !fullscreen_for_tab && !kiosk_mode && ([self floatingBarHasFocus]); |
| 448 | 450 |
| 451 /* | |
| 452 * TODO(hcarmona): bring this back | |
|
groby-ooo-7-16
2015/08/14 18:26:04
Well, that's kind of a huge part of the cocoa side
hcarmona
2015/08/18 02:22:21
Yes, it's a big part. How should we handle this? C
| |
| 449 PermissionBubbleManager* manager = [self permissionBubbleManager]; | 453 PermissionBubbleManager* manager = [self permissionBubbleManager]; |
| 450 if (manager && manager->IsBubbleVisible()) { | 454 if (manager && manager->IsBubbleVisible()) { |
| 451 NSWindow* bubbleWindow = manager->GetBubbleWindow(); | 455 NSWindow* bubbleWindow = manager->GetBubbleWindow(); |
| 452 DCHECK(bubbleWindow); | 456 DCHECK(bubbleWindow); |
| 453 // A visible permission bubble will force the dropdown to remain | 457 // A visible permission bubble will force the dropdown to remain |
| 454 // visible. | 458 // visible. |
| 455 [self lockBarVisibilityForOwner:bubbleWindow withAnimation:NO delay:NO]; | 459 [self lockBarVisibilityForOwner:bubbleWindow withAnimation:NO delay:NO]; |
| 456 showDropdown = YES; | 460 showDropdown = YES; |
| 457 // Register to be notified when the permission bubble is closed, to | 461 // Register to be notified when the permission bubble is closed, to |
| 458 // allow fullscreen to hide the dropdown. | 462 // allow fullscreen to hide the dropdown. |
| 459 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 463 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 460 [center addObserver:self | 464 [center addObserver:self |
| 461 selector:@selector(permissionBubbleWindowWillClose:) | 465 selector:@selector(permissionBubbleWindowWillClose:) |
| 462 name:NSWindowWillCloseNotification | 466 name:NSWindowWillCloseNotification |
| 463 object:bubbleWindow]; | 467 object:bubbleWindow]; |
| 464 } | 468 } |
| 469 */ | |
| 465 | 470 |
| 466 if (showDropdown) { | 471 if (showDropdown) { |
| 467 // Turn on layered mode for the window's root view for the entry | 472 // Turn on layered mode for the window's root view for the entry |
| 468 // animation. Without this, the OS fullscreen animation for entering | 473 // animation. Without this, the OS fullscreen animation for entering |
| 469 // fullscreen mode does not correctly draw the tab strip. | 474 // fullscreen mode does not correctly draw the tab strip. |
| 470 // It will be turned off (set back to NO) when the animation finishes, | 475 // It will be turned off (set back to NO) when the animation finishes, |
| 471 // in -windowDidEnterFullScreen:. | 476 // in -windowDidEnterFullScreen:. |
| 472 // Leaving wantsLayer on for the duration of presentation mode causes | 477 // Leaving wantsLayer on for the duration of presentation mode causes |
| 473 // performance issues when the dropdown is animated in/out. It also does | 478 // performance issues when the dropdown is animated in/out. It also does |
| 474 // not seem to be required for the exit animation. | 479 // not seem to be required for the exit animation. |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 if ([enterFullscreenTransition_ shouldWindowBeUnconstrained]) | 1116 if ([enterFullscreenTransition_ shouldWindowBeUnconstrained]) |
| 1112 return NO; | 1117 return NO; |
| 1113 | 1118 |
| 1114 return [super shouldConstrainFrameRect]; | 1119 return [super shouldConstrainFrameRect]; |
| 1115 } | 1120 } |
| 1116 | 1121 |
| 1117 - (WebContents*)webContents { | 1122 - (WebContents*)webContents { |
| 1118 return browser_->tab_strip_model()->GetActiveWebContents(); | 1123 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 1119 } | 1124 } |
| 1120 | 1125 |
| 1121 - (PermissionBubbleManager*)permissionBubbleManager { | |
| 1122 if (WebContents* contents = [self webContents]) | |
| 1123 return PermissionBubbleManager::FromWebContents(contents); | |
| 1124 return nil; | |
| 1125 } | |
| 1126 | |
| 1127 @end // @implementation BrowserWindowController(Private) | 1126 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |