| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include <Carbon/Carbon.h> | 5 #include <Carbon/Carbon.h> |
| 6 | 6 |
| 7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
| 8 #include "base/scoped_nsdisable_screen_updates.h" | 8 #include "base/scoped_nsdisable_screen_updates.h" |
| 9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 - (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; | 57 - (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; |
| 58 | 58 |
| 59 - (void)setBottomCornerRounded:(BOOL)rounded; | 59 - (void)setBottomCornerRounded:(BOOL)rounded; |
| 60 | 60 |
| 61 - (NSRect)_growBoxRect; | 61 - (NSRect)_growBoxRect; |
| 62 @end | 62 @end |
| 63 | 63 |
| 64 | 64 |
| 65 @interface BrowserWindowController(Private) | 65 @interface BrowserWindowController(Private) |
| 66 | 66 |
| 67 - (void)positionToolbar; | 67 - (void)positionBar; |
| 68 - (void)removeToolbar; | 68 - (void)removeBar; |
| 69 - (void)installIncognitoBadge; | 69 - (void)installIncognitoBadge; |
| 70 | 70 |
| 71 // Leopard's gradient heuristic gets confused by our tabs and makes the title | 71 // Leopard's gradient heuristic gets confused by our tabs and makes the title |
| 72 // gradient jump when creating a tab that is less than a tab width from the | 72 // gradient jump when creating a tab that is less than a tab width from the |
| 73 // right side of the screen. This function disables Leopard's gradient | 73 // right side of the screen. This function disables Leopard's gradient |
| 74 // heuristic. | 74 // heuristic. |
| 75 - (void)fixWindowGradient; | 75 - (void)fixWindowGradient; |
| 76 | 76 |
| 77 // Called by the Notification Center whenever the tabContentArea's | 77 // Called by the Notification Center whenever the tabContentArea's |
| 78 // frame changes. Re-positions the bookmark bar and the find bar. | 78 // frame changes. Re-positions the bookmark bar and the find bar. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 // Create a controller for the toolbar, giving it the toolbar model object | 169 // Create a controller for the toolbar, giving it the toolbar model object |
| 170 // and the toolbar view from the nib. The controller will handle | 170 // and the toolbar view from the nib. The controller will handle |
| 171 // registering for the appropriate command state changes from the back-end. | 171 // registering for the appropriate command state changes from the back-end. |
| 172 toolbarController_.reset([[ToolbarController alloc] | 172 toolbarController_.reset([[ToolbarController alloc] |
| 173 initWithModel:browser->toolbar_model() | 173 initWithModel:browser->toolbar_model() |
| 174 commands:browser->command_updater() | 174 commands:browser->command_updater() |
| 175 profile:browser->profile() | 175 profile:browser->profile() |
| 176 webContentView:[self tabContentArea] | 176 webContentView:[self tabContentArea] |
| 177 bookmarkDelegate:self]); | 177 bookmarkDelegate:self]); |
| 178 [self positionToolbar]; | 178 // If we are a pop-up, we have a titlebar and no toolbar. |
| 179 if (!browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) && |
| 180 browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR)) { |
| 181 [toolbarController_ setHasToolbar:NO]; |
| 182 } |
| 183 [self positionBar]; |
| 179 [self fixWindowGradient]; | 184 [self fixWindowGradient]; |
| 180 | 185 |
| 181 // Create the bridge for the status bubble. | 186 // Create the bridge for the status bubble. |
| 182 statusBubble_.reset(new StatusBubbleMac([self window])); | 187 statusBubble_.reset(new StatusBubbleMac([self window])); |
| 183 | 188 |
| 184 #if 0 | 189 #if 0 |
| 185 // Move all buttons down two pixels for visual balance. | 190 // Move all buttons down two pixels for visual balance. |
| 186 // TODO(alcor): remove this if we can't prevent window resize from breaking. | 191 // TODO(alcor): remove this if we can't prevent window resize from breaking. |
| 187 NSArray* buttons = | 192 NSArray* buttons = |
| 188 [NSArray arrayWithObjects: | 193 [NSArray arrayWithObjects: |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 } | 654 } |
| 650 | 655 |
| 651 // Adjust the UI for fullscreen mode. E.g. when going fullscreen, | 656 // Adjust the UI for fullscreen mode. E.g. when going fullscreen, |
| 652 // remove the toolbar. When stopping fullscreen, add it back in. | 657 // remove the toolbar. When stopping fullscreen, add it back in. |
| 653 - (void)adjustUIForFullscreen:(BOOL)fullscreen { | 658 - (void)adjustUIForFullscreen:(BOOL)fullscreen { |
| 654 if (fullscreen) { | 659 if (fullscreen) { |
| 655 // Disable showing of the bookmark bar. This does not toggle the | 660 // Disable showing of the bookmark bar. This does not toggle the |
| 656 // preference. | 661 // preference. |
| 657 [[toolbarController_ bookmarkBarController] setBookmarkBarEnabled:NO]; | 662 [[toolbarController_ bookmarkBarController] setBookmarkBarEnabled:NO]; |
| 658 // Make room for more content area. | 663 // Make room for more content area. |
| 659 [self removeToolbar]; | 664 [self removeBar]; |
| 660 // Hide the menubar, and allow it to un-hide when moving the mouse | 665 // Hide the menubar, and allow it to un-hide when moving the mouse |
| 661 // to the top of the screen. Does this eliminate the need for an | 666 // to the top of the screen. Does this eliminate the need for an |
| 662 // info bubble describing how to exit fullscreen mode? | 667 // info bubble describing how to exit fullscreen mode? |
| 663 SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); | 668 SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
| 664 } else { | 669 } else { |
| 665 SetSystemUIMode(kUIModeNormal, 0); | 670 SetSystemUIMode(kUIModeNormal, 0); |
| 666 [self positionToolbar]; | 671 [self positionBar]; |
| 667 [[toolbarController_ bookmarkBarController] setBookmarkBarEnabled:YES]; | 672 [[toolbarController_ bookmarkBarController] setBookmarkBarEnabled:YES]; |
| 668 } | 673 } |
| 669 } | 674 } |
| 670 | 675 |
| 671 - (NSWindow*)fullscreenWindow { | 676 - (NSWindow*)fullscreenWindow { |
| 672 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 677 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
| 673 autorelease]; | 678 autorelease]; |
| 674 } | 679 } |
| 675 | 680 |
| 676 - (void)setFullscreen:(BOOL)fullscreen { | 681 - (void)setFullscreen:(BOOL)fullscreen { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 781 |
| 777 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window { | 782 - (GTMTheme *)gtm_themeForWindow:(NSWindow*)window { |
| 778 return theme_ ? theme_ : [GTMTheme defaultTheme]; | 783 return theme_ ? theme_ : [GTMTheme defaultTheme]; |
| 779 } | 784 } |
| 780 | 785 |
| 781 @end | 786 @end |
| 782 | 787 |
| 783 @implementation BrowserWindowController (Private) | 788 @implementation BrowserWindowController (Private) |
| 784 | 789 |
| 785 // If |add| is YES: | 790 // If |add| is YES: |
| 786 // Position |toolbarView_| below the tab strip, but not as a | 791 // Position |barView| below the tab strip, but not as a sibling. The |
| 787 // sibling. The toolbar is part of the window's contentView, mainly | 792 // toolbar or titlebar is part of the window's contentView, mainly |
| 788 // because we want the opacity during drags to be the same as the web | 793 // because we want the opacity during drags to be the same as the web |
| 789 // content. This can be used for either the initial add or a | 794 // content. This can be used for either the initial add or a |
| 790 // reposition. | 795 // reposition. |
| 791 // If |add| is NO: | 796 // If |add| is NO: |
| 792 // Remove the toolbar from it's parent view (the window's content view). | 797 // Remove the toolbar or titlebar from it's parent view (the window's |
| 793 // Called when going fullscreen and we need to minimize UI. | 798 // content view). Called when going fullscreen and we need to |
| 794 - (void)positionOrRemoveToolbar:(BOOL)add { | 799 // minimize UI. |
| 800 - (void)positionOrRemoveBar:(BOOL)add { |
| 801 NSView* barView = [toolbarController_ view]; |
| 802 NSRect barFrame = [barView frame]; |
| 795 NSView* contentView = [self tabContentArea]; | 803 NSView* contentView = [self tabContentArea]; |
| 796 NSRect contentFrame = [contentView frame]; | 804 NSRect contentFrame = [contentView frame]; |
| 797 NSView* toolbarView = [toolbarController_ view]; | |
| 798 NSRect toolbarFrame = [toolbarView frame]; | |
| 799 | 805 |
| 800 // Shrink or grow the content area by the height of the toolbar. | 806 // Shrink or grow the content area by the height of the toolbar. |
| 801 if (add) | 807 if (add) |
| 802 contentFrame.size.height -= toolbarFrame.size.height; | 808 contentFrame.size.height -= barFrame.size.height; |
| 803 else | 809 else |
| 804 contentFrame.size.height += toolbarFrame.size.height; | 810 contentFrame.size.height += barFrame.size.height; |
| 805 [contentView setFrame:contentFrame]; | 811 [contentView setFrame:contentFrame]; |
| 806 | 812 |
| 807 if (add) { | 813 if (add) { |
| 808 // Move the toolbar above the content area, within the window's content view | 814 // Move the toolbar above the content area, within the window's content view |
| 809 // (as opposed to the tab strip, which is a sibling). | 815 // (as opposed to the tab strip, which is a sibling). |
| 810 toolbarFrame.origin.y = NSMaxY(contentFrame); | 816 barFrame.origin.y = NSMaxY(contentFrame); |
| 811 toolbarFrame.origin.x = 0; | 817 barFrame.origin.x = 0; |
| 812 toolbarFrame.size.width = contentFrame.size.width; | 818 barFrame.size.width = contentFrame.size.width; |
| 813 [toolbarView setFrame:toolbarFrame]; | 819 [barView setFrame:barFrame]; |
| 814 [[[self window] contentView] addSubview:toolbarView]; | 820 [[[self window] contentView] addSubview:barView]; |
| 815 } else { | 821 } else { |
| 816 [toolbarView removeFromSuperview]; | 822 [barView removeFromSuperview]; |
| 817 } | 823 } |
| 818 } | 824 } |
| 819 | 825 |
| 820 - (void)positionToolbar { | 826 - (void)positionBar { |
| 821 [self positionOrRemoveToolbar:YES]; | 827 [self positionOrRemoveBar:YES]; |
| 822 } | 828 } |
| 823 | 829 |
| 824 - (void)removeToolbar { | 830 - (void)removeBar { |
| 825 [self positionOrRemoveToolbar:NO]; | 831 [self positionOrRemoveBar:NO]; |
| 826 } | 832 } |
| 827 | 833 |
| 828 // If the browser is in incognito mode, install the image view to decorate | 834 // If the browser is in incognito mode, install the image view to decorate |
| 829 // the window at the upper right. Use the same base y coordinate as the | 835 // the window at the upper right. Use the same base y coordinate as the |
| 830 // tab strip. | 836 // tab strip. |
| 831 - (void)installIncognitoBadge { | 837 - (void)installIncognitoBadge { |
| 832 if (!browser_->profile()->IsOffTheRecord()) | 838 if (!browser_->profile()->IsOffTheRecord()) |
| 833 return; | 839 return; |
| 834 | 840 |
| 835 static const float kOffset = 4; | 841 static const float kOffset = 4; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; | 1061 NSColor* toolbarButtonBorderColor = toolbarButtonIconColor; |
| 1056 [theme setValue:toolbarButtonBorderColor | 1062 [theme setValue:toolbarButtonBorderColor |
| 1057 forAttribute:@"borderColor" | 1063 forAttribute:@"borderColor" |
| 1058 style:GTMThemeStyleToolBar | 1064 style:GTMThemeStyleToolBar |
| 1059 state:YES]; | 1065 state:YES]; |
| 1060 | 1066 |
| 1061 return theme; | 1067 return theme; |
| 1062 } | 1068 } |
| 1063 @end | 1069 @end |
| 1064 | 1070 |
| OLD | NEW |