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

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

Issue 1650483002: Refactor: Untangle Mac's ExclusiveAccessContext from BrowserWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename accessor Created 4 years, 10 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
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 #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 #import "base/auto_reset.h" 9 #import "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/mac/bind_objc_block.h" 11 #include "base/mac/bind_objc_block.h"
12 #include "base/mac/foundation_util.h" 12 #include "base/mac/foundation_util.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #import "base/mac/scoped_nsobject.h" 14 #import "base/mac/scoped_nsobject.h"
15 #import "base/mac/sdk_forward_declarations.h" 15 #import "base/mac/sdk_forward_declarations.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/prefs/scoped_user_pref_update.h" 18 #include "base/prefs/scoped_user_pref_update.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/fullscreen.h" 20 #include "chrome/browser/fullscreen.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 22 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
23 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 23 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_window_state.h" 25 #include "chrome/browser/ui/browser_window_state.h"
26 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h" 26 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h"
27 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 27 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
28 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
28 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 29 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
29 #import "chrome/browser/ui/cocoa/custom_frame_view.h" 30 #import "chrome/browser/ui/cocoa/custom_frame_view.h"
30 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 31 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
31 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 32 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
32 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 33 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
33 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" 34 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
34 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 35 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
35 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 36 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
36 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 37 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
37 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 38 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 // |-updateFullscreenExitBubbleURL:bubbleType:|. If we're in the middle of the 624 // |-updateFullscreenExitBubbleURL:bubbleType:|. If we're in the middle of the
624 // transition into fullscreen (i.e., using the AppKit Fullscreen API), do not 625 // transition into fullscreen (i.e., using the AppKit Fullscreen API), do not
625 // show the bubble because it will cause visual jank 626 // show the bubble because it will cause visual jank
626 // (http://crbug.com/130649). This will be called again as part of 627 // (http://crbug.com/130649). This will be called again as part of
627 // |-windowDidEnterFullScreen:|, so arrange to do that work then instead. 628 // |-windowDidEnterFullScreen:|, so arrange to do that work then instead.
628 if (enteringAppKitFullscreen_) 629 if (enteringAppKitFullscreen_)
629 return; 630 return;
630 631
631 [self hideOverlayIfPossibleWithAnimation:NO delay:NO]; 632 [self hideOverlayIfPossibleWithAnimation:NO delay:NO];
632 633
633 if (exclusiveAccessBubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || 634 switch (exclusiveAccessController_->bubble_type()) {
634 exclusiveAccessBubbleType_ == 635 case EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE:
635 EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION) { 636 case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION:
636 // Show no exit instruction bubble on Mac when in Browser Fullscreen. 637 // Show no exit instruction bubble on Mac when in Browser Fullscreen.
637 [self destroyFullscreenExitBubbleIfNecessary]; 638 exclusiveAccessController_->Destroy();
638 } else { 639 break;
639 [exclusiveAccessBubbleWindowController_ closeImmediately]; 640
640 exclusiveAccessBubbleWindowController_.reset( 641 default:
641 [[ExclusiveAccessBubbleWindowController alloc] 642 exclusiveAccessController_->Show();
642 initWithOwner:self
643 exclusive_access_manager:browser_.get()->exclusive_access_manager()
644 profile:browser_.get()->profile()
645 url:fullscreenUrl_
646 bubbleType:exclusiveAccessBubbleType_]);
647 [exclusiveAccessBubbleWindowController_ showWindow];
648 } 643 }
649 } 644 }
650 645
651 - (void)destroyFullscreenExitBubbleIfNecessary {
652 [exclusiveAccessBubbleWindowController_ closeImmediately];
653 exclusiveAccessBubbleWindowController_.reset();
654 }
655
656 - (void)contentViewDidResize:(NSNotification*)notification { 646 - (void)contentViewDidResize:(NSNotification*)notification {
657 [self layoutSubviews]; 647 [self layoutSubviews];
658 } 648 }
659 649
660 - (void)registerForContentViewResizeNotifications { 650 - (void)registerForContentViewResizeNotifications {
661 [[NSNotificationCenter defaultCenter] 651 [[NSNotificationCenter defaultCenter]
662 addObserver:self 652 addObserver:self
663 selector:@selector(contentViewDidResize:) 653 selector:@selector(contentViewDidResize:)
664 name:NSViewFrameDidChangeNotification 654 name:NSViewFrameDidChangeNotification
665 object:[[self window] contentView]]; 655 object:[[self window] contentView]];
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 ConstrainedWindowSheetController* sheetController = 839 ConstrainedWindowSheetController* sheetController =
850 [ConstrainedWindowSheetController 840 [ConstrainedWindowSheetController
851 controllerForParentWindow:[self window]]; 841 controllerForParentWindow:[self window]];
852 if (shoudHide) 842 if (shoudHide)
853 [sheetController hideSheetForFullscreenTransition]; 843 [sheetController hideSheetForFullscreenTransition];
854 else 844 else
855 [sheetController unhideSheetForFullscreenTransition]; 845 [sheetController unhideSheetForFullscreenTransition];
856 } 846 }
857 847
858 - (void)adjustUIForExitingFullscreen { 848 - (void)adjustUIForExitingFullscreen {
859 [self destroyFullscreenExitBubbleIfNecessary]; 849 exclusiveAccessController_->Destroy();
860 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 850 [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
861 } 851 }
862 852
863 - (void)adjustUIForEnteringFullscreen { 853 - (void)adjustUIForEnteringFullscreen {
864 fullscreen_mac::SlidingStyle style; 854 fullscreen_mac::SlidingStyle style;
865 if ([self isFullscreenForTabContent]) { 855 if ([self isFullscreenForTabContent]) {
866 style = fullscreen_mac::OMNIBOX_TABS_NONE; 856 style = fullscreen_mac::OMNIBOX_TABS_NONE;
867 } else if (enteringPresentationMode_ || [self shouldHideFullscreenToolbar]) { 857 } else if (enteringPresentationMode_ || [self shouldHideFullscreenToolbar]) {
868 style = fullscreen_mac::OMNIBOX_TABS_HIDDEN; 858 style = fullscreen_mac::OMNIBOX_TABS_HIDDEN;
869 } else { 859 } else {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 if (!NSIsEmptyRect(output.fullscreenBackingBarFrame)) { 1034 if (!NSIsEmptyRect(output.fullscreenBackingBarFrame)) {
1045 [floatingBarBackingView_ setFrame:output.fullscreenBackingBarFrame]; 1035 [floatingBarBackingView_ setFrame:output.fullscreenBackingBarFrame];
1046 [presentationModeController_ 1036 [presentationModeController_
1047 overlayFrameChanged:output.fullscreenBackingBarFrame]; 1037 overlayFrameChanged:output.fullscreenBackingBarFrame];
1048 } 1038 }
1049 1039
1050 [findBarCocoaController_ 1040 [findBarCocoaController_
1051 positionFindBarViewAtMaxY:output.findBarMaxY 1041 positionFindBarViewAtMaxY:output.findBarMaxY
1052 maxWidth:NSWidth(output.contentAreaFrame)]; 1042 maxWidth:NSWidth(output.contentAreaFrame)];
1053 1043
1054 [exclusiveAccessBubbleWindowController_ 1044 exclusiveAccessController_->Layout(output.fullscreenExitButtonMaxY);
1055 positionInWindowAtTop:output.fullscreenExitButtonMaxY
1056 width:NSWidth(output.contentAreaFrame)];
1057 } 1045 }
1058 1046
1059 - (void)updateSubviewZOrder { 1047 - (void)updateSubviewZOrder {
1060 if ([self isInAnyFullscreenMode]) 1048 if ([self isInAnyFullscreenMode])
1061 [self updateSubviewZOrderFullscreen]; 1049 [self updateSubviewZOrderFullscreen];
1062 else 1050 else
1063 [self updateSubviewZOrderNormal]; 1051 [self updateSubviewZOrderNormal];
1064 } 1052 }
1065 1053
1066 - (void)updateSubviewZOrderNormal { 1054 - (void)updateSubviewZOrderNormal {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 return nil; 1255 return nil;
1268 } 1256 }
1269 1257
1270 - (BOOL)isFullscreenForTabContent { 1258 - (BOOL)isFullscreenForTabContent {
1271 return browser_->exclusive_access_manager() 1259 return browser_->exclusive_access_manager()
1272 ->fullscreen_controller() 1260 ->fullscreen_controller()
1273 ->IsWindowFullscreenForTabOrPending(); 1261 ->IsWindowFullscreenForTabOrPending();
1274 } 1262 }
1275 1263
1276 @end // @implementation BrowserWindowController(Private) 1264 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698