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/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 30 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| 31 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 31 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| 32 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" | 32 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" |
| 33 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" | 33 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" |
| 34 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 34 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
| 35 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 35 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
| 36 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 36 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 37 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 37 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 38 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 38 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 39 #import "chrome/browser/ui/cocoa/version_independent_window.h" | 39 #import "chrome/browser/ui/cocoa/version_independent_window.h" |
| 40 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" | |
| 40 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 41 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 42 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
| 44 #include "content/public/browser/render_widget_host_view.h" | 45 #include "content/public/browser/render_widget_host_view.h" |
| 45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 46 #import "ui/base/cocoa/focus_tracker.h" | 47 #import "ui/base/cocoa/focus_tracker.h" |
| 47 #include "ui/base/ui_base_types.h" | 48 #include "ui/base/ui_base_types.h" |
| 48 | 49 |
| 49 using content::RenderWidgetHostView; | 50 using content::RenderWidgetHostView; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 // FocusTracker will fail to restore focus to anything, so we set the focus | 629 // FocusTracker will fail to restore focus to anything, so we set the focus |
| 629 // to the tab contents as a reasonable fall-back. | 630 // to the tab contents as a reasonable fall-back. |
| 630 [self focusTabContents]; | 631 [self focusTabContents]; |
| 631 } | 632 } |
| 632 [sourceWindow orderOut:self]; | 633 [sourceWindow orderOut:self]; |
| 633 | 634 |
| 634 // We're done moving focus, so re-enable bar visibility changes. | 635 // We're done moving focus, so re-enable bar visibility changes. |
| 635 [self enableBarVisibilityUpdates]; | 636 [self enableBarVisibilityUpdates]; |
| 636 } | 637 } |
| 637 | 638 |
| 639 - (void)permissionBubbleWindowWillClose:(NSNotification*)notification { | |
|
Robert Sesek
2014/07/14 14:13:32
This needs to be declared in the .h
leng
2014/07/14 18:17:24
Done.
| |
| 640 DCHECK(permissionBubbleCocoa_); | |
| 641 | |
| 642 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |
| 643 [center removeObserver:self | |
| 644 name:NSWindowWillCloseNotification | |
| 645 object:[notification object]]; | |
| 646 [presentationModeController_ setAlwaysShowDropdown:NO]; | |
| 647 } | |
| 648 | |
| 638 - (void)setPresentationModeInternal:(BOOL)presentationMode | 649 - (void)setPresentationModeInternal:(BOOL)presentationMode |
| 639 forceDropdown:(BOOL)forceDropdown { | 650 forceDropdown:(BOOL)forceDropdown { |
| 640 if (presentationMode == [self inPresentationMode]) | 651 if (presentationMode == [self inPresentationMode]) |
| 641 return; | 652 return; |
| 642 | 653 |
| 643 if (presentationMode) { | 654 if (presentationMode) { |
| 644 BOOL fullscreen_for_tab = | 655 BOOL fullscreen_for_tab = |
| 645 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); | 656 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); |
| 646 BOOL kiosk_mode = | 657 BOOL kiosk_mode = |
| 647 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 658 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 648 BOOL showDropdown = !fullscreen_for_tab && | 659 BOOL showDropdown = !fullscreen_for_tab && |
| 649 !kiosk_mode && | 660 !kiosk_mode && |
| 650 (forceDropdown || [self floatingBarHasFocus]); | 661 (forceDropdown || [self floatingBarHasFocus]); |
| 651 NSView* contentView = [[self window] contentView]; | |
| 652 presentationModeController_.reset( | 662 presentationModeController_.reset( |
| 653 [[PresentationModeController alloc] initWithBrowserController:self]); | 663 [[PresentationModeController alloc] initWithBrowserController:self]); |
| 664 | |
| 665 if (permissionBubbleCocoa_ && permissionBubbleCocoa_->IsVisible()) { | |
| 666 DCHECK(permissionBubbleCocoa_->window()); | |
| 667 // A visible permission bubble will force the dropdown to remain visible. | |
| 668 [presentationModeController_ setAlwaysShowDropdown:YES]; | |
| 669 showDropdown = YES; | |
| 670 // Register to be notified when the permission bubble is closed, to | |
| 671 // allow fullscreen to hide the dropdown. | |
| 672 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |
| 673 [center addObserver:self | |
| 674 selector:@selector(permissionBubbleWindowWillClose:) | |
| 675 name:NSWindowWillCloseNotification | |
| 676 object:permissionBubbleCocoa_->window()]; | |
| 677 } | |
| 678 if (showDropdown) { | |
| 679 // Turn on layered mode for the window's root view for the entry | |
| 680 // animation. Without this, the OS fullscreen animation for entering | |
| 681 // fullscreen mode does not correctly draw the tab strip. | |
| 682 // It will be turned off (set back to NO) when the animation finishes, | |
| 683 // in -windowDidEnterFullScreen:. | |
| 684 // Leaving wantsLayer on for the duration of presentation mode causes | |
| 685 // performance issues when the dropdown is animated in/out. It also does | |
| 686 // not seem to be required for the exit animation. | |
| 687 [[[self window] cr_windowView] setWantsLayer:YES]; | |
| 688 } | |
| 689 NSView* contentView = [[self window] contentView]; | |
| 654 [presentationModeController_ enterPresentationModeForContentView:contentView | 690 [presentationModeController_ enterPresentationModeForContentView:contentView |
| 655 showDropdown:showDropdown]; | 691 showDropdown:showDropdown]; |
| 656 } else { | 692 } else { |
| 657 [presentationModeController_ exitPresentationMode]; | 693 [presentationModeController_ exitPresentationMode]; |
| 658 presentationModeController_.reset(); | 694 presentationModeController_.reset(); |
| 659 } | 695 } |
| 660 | 696 |
| 661 [self adjustUIForPresentationMode:presentationMode]; | 697 [self adjustUIForPresentationMode:presentationMode]; |
| 662 [self layoutSubviews]; | 698 [self layoutSubviews]; |
| 663 } | 699 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 | 900 |
| 865 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 901 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 866 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen) && | 902 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen) && |
| 867 fullscreenUrl_.is_empty()) { | 903 fullscreenUrl_.is_empty()) { |
| 868 fullscreenModeController_.reset([[FullscreenModeController alloc] | 904 fullscreenModeController_.reset([[FullscreenModeController alloc] |
| 869 initWithBrowserWindowController:self]); | 905 initWithBrowserWindowController:self]); |
| 870 } | 906 } |
| 871 | 907 |
| 872 [self showFullscreenExitBubbleIfNecessary]; | 908 [self showFullscreenExitBubbleIfNecessary]; |
| 873 browser_->WindowFullscreenStateChanged(); | 909 browser_->WindowFullscreenStateChanged(); |
| 910 [[[self window] cr_windowView] setWantsLayer:NO]; | |
| 874 } | 911 } |
| 875 | 912 |
| 876 - (void)windowWillExitFullScreen:(NSNotification*)notification { | 913 - (void)windowWillExitFullScreen:(NSNotification*)notification { |
| 877 if (notification) // For System Fullscreen when non-nil. | 914 if (notification) // For System Fullscreen when non-nil. |
| 878 [self registerForContentViewResizeNotifications]; | 915 [self registerForContentViewResizeNotifications]; |
| 879 fullscreenModeController_.reset(); | 916 fullscreenModeController_.reset(); |
| 880 [self destroyFullscreenExitBubbleIfNecessary]; | 917 [self destroyFullscreenExitBubbleIfNecessary]; |
| 881 [self setPresentationModeInternal:NO forceDropdown:NO]; | 918 [self setPresentationModeInternal:NO forceDropdown:NO]; |
| 882 } | 919 } |
| 883 | 920 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 devTools->SetAllowOverlappingViews(allowOverlappingViews); | 1063 devTools->SetAllowOverlappingViews(allowOverlappingViews); |
| 1027 } | 1064 } |
| 1028 | 1065 |
| 1029 - (void)updateInfoBarTipVisibility { | 1066 - (void)updateInfoBarTipVisibility { |
| 1030 // If there's no toolbar then hide the infobar tip. | 1067 // If there's no toolbar then hide the infobar tip. |
| 1031 [infoBarContainerController_ | 1068 [infoBarContainerController_ |
| 1032 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; | 1069 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; |
| 1033 } | 1070 } |
| 1034 | 1071 |
| 1035 @end // @implementation BrowserWindowController(Private) | 1072 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |