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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1448 } | 1440 } |
1449 return downloadShelfController_; | 1441 return downloadShelfController_; |
1450 } | 1442 } |
1451 | 1443 |
1452 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 1444 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
1453 // Shouldn't call addFindBar twice. | 1445 // Shouldn't call addFindBar twice. |
1454 DCHECK(!findBarCocoaController_.get()); | 1446 DCHECK(!findBarCocoaController_.get()); |
1455 | 1447 |
1456 // Create a controller for the findbar. | 1448 // Create a controller for the findbar. |
1457 findBarCocoaController_.reset([findBarCocoaController retain]); | 1449 findBarCocoaController_.reset([findBarCocoaController retain]); |
1458 NSView* contentView = [[self window] contentView]; | 1450 [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 | 1451 |
1466 // Place the find bar immediately below the toolbar/attached bookmark bar. In | 1452 // 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 | 1453 // presentation mode, it hangs off the top of the screen when the bar is |
1468 // hidden. | 1454 // hidden. |
1469 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? | 1455 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? |
1470 NSMinY([[toolbarController_ view] frame]) : | 1456 NSMinY([[toolbarController_ view] frame]) : |
1471 NSMinY([[bookmarkBarController_ view] frame]); | 1457 NSMinY([[bookmarkBarController_ view] frame]); |
1472 CGFloat maxWidth = NSWidth([contentView frame]); | 1458 CGFloat maxWidth = NSWidth([[[self window] contentView] frame]); |
1473 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; | 1459 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; |
1474 | 1460 |
1475 // This allows the FindBarCocoaController to call |layoutSubviews| and get | 1461 // This allows the FindBarCocoaController to call |layoutSubviews| and get |
1476 // its position adjusted. | 1462 // its position adjusted. |
1477 [findBarCocoaController_ setBrowserWindowController:self]; | 1463 [findBarCocoaController_ setBrowserWindowController:self]; |
1478 } | 1464 } |
1479 | 1465 |
1480 - (NSWindow*)createFullscreenWindow { | 1466 - (NSWindow*)createFullscreenWindow { |
1481 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 1467 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
1482 autorelease]; | 1468 autorelease]; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1827 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { | 1813 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { |
1828 // Ask the toolbar controller if it wants to return a custom field editor | 1814 // Ask the toolbar controller if it wants to return a custom field editor |
1829 // for the specific object. | 1815 // for the specific object. |
1830 return [toolbarController_ customFieldEditorForObject:obj]; | 1816 return [toolbarController_ customFieldEditorForObject:obj]; |
1831 } | 1817 } |
1832 | 1818 |
1833 // (Needed for |BookmarkBarControllerDelegate| protocol.) | 1819 // (Needed for |BookmarkBarControllerDelegate| protocol.) |
1834 - (void)bookmarkBar:(BookmarkBarController*)controller | 1820 - (void)bookmarkBar:(BookmarkBarController*)controller |
1835 didChangeFromState:(BookmarkBar::State)oldState | 1821 didChangeFromState:(BookmarkBar::State)oldState |
1836 toState:(BookmarkBar::State)newState { | 1822 toState:(BookmarkBar::State)newState { |
1837 [toolbarController_ | 1823 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
1838 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]]; | |
1839 [self adjustToolbarAndBookmarkBarForCompression: | 1824 [self adjustToolbarAndBookmarkBarForCompression: |
1840 [controller getDesiredToolbarHeightCompression]]; | 1825 [controller getDesiredToolbarHeightCompression]]; |
1841 } | 1826 } |
1842 | 1827 |
1843 // (Needed for |BookmarkBarControllerDelegate| protocol.) | 1828 // (Needed for |BookmarkBarControllerDelegate| protocol.) |
1844 - (void)bookmarkBar:(BookmarkBarController*)controller | 1829 - (void)bookmarkBar:(BookmarkBarController*)controller |
1845 willAnimateFromState:(BookmarkBar::State)oldState | 1830 willAnimateFromState:(BookmarkBar::State)oldState |
1846 toState:(BookmarkBar::State)newState { | 1831 toState:(BookmarkBar::State)newState { |
1847 [toolbarController_ | 1832 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
1848 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]]; | |
1849 [self adjustToolbarAndBookmarkBarForCompression: | 1833 [self adjustToolbarAndBookmarkBarForCompression: |
1850 [controller getDesiredToolbarHeightCompression]]; | 1834 [controller getDesiredToolbarHeightCompression]]; |
1851 } | 1835 } |
1852 | 1836 |
1853 // (Private/TestingAPI) | 1837 // (Private/TestingAPI) |
1854 - (void)resetWindowGrowthState { | 1838 - (void)resetWindowGrowthState { |
1855 windowTopGrowth_ = 0; | 1839 windowTopGrowth_ = 0; |
1856 windowBottomGrowth_ = 0; | 1840 windowBottomGrowth_ = 0; |
1857 isShrinkingFromZoomed_ = NO; | 1841 isShrinkingFromZoomed_ = NO; |
1858 } | 1842 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1914 | 1898 |
1915 return frame; | 1899 return frame; |
1916 } | 1900 } |
1917 | 1901 |
1918 - (void)sheetDidEnd:(NSWindow*)sheet | 1902 - (void)sheetDidEnd:(NSWindow*)sheet |
1919 returnCode:(NSInteger)code | 1903 returnCode:(NSInteger)code |
1920 context:(void*)context { | 1904 context:(void*)context { |
1921 [sheet orderOut:self]; | 1905 [sheet orderOut:self]; |
1922 } | 1906 } |
1923 | 1907 |
1908 - (void)updateBookmarkStateForInstantPreview { | |
dhollowa
2013/01/17 17:47:58
optional: updateBookmarkBarStateForInstantPreview
sail
2013/01/17 18:17:12
Done.
| |
1909 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; | |
1910 [self updateContentOffsets]; | |
1911 [self updateSubviewZOrder]; | |
1912 } | |
1913 | |
1924 @end // @implementation BrowserWindowController | 1914 @end // @implementation BrowserWindowController |
1925 | 1915 |
1926 | 1916 |
1927 @implementation BrowserWindowController(Fullscreen) | 1917 @implementation BrowserWindowController(Fullscreen) |
1928 | 1918 |
1929 - (void)handleLionToggleFullscreen { | 1919 - (void)handleLionToggleFullscreen { |
1930 DCHECK(base::mac::IsOSLionOrLater()); | 1920 DCHECK(base::mac::IsOSLionOrLater()); |
1931 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); | 1921 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); |
1932 } | 1922 } |
1933 | 1923 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2172 | 2162 |
2173 - (BOOL)supportsBookmarkBar { | 2163 - (BOOL)supportsBookmarkBar { |
2174 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2164 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2175 } | 2165 } |
2176 | 2166 |
2177 - (BOOL)isTabbedWindow { | 2167 - (BOOL)isTabbedWindow { |
2178 return browser_->is_type_tabbed(); | 2168 return browser_->is_type_tabbed(); |
2179 } | 2169 } |
2180 | 2170 |
2181 @end // @implementation BrowserWindowController(WindowType) | 2171 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |