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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/ui/browser_command_controller.h" 35 #include "chrome/browser/ui/browser_command_controller.h"
36 #include "chrome/browser/ui/browser_commands.h" 36 #include "chrome/browser/ui/browser_commands.h"
37 #include "chrome/browser/ui/browser_dialogs.h" 37 #include "chrome/browser/ui/browser_dialogs.h"
38 #include "chrome/browser/ui/browser_instant_controller.h" 38 #include "chrome/browser/ui/browser_instant_controller.h"
39 #include "chrome/browser/ui/browser_list.h" 39 #include "chrome/browser/ui/browser_list.h"
40 #include "chrome/browser/ui/browser_window_state.h" 40 #include "chrome/browser/ui/browser_window_state.h"
41 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 41 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
42 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 42 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h" 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h"
44 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" 44 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
45 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
45 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 46 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
46 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" 47 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h"
47 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 48 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
48 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 49 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
49 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 50 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
50 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 51 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
51 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 52 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
52 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" 53 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h"
53 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 54 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
54 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 55 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // When we are given x/y coordinates of 0 on a created popup window, assume 294 // When we are given x/y coordinates of 0 on a created popup window, assume
294 // none were given by the window.open() command. 295 // none were given by the window.open() command.
295 if (browser_->is_type_popup() && 296 if (browser_->is_type_popup() &&
296 windowRect.x() == 0 && windowRect.y() == 0) { 297 windowRect.x() == 0 && windowRect.y() == 0) {
297 gfx::Size size = windowRect.size(); 298 gfx::Size size = windowRect.size();
298 windowRect.set_origin( 299 windowRect.set_origin(
299 WindowSizer::GetDefaultPopupOrigin(size, 300 WindowSizer::GetDefaultPopupOrigin(size,
300 browser_->host_desktop_type())); 301 browser_->host_desktop_type()));
301 } 302 }
302 303
304 // Creates the manager for fullscreen and fullscreen bubbles.
305 exclusiveAccessController_.reset(
306 new ExclusiveAccessController(self, browser_.get()));
307
303 // Size and position the window. Note that it is not yet onscreen. Popup 308 // Size and position the window. Note that it is not yet onscreen. Popup
304 // windows may get resized later on in this function, once the actual size 309 // windows may get resized later on in this function, once the actual size
305 // of the toolbar/tabstrip is known. 310 // of the toolbar/tabstrip is known.
306 windowShim_->SetBounds(windowRect); 311 windowShim_->SetBounds(windowRect);
307 312
308 // Puts the incognito badge on the window frame, if necessary. 313 // Puts the incognito badge on the window frame, if necessary.
309 [self installAvatar]; 314 [self installAvatar];
310 315
311 // Create a sub-controller for the docked devTools and add its view to the 316 // Create a sub-controller for the docked devTools and add its view to the
312 // hierarchy. 317 // hierarchy.
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 CGFloat y = 0; 1882 CGFloat y = 0;
1878 if (NSMaxY(target) < NSMaxY(source)) 1883 if (NSMaxY(target) < NSMaxY(source))
1879 y = NSMaxY(source) - NSMaxY(target); 1884 y = NSMaxY(source) - NSMaxY(target);
1880 else if (NSMinY(source) < NSMinY(target)) 1885 else if (NSMinY(source) < NSMinY(target))
1881 y = NSMinY(source) - NSMinY(target); 1886 y = NSMinY(source) - NSMinY(target);
1882 1887
1883 return NSMakeSize(x, y); 1888 return NSMakeSize(x, y);
1884 } 1889 }
1885 1890
1886 // (Private/TestingAPI) 1891 // (Private/TestingAPI)
1887 - (ExclusiveAccessBubbleWindowController*)
1888 exclusiveAccessBubbleWindowController {
1889 return exclusiveAccessBubbleWindowController_.get();
1890 }
1891
1892 - (NSRect)omniboxPopupAnchorRect { 1892 - (NSRect)omniboxPopupAnchorRect {
1893 // Start with toolbar rect. 1893 // Start with toolbar rect.
1894 NSView* toolbarView = [toolbarController_ view]; 1894 NSView* toolbarView = [toolbarController_ view];
1895 NSRect anchorRect = [toolbarView frame]; 1895 NSRect anchorRect = [toolbarView frame];
1896 1896
1897 // Adjust to account for height and possible bookmark bar. Compress by 1 1897 // Adjust to account for height and possible bookmark bar. Compress by 1
1898 // to account for the separator. 1898 // to account for the separator.
1899 anchorRect.origin.y = 1899 anchorRect.origin.y =
1900 NSMaxY(anchorRect) - [toolbarController_ desiredHeightForCompression:1]; 1900 NSMaxY(anchorRect) - [toolbarController_ desiredHeightForCompression:1];
1901 1901
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 [self enterAppKitFullscreen]; 1952 [self enterAppKitFullscreen];
1953 } 1953 }
1954 } 1954 }
1955 1955
1956 - (void)updateFullscreenWithToolbar:(BOOL)withToolbar { 1956 - (void)updateFullscreenWithToolbar:(BOOL)withToolbar {
1957 [self adjustUIForSlidingFullscreenStyle: 1957 [self adjustUIForSlidingFullscreenStyle:
1958 withToolbar ? fullscreen_mac::OMNIBOX_TABS_PRESENT 1958 withToolbar ? fullscreen_mac::OMNIBOX_TABS_PRESENT
1959 : fullscreen_mac::OMNIBOX_TABS_HIDDEN]; 1959 : fullscreen_mac::OMNIBOX_TABS_HIDDEN];
1960 } 1960 }
1961 1961
1962 - (void)updateFullscreenExitBubbleURL:(const GURL&)url 1962 - (void)updateFullscreenExitBubble {
1963 bubbleType:(ExclusiveAccessBubbleType)bubbleType {
1964 fullscreenUrl_ = url;
1965 exclusiveAccessBubbleType_ = bubbleType;
1966 [self layoutSubviews]; 1963 [self layoutSubviews];
1967 [self showFullscreenExitBubbleIfNecessary]; 1964 [self showFullscreenExitBubbleIfNecessary];
1968 } 1965 }
1969 1966
1970 - (void)toggleFullscreenToolbar { 1967 - (void)toggleFullscreenToolbar {
1971 shouldHideFullscreenToolbar_ = !shouldHideFullscreenToolbar_; 1968 shouldHideFullscreenToolbar_ = !shouldHideFullscreenToolbar_;
1972 1969
1973 if ([self isInAppKitFullscreen]) 1970 if ([self isInAppKitFullscreen])
1974 [self updateFullscreenWithToolbar:!shouldHideFullscreenToolbar_]; 1971 [self updateFullscreenWithToolbar:!shouldHideFullscreenToolbar_];
1975 } 1972 }
1976 1973
1977 - (BOOL)isInAnyFullscreenMode { 1974 - (BOOL)isInAnyFullscreenMode {
1978 return [self isInImmersiveFullscreen] || [self isInAppKitFullscreen]; 1975 return [self isInImmersiveFullscreen] || [self isInAppKitFullscreen];
1979 } 1976 }
1980 1977
1981 - (BOOL)isInImmersiveFullscreen { 1978 - (BOOL)isInImmersiveFullscreen {
1982 return fullscreenWindow_.get() != nil || enteringImmersiveFullscreen_; 1979 return fullscreenWindow_.get() != nil || enteringImmersiveFullscreen_;
1983 } 1980 }
1984 1981
1985 - (BOOL)isInAppKitFullscreen { 1982 - (BOOL)isInAppKitFullscreen {
1986 return !exitingAppKitFullscreen_ && 1983 return !exitingAppKitFullscreen_ &&
1987 (([[self window] styleMask] & NSFullScreenWindowMask) == 1984 (([[self window] styleMask] & NSFullScreenWindowMask) ==
1988 NSFullScreenWindowMask || 1985 NSFullScreenWindowMask ||
1989 enteringAppKitFullscreen_); 1986 enteringAppKitFullscreen_);
1990 } 1987 }
1991 1988
1992 - (void)enterExtensionFullscreenForURL:(const GURL&)url 1989 - (void)enterExtensionFullscreen {
1993 bubbleType:(ExclusiveAccessBubbleType)bubbleType {
1994 if (chrome::mac::SupportsSystemFullscreen()) { 1990 if (chrome::mac::SupportsSystemFullscreen()) {
1995 fullscreenUrl_ = url;
1996 exclusiveAccessBubbleType_ = bubbleType;
1997 [self enterBrowserFullscreenWithToolbar:NO]; 1991 [self enterBrowserFullscreenWithToolbar:NO];
1998 } else { 1992 } else {
1999 [self enterImmersiveFullscreen]; 1993 [self enterImmersiveFullscreen];
2000 DCHECK(!url.is_empty()); 1994 DCHECK(!exclusiveAccessController_->url().is_empty());
2001 [self updateFullscreenExitBubbleURL:url bubbleType:bubbleType]; 1995 [self updateFullscreenExitBubble];
2002 } 1996 }
2003 } 1997 }
2004 1998
2005 - (void)enterWebContentFullscreenForURL:(const GURL&)url 1999 - (void)enterWebContentFullscreen {
2006 bubbleType:(ExclusiveAccessBubbleType)bubbleType {
2007 // HTML5 Fullscreen should only use AppKit fullscreen in 10.10+. 2000 // HTML5 Fullscreen should only use AppKit fullscreen in 10.10+.
2008 if (chrome::mac::SupportsSystemFullscreen() && 2001 if (chrome::mac::SupportsSystemFullscreen() &&
2009 base::mac::IsOSYosemiteOrLater()) 2002 base::mac::IsOSYosemiteOrLater())
2010 [self enterAppKitFullscreen]; 2003 [self enterAppKitFullscreen];
2011 else 2004 else
2012 [self enterImmersiveFullscreen]; 2005 [self enterImmersiveFullscreen];
2013 2006
2014 if (!url.is_empty()) 2007 if (!exclusiveAccessController_->url().is_empty())
2015 [self updateFullscreenExitBubbleURL:url bubbleType:bubbleType]; 2008 [self updateFullscreenExitBubble];
2016 } 2009 }
2017 2010
2018 - (void)exitAnyFullscreen { 2011 - (void)exitAnyFullscreen {
2019 // TODO(erikchen): Fullscreen modes should stack. Should be able to exit 2012 // TODO(erikchen): Fullscreen modes should stack. Should be able to exit
2020 // Immersive Fullscreen and still be in AppKit Fullscreen. 2013 // Immersive Fullscreen and still be in AppKit Fullscreen.
2021 if ([self isInAppKitFullscreen]) 2014 if ([self isInAppKitFullscreen])
2022 [self exitAppKitFullscreen]; 2015 [self exitAppKitFullscreen];
2023 if ([self isInImmersiveFullscreen]) 2016 if ([self isInImmersiveFullscreen])
2024 [self exitImmersiveFullscreen]; 2017 [self exitImmersiveFullscreen];
2025 } 2018 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 delay:delay]; 2071 delay:delay];
2079 } 2072 }
2080 } 2073 }
2081 } 2074 }
2082 2075
2083 - (BOOL)floatingBarHasFocus { 2076 - (BOOL)floatingBarHasFocus {
2084 NSResponder* focused = [[self window] firstResponder]; 2077 NSResponder* focused = [[self window] firstResponder];
2085 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; 2078 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]];
2086 } 2079 }
2087 2080
2081 - (ExclusiveAccessController*)exclusiveAccessController {
2082 return exclusiveAccessController_.get();
2083 }
2084
2088 @end // @implementation BrowserWindowController(Fullscreen) 2085 @end // @implementation BrowserWindowController(Fullscreen)
2089 2086
2090 2087
2091 @implementation BrowserWindowController(WindowType) 2088 @implementation BrowserWindowController(WindowType)
2092 2089
2093 - (BOOL)supportsWindowFeature:(int)feature { 2090 - (BOOL)supportsWindowFeature:(int)feature {
2094 return browser_->SupportsWindowFeature( 2091 return browser_->SupportsWindowFeature(
2095 static_cast<Browser::WindowFeature>(feature)); 2092 static_cast<Browser::WindowFeature>(feature));
2096 } 2093 }
2097 2094
(...skipping 11 matching lines...) Expand all
2109 2106
2110 - (BOOL)supportsBookmarkBar { 2107 - (BOOL)supportsBookmarkBar {
2111 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2108 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2112 } 2109 }
2113 2110
2114 - (BOOL)isTabbedWindow { 2111 - (BOOL)isTabbedWindow {
2115 return browser_->is_type_tabbed(); 2112 return browser_->is_type_tabbed();
2116 } 2113 }
2117 2114
2118 @end // @implementation BrowserWindowController(WindowType) 2115 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698