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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 11876036: Alternate NTP: Don't hide bookmark bar on instant (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 7 years, 11 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 | Annotate | Revision Log
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 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" 60 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
61 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" 61 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h"
62 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 62 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
63 #import "chrome/browser/ui/cocoa/tabpose_window.h" 63 #import "chrome/browser/ui/cocoa/tabpose_window.h"
64 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 64 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
65 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 65 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
66 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 66 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
67 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 67 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
68 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 68 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
69 #include "chrome/browser/ui/omnibox/location_bar.h" 69 #include "chrome/browser/ui/omnibox/location_bar.h"
70 #include "chrome/browser/ui/search/search.h"
71 #include "chrome/browser/ui/search/search_model.h"
70 #include "chrome/browser/ui/tabs/dock_info.h" 72 #include "chrome/browser/ui/tabs/dock_info.h"
71 #include "chrome/browser/ui/tabs/tab_strip_model.h" 73 #include "chrome/browser/ui/tabs/tab_strip_model.h"
72 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 74 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
73 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 75 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
74 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 76 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
75 #include "chrome/browser/ui/window_sizer/window_sizer.h" 77 #include "chrome/browser/ui/window_sizer/window_sizer.h"
76 #include "chrome/common/chrome_switches.h" 78 #include "chrome/common/chrome_switches.h"
77 #include "chrome/common/url_constants.h" 79 #include "chrome/common/url_constants.h"
78 #include "content/public/browser/render_view_host.h" 80 #include "content/public/browser/render_view_host.h"
79 #include "content/public/browser/render_widget_host_view.h" 81 #include "content/public/browser/render_widget_host_view.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // registering for the appropriate command state changes from the back-end. 387 // registering for the appropriate command state changes from the back-end.
386 // Adds the toolbar to the content area. 388 // Adds the toolbar to the content area.
387 toolbarController_.reset([[ToolbarController alloc] 389 toolbarController_.reset([[ToolbarController alloc]
388 initWithModel:browser->toolbar_model() 390 initWithModel:browser->toolbar_model()
389 commands:browser->command_controller()->command_updater() 391 commands:browser->command_controller()->command_updater()
390 profile:browser->profile() 392 profile:browser->profile()
391 browser:browser 393 browser:browser
392 resizeDelegate:self]); 394 resizeDelegate:self]);
393 [toolbarController_ setHasToolbar:[self hasToolbar] 395 [toolbarController_ setHasToolbar:[self hasToolbar]
394 hasLocationBar:[self hasLocationBar]]; 396 hasLocationBar:[self hasLocationBar]];
395 [[[self window] contentView] addSubview:[toolbarController_ view]];
396 397
397 // Create a sub-controller for the bookmark bar. 398 // Create a sub-controller for the bookmark bar.
398 bookmarkBarController_.reset( 399 bookmarkBarController_.reset(
399 [[BookmarkBarController alloc] 400 [[BookmarkBarController alloc]
400 initWithBrowser:browser_.get() 401 initWithBrowser:browser_.get()
401 initialWidth:NSWidth([[[self window] contentView] frame]) 402 initialWidth:NSWidth([[[self window] contentView] frame])
402 delegate:self 403 delegate:self
403 resizeDelegate:self]); 404 resizeDelegate:self]);
404
405 // Add bookmark bar to the view hierarchy, which also triggers the nib load.
406 // The bookmark bar is defined (in the nib) to be bottom-aligned to its
407 // parent view (among other things), so position and resize properties don't
408 // need to be set.
409 [[[self window] contentView] addSubview:[bookmarkBarController_ view]
410 positioned:NSWindowBelow
411 relativeTo:[toolbarController_ view]];
412 [bookmarkBarController_ setBookmarkBarEnabled:[self supportsBookmarkBar]]; 405 [bookmarkBarController_ setBookmarkBarEnabled:[self supportsBookmarkBar]];
413 406
414 // Create the infobar container view, so we can pass it to the 407 // Create the infobar container view, so we can pass it to the
415 // ToolbarController. 408 // ToolbarController.
416 infoBarContainerController_.reset( 409 infoBarContainerController_.reset(
417 [[InfoBarContainerController alloc] initWithResizeDelegate:self]); 410 [[InfoBarContainerController alloc] initWithResizeDelegate:self]);
418 [[[self window] contentView] addSubview:[infoBarContainerController_ view]];
419 411
420 // We don't want to try and show the bar before it gets placed in its parent 412 // We don't want to try and show the bar before it gets placed in its parent
421 // view, so this step shoudn't be inside the bookmark bar controller's 413 // view, so this step shoudn't be inside the bookmark bar controller's
422 // |-awakeFromNib|. 414 // |-awakeFromNib|.
423 windowShim_->BookmarkBarStateChanged( 415 windowShim_->BookmarkBarStateChanged(
424 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 416 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
425 417
426 // Allow bar visibility to be changed. 418 // Allow bar visibility to be changed.
427 [self enableBarVisibilityUpdates]; 419 [self enableBarVisibilityUpdates];
428 420
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 523 }
532 524
533 - (ToolbarController*)toolbarController { 525 - (ToolbarController*)toolbarController {
534 return toolbarController_.get(); 526 return toolbarController_.get();
535 } 527 }
536 528
537 - (TabStripController*)tabStripController { 529 - (TabStripController*)tabStripController {
538 return tabStripController_.get(); 530 return tabStripController_.get();
539 } 531 }
540 532
533 - (FindBarCocoaController*)findBarCocoaController {
534 return findBarCocoaController_.get();
535 }
536
541 - (InfoBarContainerController*)infoBarContainerController { 537 - (InfoBarContainerController*)infoBarContainerController {
542 return infoBarContainerController_.get(); 538 return infoBarContainerController_.get();
543 } 539 }
544 540
545 - (StatusBubbleMac*)statusBubble { 541 - (StatusBubbleMac*)statusBubble {
546 return statusBubble_; 542 return statusBubble_;
547 } 543 }
548 544
549 - (LocationBarViewMac*)locationBarBridge { 545 - (LocationBarViewMac*)locationBarBridge {
550 return [toolbarController_ locationBarBridge]; 546 return [toolbarController_ locationBarBridge];
551 } 547 }
552 548
549 - (NSView*)floatingBarBackingView {
550 return floatingBarBackingView_;
551 }
552
553 - (PreviewableContentsController*)previewableContentsController {
554 return previewableContentsController_;
555 }
556
553 - (Profile*)profile { 557 - (Profile*)profile {
554 return browser_->profile(); 558 return browser_->profile();
555 } 559 }
556 560
557 - (AvatarButtonController*)avatarButtonController { 561 - (AvatarButtonController*)avatarButtonController {
558 return avatarButtonController_.get(); 562 return avatarButtonController_.get();
559 } 563 }
560 564
561 - (void)destroyBrowser { 565 - (void)destroyBrowser {
562 [NSApp removeWindowsItem:[self window]]; 566 [NSApp removeWindowsItem:[self window]];
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 } 1525 }
1522 return downloadShelfController_; 1526 return downloadShelfController_;
1523 } 1527 }
1524 1528
1525 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { 1529 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController {
1526 // Shouldn't call addFindBar twice. 1530 // Shouldn't call addFindBar twice.
1527 DCHECK(!findBarCocoaController_.get()); 1531 DCHECK(!findBarCocoaController_.get());
1528 1532
1529 // Create a controller for the findbar. 1533 // Create a controller for the findbar.
1530 findBarCocoaController_.reset([findBarCocoaController retain]); 1534 findBarCocoaController_.reset([findBarCocoaController retain]);
1531 NSView* contentView = [[self window] contentView]; 1535 [self updateSubviewZOrder];
1532 NSView* relativeView =
1533 [self inPresentationMode] ? [toolbarController_ view] :
1534 [infoBarContainerController_ view];
1535 [contentView addSubview:[findBarCocoaController_ view]
1536 positioned:NSWindowAbove
1537 relativeTo:relativeView];
1538 1536
1539 // Place the find bar immediately below the toolbar/attached bookmark bar. In 1537 // Place the find bar immediately below the toolbar/attached bookmark bar. In
1540 // presentation mode, it hangs off the top of the screen when the bar is 1538 // presentation mode, it hangs off the top of the screen when the bar is
1541 // hidden. 1539 // hidden.
1542 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? 1540 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ?
1543 NSMinY([[toolbarController_ view] frame]) : 1541 NSMinY([[toolbarController_ view] frame]) :
1544 NSMinY([[bookmarkBarController_ view] frame]); 1542 NSMinY([[bookmarkBarController_ view] frame]);
1545 CGFloat maxWidth = NSWidth([contentView frame]); 1543 CGFloat maxWidth = NSWidth([[[self window] contentView] frame]);
1546 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; 1544 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth];
1547 1545
1548 // This allows the FindBarCocoaController to call |layoutSubviews| and get 1546 // This allows the FindBarCocoaController to call |layoutSubviews| and get
1549 // its position adjusted. 1547 // its position adjusted.
1550 [findBarCocoaController_ setBrowserWindowController:self]; 1548 [findBarCocoaController_ setBrowserWindowController:self];
1551 } 1549 }
1552 1550
1553 - (NSWindow*)createFullscreenWindow { 1551 - (NSWindow*)createFullscreenWindow {
1554 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] 1552 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]]
1555 autorelease]; 1553 autorelease];
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { 1900 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj {
1903 // Ask the toolbar controller if it wants to return a custom field editor 1901 // Ask the toolbar controller if it wants to return a custom field editor
1904 // for the specific object. 1902 // for the specific object.
1905 return [toolbarController_ customFieldEditorForObject:obj]; 1903 return [toolbarController_ customFieldEditorForObject:obj];
1906 } 1904 }
1907 1905
1908 // (Needed for |BookmarkBarControllerDelegate| protocol.) 1906 // (Needed for |BookmarkBarControllerDelegate| protocol.)
1909 - (void)bookmarkBar:(BookmarkBarController*)controller 1907 - (void)bookmarkBar:(BookmarkBarController*)controller
1910 didChangeFromState:(BookmarkBar::State)oldState 1908 didChangeFromState:(BookmarkBar::State)oldState
1911 toState:(BookmarkBar::State)newState { 1909 toState:(BookmarkBar::State)newState {
1912 [toolbarController_ 1910 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]];
1913 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]];
1914 [self adjustToolbarAndBookmarkBarForCompression: 1911 [self adjustToolbarAndBookmarkBarForCompression:
1915 [controller getDesiredToolbarHeightCompression]]; 1912 [controller getDesiredToolbarHeightCompression]];
1916 } 1913 }
1917 1914
1918 // (Needed for |BookmarkBarControllerDelegate| protocol.) 1915 // (Needed for |BookmarkBarControllerDelegate| protocol.)
1919 - (void)bookmarkBar:(BookmarkBarController*)controller 1916 - (void)bookmarkBar:(BookmarkBarController*)controller
1920 willAnimateFromState:(BookmarkBar::State)oldState 1917 willAnimateFromState:(BookmarkBar::State)oldState
1921 toState:(BookmarkBar::State)newState { 1918 toState:(BookmarkBar::State)newState {
1922 [toolbarController_ 1919 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]];
1923 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]];
1924 [self adjustToolbarAndBookmarkBarForCompression: 1920 [self adjustToolbarAndBookmarkBarForCompression:
1925 [controller getDesiredToolbarHeightCompression]]; 1921 [controller getDesiredToolbarHeightCompression]];
1926 } 1922 }
1927 1923
1928 // (Private/TestingAPI) 1924 // (Private/TestingAPI)
1929 - (void)resetWindowGrowthState { 1925 - (void)resetWindowGrowthState {
1930 windowTopGrowth_ = 0; 1926 windowTopGrowth_ = 0;
1931 windowBottomGrowth_ = 0; 1927 windowBottomGrowth_ = 0;
1932 isShrinkingFromZoomed_ = NO; 1928 isShrinkingFromZoomed_ = NO;
1933 } 1929 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 1980
1985 return frame; 1981 return frame;
1986 } 1982 }
1987 1983
1988 - (void)sheetDidEnd:(NSWindow*)sheet 1984 - (void)sheetDidEnd:(NSWindow*)sheet
1989 returnCode:(NSInteger)code 1985 returnCode:(NSInteger)code
1990 context:(void*)context { 1986 context:(void*)context {
1991 [sheet orderOut:self]; 1987 [sheet orderOut:self];
1992 } 1988 }
1993 1989
1990 - (void)updateBookmarkBarStateForInstantPreview {
1991 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]];
1992 [self updateContentOffsets];
1993 [self updateSubviewZOrder];
1994 }
1995
1994 @end // @implementation BrowserWindowController 1996 @end // @implementation BrowserWindowController
1995 1997
1996 1998
1997 @implementation BrowserWindowController(Fullscreen) 1999 @implementation BrowserWindowController(Fullscreen)
1998 2000
1999 - (void)handleLionToggleFullscreen { 2001 - (void)handleLionToggleFullscreen {
2000 DCHECK(base::mac::IsOSLionOrLater()); 2002 DCHECK(base::mac::IsOSLionOrLater());
2001 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); 2003 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN);
2002 } 2004 }
2003 2005
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 2244
2243 - (BOOL)supportsBookmarkBar { 2245 - (BOOL)supportsBookmarkBar {
2244 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2246 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2245 } 2247 }
2246 2248
2247 - (BOOL)isTabbedWindow { 2249 - (BOOL)isTabbedWindow {
2248 return browser_->is_type_tabbed(); 2250 return browser_->is_type_tabbed();
2249 } 2251 }
2250 2252
2251 @end // @implementation BrowserWindowController(WindowType) 2253 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698