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 { |
| 640 DCHECK(permissionBubbleCocoa_); |
| 641 |
| 642 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 643 [center removeObserver:self |
| 644 name:NSWindowWillCloseNotification |
| 645 object:[notification object]]; |
| 646 [self releaseBarVisibilityForOwner:[notification object] |
| 647 withAnimation:YES |
| 648 delay:YES]; |
| 649 } |
| 650 |
638 - (void)setPresentationModeInternal:(BOOL)presentationMode | 651 - (void)setPresentationModeInternal:(BOOL)presentationMode |
639 forceDropdown:(BOOL)forceDropdown { | 652 forceDropdown:(BOOL)forceDropdown { |
640 if (presentationMode == [self inPresentationMode]) | 653 if (presentationMode == [self inPresentationMode]) |
641 return; | 654 return; |
642 | 655 |
643 if (presentationMode) { | 656 if (presentationMode) { |
644 BOOL fullscreen_for_tab = | 657 BOOL fullscreen_for_tab = |
645 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); | 658 browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); |
646 BOOL kiosk_mode = | 659 BOOL kiosk_mode = |
647 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 660 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
648 BOOL showDropdown = !fullscreen_for_tab && | 661 BOOL showDropdown = !fullscreen_for_tab && |
649 !kiosk_mode && | 662 !kiosk_mode && |
650 (forceDropdown || [self floatingBarHasFocus]); | 663 (forceDropdown || [self floatingBarHasFocus]); |
651 NSView* contentView = [[self window] contentView]; | |
652 presentationModeController_.reset( | 664 presentationModeController_.reset( |
653 [[PresentationModeController alloc] initWithBrowserController:self]); | 665 [[PresentationModeController alloc] initWithBrowserController:self]); |
| 666 |
| 667 if (permissionBubbleCocoa_ && permissionBubbleCocoa_->IsVisible()) { |
| 668 DCHECK(permissionBubbleCocoa_->window()); |
| 669 // A visible permission bubble will force the dropdown to remain visible. |
| 670 [self lockBarVisibilityForOwner:permissionBubbleCocoa_->window() |
| 671 withAnimation:NO |
| 672 delay:NO]; |
| 673 showDropdown = YES; |
| 674 // Register to be notified when the permission bubble is closed, to |
| 675 // allow fullscreen to hide the dropdown. |
| 676 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 677 [center addObserver:self |
| 678 selector:@selector(permissionBubbleWindowWillClose:) |
| 679 name:NSWindowWillCloseNotification |
| 680 object:permissionBubbleCocoa_->window()]; |
| 681 } |
| 682 if (showDropdown) { |
| 683 // Turn on layered mode for the window's root view for the entry |
| 684 // animation. Without this, the OS fullscreen animation for entering |
| 685 // fullscreen mode does not correctly draw the tab strip. |
| 686 // It will be turned off (set back to NO) when the animation finishes, |
| 687 // in -windowDidEnterFullScreen:. |
| 688 // Leaving wantsLayer on for the duration of presentation mode causes |
| 689 // performance issues when the dropdown is animated in/out. It also does |
| 690 // not seem to be required for the exit animation. |
| 691 [[[self window] cr_windowView] setWantsLayer:YES]; |
| 692 } |
| 693 NSView* contentView = [[self window] contentView]; |
654 [presentationModeController_ enterPresentationModeForContentView:contentView | 694 [presentationModeController_ enterPresentationModeForContentView:contentView |
655 showDropdown:showDropdown]; | 695 showDropdown:showDropdown]; |
656 } else { | 696 } else { |
657 [presentationModeController_ exitPresentationMode]; | 697 [presentationModeController_ exitPresentationMode]; |
658 presentationModeController_.reset(); | 698 presentationModeController_.reset(); |
659 } | 699 } |
660 | 700 |
661 [self adjustUIForPresentationMode:presentationMode]; | 701 [self adjustUIForPresentationMode:presentationMode]; |
662 [self layoutSubviews]; | 702 [self layoutSubviews]; |
663 } | 703 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 - (void)showFullscreenExitBubbleIfNecessary { | 810 - (void)showFullscreenExitBubbleIfNecessary { |
771 // This method is called in response to | 811 // This method is called in response to |
772 // |-updateFullscreenExitBubbleURL:bubbleType:|. If we're in the middle of the | 812 // |-updateFullscreenExitBubbleURL:bubbleType:|. If we're in the middle of the |
773 // transition into fullscreen (i.e., using the System Fullscreen API), do not | 813 // transition into fullscreen (i.e., using the System Fullscreen API), do not |
774 // show the bubble because it will cause visual jank | 814 // show the bubble because it will cause visual jank |
775 // (http://crbug.com/130649). This will be called again as part of | 815 // (http://crbug.com/130649). This will be called again as part of |
776 // |-windowDidEnterFullScreen:|, so arrange to do that work then instead. | 816 // |-windowDidEnterFullScreen:|, so arrange to do that work then instead. |
777 if (enteringFullscreen_) | 817 if (enteringFullscreen_) |
778 return; | 818 return; |
779 | 819 |
780 [presentationModeController_ ensureOverlayHiddenWithAnimation:NO delay:NO]; | 820 [self hideOverlayIfPossibleWithAnimation:NO delay:NO]; |
781 | 821 |
782 if (fullscreenBubbleType_ == FEB_TYPE_NONE || | 822 if (fullscreenBubbleType_ == FEB_TYPE_NONE || |
783 fullscreenBubbleType_ == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION) { | 823 fullscreenBubbleType_ == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION) { |
784 // Show no exit instruction bubble on Mac when in Browser Fullscreen. | 824 // Show no exit instruction bubble on Mac when in Browser Fullscreen. |
785 [self destroyFullscreenExitBubbleIfNecessary]; | 825 [self destroyFullscreenExitBubbleIfNecessary]; |
786 } else { | 826 } else { |
787 [fullscreenExitBubbleController_ closeImmediately]; | 827 [fullscreenExitBubbleController_ closeImmediately]; |
788 fullscreenExitBubbleController_.reset( | 828 fullscreenExitBubbleController_.reset( |
789 [[FullscreenExitBubbleController alloc] | 829 [[FullscreenExitBubbleController alloc] |
790 initWithOwner:self | 830 initWithOwner:self |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 904 |
865 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 905 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
866 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen) && | 906 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen) && |
867 fullscreenUrl_.is_empty()) { | 907 fullscreenUrl_.is_empty()) { |
868 fullscreenModeController_.reset([[FullscreenModeController alloc] | 908 fullscreenModeController_.reset([[FullscreenModeController alloc] |
869 initWithBrowserWindowController:self]); | 909 initWithBrowserWindowController:self]); |
870 } | 910 } |
871 | 911 |
872 [self showFullscreenExitBubbleIfNecessary]; | 912 [self showFullscreenExitBubbleIfNecessary]; |
873 browser_->WindowFullscreenStateChanged(); | 913 browser_->WindowFullscreenStateChanged(); |
| 914 [[[self window] cr_windowView] setWantsLayer:NO]; |
874 } | 915 } |
875 | 916 |
876 - (void)windowWillExitFullScreen:(NSNotification*)notification { | 917 - (void)windowWillExitFullScreen:(NSNotification*)notification { |
877 if (notification) // For System Fullscreen when non-nil. | 918 if (notification) // For System Fullscreen when non-nil. |
878 [self registerForContentViewResizeNotifications]; | 919 [self registerForContentViewResizeNotifications]; |
879 fullscreenModeController_.reset(); | 920 fullscreenModeController_.reset(); |
880 [self destroyFullscreenExitBubbleIfNecessary]; | 921 [self destroyFullscreenExitBubbleIfNecessary]; |
881 [self setPresentationModeInternal:NO forceDropdown:NO]; | 922 [self setPresentationModeInternal:NO forceDropdown:NO]; |
882 } | 923 } |
883 | 924 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 | 959 |
919 - (void)disableBarVisibilityUpdates { | 960 - (void)disableBarVisibilityUpdates { |
920 // Early escape if there's nothing to do. | 961 // Early escape if there's nothing to do. |
921 if (!barVisibilityUpdatesEnabled_) | 962 if (!barVisibilityUpdatesEnabled_) |
922 return; | 963 return; |
923 | 964 |
924 barVisibilityUpdatesEnabled_ = NO; | 965 barVisibilityUpdatesEnabled_ = NO; |
925 [presentationModeController_ cancelAnimationAndTimers]; | 966 [presentationModeController_ cancelAnimationAndTimers]; |
926 } | 967 } |
927 | 968 |
| 969 - (void)hideOverlayIfPossibleWithAnimation:(BOOL)animation delay:(BOOL)delay { |
| 970 if (!barVisibilityUpdatesEnabled_ || [barVisibilityLocks_ count]) |
| 971 return; |
| 972 [presentationModeController_ ensureOverlayHiddenWithAnimation:animation |
| 973 delay:delay]; |
| 974 } |
| 975 |
928 - (CGFloat)toolbarDividerOpacity { | 976 - (CGFloat)toolbarDividerOpacity { |
929 return [bookmarkBarController_ toolbarDividerOpacity]; | 977 return [bookmarkBarController_ toolbarDividerOpacity]; |
930 } | 978 } |
931 | 979 |
932 - (void)updateSubviewZOrder:(BOOL)inPresentationMode { | 980 - (void)updateSubviewZOrder:(BOOL)inPresentationMode { |
933 NSView* contentView = [[self window] contentView]; | 981 NSView* contentView = [[self window] contentView]; |
934 NSView* toolbarView = [toolbarController_ view]; | 982 NSView* toolbarView = [toolbarController_ view]; |
935 | 983 |
936 if (inPresentationMode) { | 984 if (inPresentationMode) { |
937 // Toolbar is above tab contents so that it can slide down from top of | 985 // Toolbar is above tab contents so that it can slide down from top of |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 devTools->SetAllowOverlappingViews(allowOverlappingViews); | 1074 devTools->SetAllowOverlappingViews(allowOverlappingViews); |
1027 } | 1075 } |
1028 | 1076 |
1029 - (void)updateInfoBarTipVisibility { | 1077 - (void)updateInfoBarTipVisibility { |
1030 // If there's no toolbar then hide the infobar tip. | 1078 // If there's no toolbar then hide the infobar tip. |
1031 [infoBarContainerController_ | 1079 [infoBarContainerController_ |
1032 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; | 1080 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; |
1033 } | 1081 } |
1034 | 1082 |
1035 @end // @implementation BrowserWindowController(Private) | 1083 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |