| OLD | NEW |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 52 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
| 53 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 53 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
| 54 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 54 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 55 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 55 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 56 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 56 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 57 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 57 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 58 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h" | 58 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h" |
| 59 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 59 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
| 60 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 60 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 61 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 61 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 62 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_visibility_lock_c
ontroller.h" |
| 62 #import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h" | 63 #import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h" |
| 63 #include "chrome/browser/ui/cocoa/l10n_util.h" | 64 #include "chrome/browser/ui/cocoa/l10n_util.h" |
| 64 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" | 65 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
| 65 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" | 66 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" |
| 66 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" | 67 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" |
| 67 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 68 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
| 68 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 69 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
| 69 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 70 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 70 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 71 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 71 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 72 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // ordering of all child views and their layers. | 239 // ordering of all child views and their layers. |
| 239 [[window contentView] setWantsLayer:YES]; | 240 [[window contentView] setWantsLayer:YES]; |
| 240 windowShim_.reset(new BrowserWindowCocoa(browser, self)); | 241 windowShim_.reset(new BrowserWindowCocoa(browser, self)); |
| 241 | 242 |
| 242 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups. | 243 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups. |
| 243 // This has to happen before -enforceMinWindowSize: is called further down. | 244 // This has to happen before -enforceMinWindowSize: is called further down. |
| 244 NSSize minSize = [self isTabbedWindow] ? | 245 NSSize minSize = [self isTabbedWindow] ? |
| 245 NSMakeSize(400, 272) : NSMakeSize(100, 122); | 246 NSMakeSize(400, 272) : NSMakeSize(100, 122); |
| 246 [[self window] setMinSize:minSize]; | 247 [[self window] setMinSize:minSize]; |
| 247 | 248 |
| 248 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully | |
| 249 // be big enough to hold all locks that'll ever be needed. | |
| 250 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); | |
| 251 | |
| 252 // Lion will attempt to automagically save and restore the UI. This | 249 // Lion will attempt to automagically save and restore the UI. This |
| 253 // functionality appears to be leaky (or at least interacts badly with our | 250 // functionality appears to be leaky (or at least interacts badly with our |
| 254 // architecture) and thus BrowserWindowController never gets released. This | 251 // architecture) and thus BrowserWindowController never gets released. This |
| 255 // prevents the browser from being able to quit <http://crbug.com/79113>. | 252 // prevents the browser from being able to quit <http://crbug.com/79113>. |
| 256 [window setRestorable:NO]; | 253 [window setRestorable:NO]; |
| 257 | 254 |
| 258 // Get the windows to swish in on Lion. | 255 // Get the windows to swish in on Lion. |
| 259 [window setAnimationBehavior:NSWindowAnimationBehaviorDocumentWindow]; | 256 [window setAnimationBehavior:NSWindowAnimationBehaviorDocumentWindow]; |
| 260 | 257 |
| 261 // Get the most appropriate size for the window, then enforce the | 258 // Get the most appropriate size for the window, then enforce the |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 infoBarContainerController_.reset( | 337 infoBarContainerController_.reset( |
| 341 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); | 338 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); |
| 342 [self updateInfoBarTipVisibility]; | 339 [self updateInfoBarTipVisibility]; |
| 343 | 340 |
| 344 // We don't want to try and show the bar before it gets placed in its parent | 341 // We don't want to try and show the bar before it gets placed in its parent |
| 345 // view, so this step shoudn't be inside the bookmark bar controller's | 342 // view, so this step shoudn't be inside the bookmark bar controller's |
| 346 // |-awakeFromNib|. | 343 // |-awakeFromNib|. |
| 347 windowShim_->BookmarkBarStateChanged( | 344 windowShim_->BookmarkBarStateChanged( |
| 348 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 345 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 349 | 346 |
| 350 // Allow bar visibility to be changed. | |
| 351 [self enableBarVisibilityUpdates]; | |
| 352 | |
| 353 [self updateFullscreenCollectionBehavior]; | 347 [self updateFullscreenCollectionBehavior]; |
| 354 | 348 |
| 355 [self layoutSubviews]; | 349 [self layoutSubviews]; |
| 356 | 350 |
| 357 // For non-trusted, non-app popup windows, |desiredContentRect| contains the | 351 // For non-trusted, non-app popup windows, |desiredContentRect| contains the |
| 358 // desired height of the content, not of the whole window. Now that all the | 352 // desired height of the content, not of the whole window. Now that all the |
| 359 // views are laid out, measure the current content area size and grow if | 353 // views are laid out, measure the current content area size and grow if |
| 360 // needed. The window has not been placed onscreen yet, so this extra resize | 354 // needed. The window has not been placed onscreen yet, so this extra resize |
| 361 // will not cause visible jank. | 355 // will not cause visible jank. |
| 362 if (chrome::SavedBoundsAreContentBounds(browser_.get())) { | 356 if (chrome::SavedBoundsAreContentBounds(browser_.get())) { |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 - (void)resizeFullscreenWindow { | 1925 - (void)resizeFullscreenWindow { |
| 1932 DCHECK([self isInAnyFullscreenMode]); | 1926 DCHECK([self isInAnyFullscreenMode]); |
| 1933 if (![self isInAnyFullscreenMode]) | 1927 if (![self isInAnyFullscreenMode]) |
| 1934 return; | 1928 return; |
| 1935 | 1929 |
| 1936 NSWindow* window = [self window]; | 1930 NSWindow* window = [self window]; |
| 1937 [window setFrame:[[window screen] frame] display:YES]; | 1931 [window setFrame:[[window screen] frame] display:YES]; |
| 1938 [self layoutSubviews]; | 1932 [self layoutSubviews]; |
| 1939 } | 1933 } |
| 1940 | 1934 |
| 1941 - (BOOL)isBarVisibilityLockedForOwner:(id)owner { | 1935 - (BOOL)isToolbarVisibilityLockedForOwner:(id)owner { |
| 1942 DCHECK(barVisibilityLocks_); | 1936 FullscreenToolbarVisibilityLockController* visibilityController = |
| 1943 return owner ? [barVisibilityLocks_ containsObject:owner] | 1937 [self fullscreenToolbarVisibilityLockController]; |
| 1944 : [barVisibilityLocks_ count]; | 1938 return [visibilityController isToolbarVisibilityLockedForOwner:owner]; |
| 1945 } | 1939 } |
| 1946 | 1940 |
| 1947 - (void)lockBarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate { | 1941 - (void)lockToolbarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate { |
| 1948 if (![self isBarVisibilityLockedForOwner:owner]) { | 1942 FullscreenToolbarVisibilityLockController* visibilityController = |
| 1949 [barVisibilityLocks_ addObject:owner]; | 1943 [self fullscreenToolbarVisibilityLockController]; |
| 1950 | 1944 [visibilityController lockToolbarVisibilityForOwner:owner |
| 1951 // If enabled, show the overlay if necessary (and if the fullscreen | 1945 withAnimation:animate]; |
| 1952 // toolbar is hidden). | |
| 1953 if (barVisibilityUpdatesEnabled_) | |
| 1954 [fullscreenToolbarController_ ensureOverlayShownWithAnimation:animate]; | |
| 1955 } | |
| 1956 } | 1946 } |
| 1957 | 1947 |
| 1958 - (void)releaseBarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate { | 1948 - (void)releaseToolbarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate { |
| 1959 if ([self isBarVisibilityLockedForOwner:owner]) { | 1949 FullscreenToolbarVisibilityLockController* visibilityController = |
| 1960 [barVisibilityLocks_ removeObject:owner]; | 1950 [self fullscreenToolbarVisibilityLockController]; |
| 1961 | 1951 [visibilityController releaseToolbarVisibilityForOwner:owner |
| 1962 // If enabled, hide the overlay if necessary (and if the fullscreen | 1952 withAnimation:animate]; |
| 1963 // toolbar is hidden). | |
| 1964 if (barVisibilityUpdatesEnabled_ && ![barVisibilityLocks_ count]) | |
| 1965 [fullscreenToolbarController_ ensureOverlayHiddenWithAnimation:animate]; | |
| 1966 } | |
| 1967 } | 1953 } |
| 1968 | 1954 |
| 1969 - (BOOL)floatingBarHasFocus { | 1955 - (BOOL)floatingBarHasFocus { |
| 1970 NSResponder* focused = [[self window] firstResponder]; | 1956 NSResponder* focused = [[self window] firstResponder]; |
| 1971 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; | 1957 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; |
| 1972 } | 1958 } |
| 1973 | 1959 |
| 1974 - (ExclusiveAccessController*)exclusiveAccessController { | 1960 - (ExclusiveAccessController*)exclusiveAccessController { |
| 1975 return exclusiveAccessController_.get(); | 1961 return exclusiveAccessController_.get(); |
| 1976 } | 1962 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2007 | 1993 |
| 2008 - (NSRect)savedRegularWindowFrame { | 1994 - (NSRect)savedRegularWindowFrame { |
| 2009 return savedRegularWindowFrame_; | 1995 return savedRegularWindowFrame_; |
| 2010 } | 1996 } |
| 2011 | 1997 |
| 2012 - (BOOL)isFullscreenTransitionInProgress { | 1998 - (BOOL)isFullscreenTransitionInProgress { |
| 2013 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 1999 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2014 } | 2000 } |
| 2015 | 2001 |
| 2016 @end // @implementation BrowserWindowController(WindowType) | 2002 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |