| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 [[bookmarkBarController_ controlledView] setResizeDelegate:self]; | 331 [[bookmarkBarController_ controlledView] setResizeDelegate:self]; |
| 332 | 332 |
| 333 [bookmarkBarController_ setBookmarkBarEnabled:[self supportsBookmarkBar]]; | 333 [bookmarkBarController_ setBookmarkBarEnabled:[self supportsBookmarkBar]]; |
| 334 | 334 |
| 335 // Create the infobar container view, so we can pass it to the | 335 // Create the infobar container view, so we can pass it to the |
| 336 // ToolbarController. | 336 // ToolbarController. |
| 337 infoBarContainerController_.reset( | 337 infoBarContainerController_.reset( |
| 338 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); | 338 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); |
| 339 [self updateInfoBarTipVisibility]; | 339 [self updateInfoBarTipVisibility]; |
| 340 | 340 |
| 341 fullscreenToolbarController_.reset( |
| 342 [[FullscreenToolbarController alloc] initWithBrowserController:self]); |
| 343 |
| 341 // We don't want to try and show the bar before it gets placed in its parent | 344 // We don't want to try and show the bar before it gets placed in its parent |
| 342 // view, so this step shoudn't be inside the bookmark bar controller's | 345 // view, so this step shoudn't be inside the bookmark bar controller's |
| 343 // |-awakeFromNib|. | 346 // |-awakeFromNib|. |
| 344 windowShim_->BookmarkBarStateChanged( | 347 windowShim_->BookmarkBarStateChanged( |
| 345 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 348 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 346 | 349 |
| 347 [self updateFullscreenCollectionBehavior]; | 350 [self updateFullscreenCollectionBehavior]; |
| 348 | 351 |
| 349 [self layoutSubviews]; | 352 [self layoutSubviews]; |
| 350 | 353 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 376 // on the window bounds to determine whether to show buttons or not. | 379 // on the window bounds to determine whether to show buttons or not. |
| 377 if ([self hasToolbar]) // Do not create the buttons in popups. | 380 if ([self hasToolbar]) // Do not create the buttons in popups. |
| 378 [toolbarController_ createBrowserActionButtons]; | 381 [toolbarController_ createBrowserActionButtons]; |
| 379 | 382 |
| 380 extensionKeybindingRegistry_.reset( | 383 extensionKeybindingRegistry_.reset( |
| 381 new ExtensionKeybindingRegistryCocoa(browser_->profile(), | 384 new ExtensionKeybindingRegistryCocoa(browser_->profile(), |
| 382 [self window], | 385 [self window], |
| 383 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, | 386 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, |
| 384 windowShim_.get())); | 387 windowShim_.get())); |
| 385 | 388 |
| 386 PrefService* prefs = browser_->profile()->GetPrefs(); | |
| 387 shouldShowFullscreenToolbar_ = | |
| 388 prefs->GetBoolean(prefs::kShowFullscreenToolbar); | |
| 389 blockLayoutSubviews_ = NO; | 389 blockLayoutSubviews_ = NO; |
| 390 | 390 |
| 391 // We are done initializing now. | 391 // We are done initializing now. |
| 392 initializing_ = NO; | 392 initializing_ = NO; |
| 393 } | 393 } |
| 394 return self; | 394 return self; |
| 395 } | 395 } |
| 396 | 396 |
| 397 - (void)dealloc { | 397 - (void)dealloc { |
| 398 browser_->tab_strip_model()->CloseAllTabs(); | 398 browser_->tab_strip_model()->CloseAllTabs(); |
| (...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 | 1821 |
| 1822 @implementation BrowserWindowController(Fullscreen) | 1822 @implementation BrowserWindowController(Fullscreen) |
| 1823 | 1823 |
| 1824 - (void)enterBrowserFullscreen { | 1824 - (void)enterBrowserFullscreen { |
| 1825 [self enterAppKitFullscreen]; | 1825 [self enterAppKitFullscreen]; |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 1828 - (void)updateUIForTabFullscreen: | 1828 - (void)updateUIForTabFullscreen: |
| 1829 (ExclusiveAccessContext::TabFullscreenState)state { | 1829 (ExclusiveAccessContext::TabFullscreenState)state { |
| 1830 DCHECK([self isInAnyFullscreenMode]); | 1830 DCHECK([self isInAnyFullscreenMode]); |
| 1831 if (state == ExclusiveAccessContext::STATE_ENTER_TAB_FULLSCREEN) { | 1831 [fullscreenToolbarController_ updateToolbarStyle]; |
| 1832 [self adjustUIForSlidingFullscreenStyle:FullscreenSlidingStyle:: | |
| 1833 OMNIBOX_TABS_NONE]; | |
| 1834 return; | |
| 1835 } | |
| 1836 | |
| 1837 [self adjustUIForSlidingFullscreenStyle: | |
| 1838 shouldShowFullscreenToolbar_ | |
| 1839 ? FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT | |
| 1840 : FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN]; | |
| 1841 } | 1832 } |
| 1842 | 1833 |
| 1843 - (void)updateFullscreenExitBubble { | 1834 - (void)updateFullscreenExitBubble { |
| 1844 [self showFullscreenExitBubbleIfNecessary]; | 1835 [self showFullscreenExitBubbleIfNecessary]; |
| 1845 } | 1836 } |
| 1846 | 1837 |
| 1847 - (BOOL)exitExtensionFullscreenIfPossible { | 1838 - (BOOL)exitExtensionFullscreenIfPossible { |
| 1848 if (browser_->exclusive_access_manager() | 1839 if (browser_->exclusive_access_manager() |
| 1849 ->fullscreen_controller() | 1840 ->fullscreen_controller() |
| 1850 ->IsExtensionFullscreenOrPending()) { | 1841 ->IsExtensionFullscreenOrPending()) { |
| 1851 browser_->extension_window_controller()->SetFullscreenMode(NO, GURL()); | 1842 browser_->extension_window_controller()->SetFullscreenMode(NO, GURL()); |
| 1852 return YES; | 1843 return YES; |
| 1853 } | 1844 } |
| 1854 return NO; | 1845 return NO; |
| 1855 } | 1846 } |
| 1856 | 1847 |
| 1857 - (void)setFullscreenToolbarVisible:(BOOL)visible { | |
| 1858 if (shouldShowFullscreenToolbar_ == visible) | |
| 1859 return; | |
| 1860 | |
| 1861 shouldShowFullscreenToolbar_ = visible; | |
| 1862 [self adjustUIForSlidingFullscreenStyle: | |
| 1863 shouldShowFullscreenToolbar_ | |
| 1864 ? FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT | |
| 1865 : FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN]; | |
| 1866 } | |
| 1867 | |
| 1868 - (BOOL)isInAnyFullscreenMode { | 1848 - (BOOL)isInAnyFullscreenMode { |
| 1869 return [self isInImmersiveFullscreen] || [self isInAppKitFullscreen]; | 1849 return [self isInImmersiveFullscreen] || [self isInAppKitFullscreen]; |
| 1870 } | 1850 } |
| 1871 | 1851 |
| 1872 - (BOOL)isInImmersiveFullscreen { | 1852 - (BOOL)isInImmersiveFullscreen { |
| 1873 return fullscreenWindow_.get() != nil || enteringImmersiveFullscreen_; | 1853 return fullscreenWindow_.get() != nil || enteringImmersiveFullscreen_; |
| 1874 } | 1854 } |
| 1875 | 1855 |
| 1876 - (BOOL)isInAppKitFullscreen { | 1856 - (BOOL)isInAppKitFullscreen { |
| 1877 return !exitingAppKitFullscreen_ && | 1857 return !exitingAppKitFullscreen_ && |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 [self fullscreenToolbarVisibilityLockController]; | 1930 [self fullscreenToolbarVisibilityLockController]; |
| 1951 [visibilityController releaseToolbarVisibilityForOwner:owner | 1931 [visibilityController releaseToolbarVisibilityForOwner:owner |
| 1952 withAnimation:animate]; | 1932 withAnimation:animate]; |
| 1953 } | 1933 } |
| 1954 | 1934 |
| 1955 - (BOOL)floatingBarHasFocus { | 1935 - (BOOL)floatingBarHasFocus { |
| 1956 NSResponder* focused = [[self window] firstResponder]; | 1936 NSResponder* focused = [[self window] firstResponder]; |
| 1957 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; | 1937 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; |
| 1958 } | 1938 } |
| 1959 | 1939 |
| 1940 - (BOOL)isFullscreenForTabContentOrExtension { |
| 1941 FullscreenController* controller = |
| 1942 browser_->exclusive_access_manager()->fullscreen_controller(); |
| 1943 return controller->IsWindowFullscreenForTabOrPending() || |
| 1944 controller->IsExtensionFullscreenOrPending(); |
| 1945 } |
| 1946 |
| 1960 - (ExclusiveAccessController*)exclusiveAccessController { | 1947 - (ExclusiveAccessController*)exclusiveAccessController { |
| 1961 return exclusiveAccessController_.get(); | 1948 return exclusiveAccessController_.get(); |
| 1962 } | 1949 } |
| 1963 | 1950 |
| 1964 @end // @implementation BrowserWindowController(Fullscreen) | 1951 @end // @implementation BrowserWindowController(Fullscreen) |
| 1965 | 1952 |
| 1966 | 1953 |
| 1967 @implementation BrowserWindowController(WindowType) | 1954 @implementation BrowserWindowController(WindowType) |
| 1968 | 1955 |
| 1969 - (BOOL)supportsWindowFeature:(int)feature { | 1956 - (BOOL)supportsWindowFeature:(int)feature { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1993 | 1980 |
| 1994 - (NSRect)savedRegularWindowFrame { | 1981 - (NSRect)savedRegularWindowFrame { |
| 1995 return savedRegularWindowFrame_; | 1982 return savedRegularWindowFrame_; |
| 1996 } | 1983 } |
| 1997 | 1984 |
| 1998 - (BOOL)isFullscreenTransitionInProgress { | 1985 - (BOOL)isFullscreenTransitionInProgress { |
| 1999 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 1986 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2000 } | 1987 } |
| 2001 | 1988 |
| 2002 @end // @implementation BrowserWindowController(WindowType) | 1989 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |