| 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 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" | 56 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" |
| 57 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" | 57 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" |
| 58 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 58 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 59 #import "chrome/browser/ui/cocoa/tabpose_window.h" | 59 #import "chrome/browser/ui/cocoa/tabpose_window.h" |
| 60 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 60 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 61 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 61 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 62 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 62 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 63 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 63 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 64 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 64 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 65 #include "chrome/browser/ui/omnibox/location_bar.h" | 65 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 66 #include "chrome/browser/ui/search/search.h" |
| 67 #include "chrome/browser/ui/search/search_model.h" |
| 66 #include "chrome/browser/ui/tabs/dock_info.h" | 68 #include "chrome/browser/ui/tabs/dock_info.h" |
| 67 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 69 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 68 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 70 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 69 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 71 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 70 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 72 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
| 71 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 73 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 72 #include "chrome/common/chrome_switches.h" | 74 #include "chrome/common/chrome_switches.h" |
| 73 #include "chrome/common/url_constants.h" | 75 #include "chrome/common/url_constants.h" |
| 74 #include "content/public/browser/render_view_host.h" | 76 #include "content/public/browser/render_view_host.h" |
| 75 #include "content/public/browser/render_widget_host_view.h" | 77 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // registering for the appropriate command state changes from the back-end. | 323 // registering for the appropriate command state changes from the back-end. |
| 322 // Adds the toolbar to the content area. | 324 // Adds the toolbar to the content area. |
| 323 toolbarController_.reset([[ToolbarController alloc] | 325 toolbarController_.reset([[ToolbarController alloc] |
| 324 initWithModel:browser->toolbar_model() | 326 initWithModel:browser->toolbar_model() |
| 325 commands:browser->command_controller()->command_updater() | 327 commands:browser->command_controller()->command_updater() |
| 326 profile:browser->profile() | 328 profile:browser->profile() |
| 327 browser:browser | 329 browser:browser |
| 328 resizeDelegate:self]); | 330 resizeDelegate:self]); |
| 329 [toolbarController_ setHasToolbar:[self hasToolbar] | 331 [toolbarController_ setHasToolbar:[self hasToolbar] |
| 330 hasLocationBar:[self hasLocationBar]]; | 332 hasLocationBar:[self hasLocationBar]]; |
| 331 [[[self window] contentView] addSubview:[toolbarController_ view]]; | |
| 332 | 333 |
| 333 // Create a sub-controller for the bookmark bar. | 334 // Create a sub-controller for the bookmark bar. |
| 334 bookmarkBarController_.reset( | 335 bookmarkBarController_.reset( |
| 335 [[BookmarkBarController alloc] | 336 [[BookmarkBarController alloc] |
| 336 initWithBrowser:browser_.get() | 337 initWithBrowser:browser_.get() |
| 337 initialWidth:NSWidth([[[self window] contentView] frame]) | 338 initialWidth:NSWidth([[[self window] contentView] frame]) |
| 338 delegate:self | 339 delegate:self |
| 339 resizeDelegate:self]); | 340 resizeDelegate:self]); |
| 340 | |
| 341 // Add bookmark bar to the view hierarchy, which also triggers the nib load. | |
| 342 // The bookmark bar is defined (in the nib) to be bottom-aligned to its | |
| 343 // parent view (among other things), so position and resize properties don't | |
| 344 // need to be set. | |
| 345 [[[self window] contentView] addSubview:[bookmarkBarController_ view] | |
| 346 positioned:NSWindowBelow | |
| 347 relativeTo:[toolbarController_ view]]; | |
| 348 [bookmarkBarController_ setBookmarkBarEnabled:[self supportsBookmarkBar]]; | 341 [bookmarkBarController_ setBookmarkBarEnabled:[self supportsBookmarkBar]]; |
| 349 | 342 |
| 350 // Create the infobar container view, so we can pass it to the | 343 // Create the infobar container view, so we can pass it to the |
| 351 // ToolbarController. | 344 // ToolbarController. |
| 352 infoBarContainerController_.reset( | 345 infoBarContainerController_.reset( |
| 353 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); | 346 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); |
| 354 [[[self window] contentView] addSubview:[infoBarContainerController_ view]]; | |
| 355 | 347 |
| 356 // We don't want to try and show the bar before it gets placed in its parent | 348 // We don't want to try and show the bar before it gets placed in its parent |
| 357 // view, so this step shoudn't be inside the bookmark bar controller's | 349 // view, so this step shoudn't be inside the bookmark bar controller's |
| 358 // |-awakeFromNib|. | 350 // |-awakeFromNib|. |
| 359 windowShim_->BookmarkBarStateChanged( | 351 windowShim_->BookmarkBarStateChanged( |
| 360 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 352 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 361 | 353 |
| 362 // Allow bar visibility to be changed. | 354 // Allow bar visibility to be changed. |
| 363 [self enableBarVisibilityUpdates]; | 355 [self enableBarVisibilityUpdates]; |
| 364 | 356 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 } | 459 } |
| 468 | 460 |
| 469 - (ToolbarController*)toolbarController { | 461 - (ToolbarController*)toolbarController { |
| 470 return toolbarController_.get(); | 462 return toolbarController_.get(); |
| 471 } | 463 } |
| 472 | 464 |
| 473 - (TabStripController*)tabStripController { | 465 - (TabStripController*)tabStripController { |
| 474 return tabStripController_.get(); | 466 return tabStripController_.get(); |
| 475 } | 467 } |
| 476 | 468 |
| 469 - (FindBarCocoaController*)findBarCocoaController { |
| 470 return findBarCocoaController_.get(); |
| 471 } |
| 472 |
| 477 - (InfoBarContainerController*)infoBarContainerController { | 473 - (InfoBarContainerController*)infoBarContainerController { |
| 478 return infoBarContainerController_.get(); | 474 return infoBarContainerController_.get(); |
| 479 } | 475 } |
| 480 | 476 |
| 481 - (StatusBubbleMac*)statusBubble { | 477 - (StatusBubbleMac*)statusBubble { |
| 482 return statusBubble_; | 478 return statusBubble_; |
| 483 } | 479 } |
| 484 | 480 |
| 485 - (LocationBarViewMac*)locationBarBridge { | 481 - (LocationBarViewMac*)locationBarBridge { |
| 486 return [toolbarController_ locationBarBridge]; | 482 return [toolbarController_ locationBarBridge]; |
| 487 } | 483 } |
| 488 | 484 |
| 485 - (NSView*)floatingBarBackingView { |
| 486 return floatingBarBackingView_; |
| 487 } |
| 488 |
| 489 - (PreviewableContentsController*)previewableContentsController { |
| 490 return previewableContentsController_; |
| 491 } |
| 492 |
| 489 - (Profile*)profile { | 493 - (Profile*)profile { |
| 490 return browser_->profile(); | 494 return browser_->profile(); |
| 491 } | 495 } |
| 492 | 496 |
| 493 - (AvatarButtonController*)avatarButtonController { | 497 - (AvatarButtonController*)avatarButtonController { |
| 494 return avatarButtonController_.get(); | 498 return avatarButtonController_.get(); |
| 495 } | 499 } |
| 496 | 500 |
| 497 - (void)destroyBrowser { | 501 - (void)destroyBrowser { |
| 498 [NSApp removeWindowsItem:[self window]]; | 502 [NSApp removeWindowsItem:[self window]]; |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 } | 1452 } |
| 1449 return downloadShelfController_; | 1453 return downloadShelfController_; |
| 1450 } | 1454 } |
| 1451 | 1455 |
| 1452 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 1456 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
| 1453 // Shouldn't call addFindBar twice. | 1457 // Shouldn't call addFindBar twice. |
| 1454 DCHECK(!findBarCocoaController_.get()); | 1458 DCHECK(!findBarCocoaController_.get()); |
| 1455 | 1459 |
| 1456 // Create a controller for the findbar. | 1460 // Create a controller for the findbar. |
| 1457 findBarCocoaController_.reset([findBarCocoaController retain]); | 1461 findBarCocoaController_.reset([findBarCocoaController retain]); |
| 1458 NSView* contentView = [[self window] contentView]; | 1462 [self updateSubviewZOrder]; |
| 1459 NSView* relativeView = | |
| 1460 [self inPresentationMode] ? [toolbarController_ view] : | |
| 1461 [infoBarContainerController_ view]; | |
| 1462 [contentView addSubview:[findBarCocoaController_ view] | |
| 1463 positioned:NSWindowAbove | |
| 1464 relativeTo:relativeView]; | |
| 1465 | 1463 |
| 1466 // Place the find bar immediately below the toolbar/attached bookmark bar. In | 1464 // Place the find bar immediately below the toolbar/attached bookmark bar. In |
| 1467 // presentation mode, it hangs off the top of the screen when the bar is | 1465 // presentation mode, it hangs off the top of the screen when the bar is |
| 1468 // hidden. | 1466 // hidden. |
| 1469 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? | 1467 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? |
| 1470 NSMinY([[toolbarController_ view] frame]) : | 1468 NSMinY([[toolbarController_ view] frame]) : |
| 1471 NSMinY([[bookmarkBarController_ view] frame]); | 1469 NSMinY([[bookmarkBarController_ view] frame]); |
| 1472 CGFloat maxWidth = NSWidth([contentView frame]); | 1470 CGFloat maxWidth = NSWidth([[[self window] contentView] frame]); |
| 1473 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; | 1471 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; |
| 1474 | 1472 |
| 1475 // This allows the FindBarCocoaController to call |layoutSubviews| and get | 1473 // This allows the FindBarCocoaController to call |layoutSubviews| and get |
| 1476 // its position adjusted. | 1474 // its position adjusted. |
| 1477 [findBarCocoaController_ setBrowserWindowController:self]; | 1475 [findBarCocoaController_ setBrowserWindowController:self]; |
| 1478 } | 1476 } |
| 1479 | 1477 |
| 1480 - (NSWindow*)createFullscreenWindow { | 1478 - (NSWindow*)createFullscreenWindow { |
| 1481 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 1479 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
| 1482 autorelease]; | 1480 autorelease]; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { | 1825 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { |
| 1828 // Ask the toolbar controller if it wants to return a custom field editor | 1826 // Ask the toolbar controller if it wants to return a custom field editor |
| 1829 // for the specific object. | 1827 // for the specific object. |
| 1830 return [toolbarController_ customFieldEditorForObject:obj]; | 1828 return [toolbarController_ customFieldEditorForObject:obj]; |
| 1831 } | 1829 } |
| 1832 | 1830 |
| 1833 // (Needed for |BookmarkBarControllerDelegate| protocol.) | 1831 // (Needed for |BookmarkBarControllerDelegate| protocol.) |
| 1834 - (void)bookmarkBar:(BookmarkBarController*)controller | 1832 - (void)bookmarkBar:(BookmarkBarController*)controller |
| 1835 didChangeFromState:(BookmarkBar::State)oldState | 1833 didChangeFromState:(BookmarkBar::State)oldState |
| 1836 toState:(BookmarkBar::State)newState { | 1834 toState:(BookmarkBar::State)newState { |
| 1837 [toolbarController_ | 1835 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
| 1838 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]]; | |
| 1839 [self adjustToolbarAndBookmarkBarForCompression: | 1836 [self adjustToolbarAndBookmarkBarForCompression: |
| 1840 [controller getDesiredToolbarHeightCompression]]; | 1837 [controller getDesiredToolbarHeightCompression]]; |
| 1841 } | 1838 } |
| 1842 | 1839 |
| 1843 // (Needed for |BookmarkBarControllerDelegate| protocol.) | 1840 // (Needed for |BookmarkBarControllerDelegate| protocol.) |
| 1844 - (void)bookmarkBar:(BookmarkBarController*)controller | 1841 - (void)bookmarkBar:(BookmarkBarController*)controller |
| 1845 willAnimateFromState:(BookmarkBar::State)oldState | 1842 willAnimateFromState:(BookmarkBar::State)oldState |
| 1846 toState:(BookmarkBar::State)newState { | 1843 toState:(BookmarkBar::State)newState { |
| 1847 [toolbarController_ | 1844 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
| 1848 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]]; | |
| 1849 [self adjustToolbarAndBookmarkBarForCompression: | 1845 [self adjustToolbarAndBookmarkBarForCompression: |
| 1850 [controller getDesiredToolbarHeightCompression]]; | 1846 [controller getDesiredToolbarHeightCompression]]; |
| 1851 } | 1847 } |
| 1852 | 1848 |
| 1853 // (Private/TestingAPI) | 1849 // (Private/TestingAPI) |
| 1854 - (void)resetWindowGrowthState { | 1850 - (void)resetWindowGrowthState { |
| 1855 windowTopGrowth_ = 0; | 1851 windowTopGrowth_ = 0; |
| 1856 windowBottomGrowth_ = 0; | 1852 windowBottomGrowth_ = 0; |
| 1857 isShrinkingFromZoomed_ = NO; | 1853 isShrinkingFromZoomed_ = NO; |
| 1858 } | 1854 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 | 1910 |
| 1915 return frame; | 1911 return frame; |
| 1916 } | 1912 } |
| 1917 | 1913 |
| 1918 - (void)sheetDidEnd:(NSWindow*)sheet | 1914 - (void)sheetDidEnd:(NSWindow*)sheet |
| 1919 returnCode:(NSInteger)code | 1915 returnCode:(NSInteger)code |
| 1920 context:(void*)context { | 1916 context:(void*)context { |
| 1921 [sheet orderOut:self]; | 1917 [sheet orderOut:self]; |
| 1922 } | 1918 } |
| 1923 | 1919 |
| 1920 - (void)updateBookmarkBarStateForInstantPreview { |
| 1921 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
| 1922 [self updateContentOffsets]; |
| 1923 [self updateSubviewZOrder]; |
| 1924 } |
| 1925 |
| 1924 @end // @implementation BrowserWindowController | 1926 @end // @implementation BrowserWindowController |
| 1925 | 1927 |
| 1926 | 1928 |
| 1927 @implementation BrowserWindowController(Fullscreen) | 1929 @implementation BrowserWindowController(Fullscreen) |
| 1928 | 1930 |
| 1929 - (void)handleLionToggleFullscreen { | 1931 - (void)handleLionToggleFullscreen { |
| 1930 DCHECK(base::mac::IsOSLionOrLater()); | 1932 DCHECK(base::mac::IsOSLionOrLater()); |
| 1931 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); | 1933 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); |
| 1932 } | 1934 } |
| 1933 | 1935 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 | 2174 |
| 2173 - (BOOL)supportsBookmarkBar { | 2175 - (BOOL)supportsBookmarkBar { |
| 2174 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2176 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2175 } | 2177 } |
| 2176 | 2178 |
| 2177 - (BOOL)isTabbedWindow { | 2179 - (BOOL)isTabbedWindow { |
| 2178 return browser_->is_type_tabbed(); | 2180 return browser_->is_type_tabbed(); |
| 2179 } | 2181 } |
| 2180 | 2182 |
| 2181 @end // @implementation BrowserWindowController(WindowType) | 2183 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |