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

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

Issue 149094: Removes our homespun grow box and replaces it with the... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 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 (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 "base/mac_util.h" 5 #include "base/mac_util.h"
6 #include "base/scoped_nsdisable_screen_updates.h" 6 #include "base/scoped_nsdisable_screen_updates.h"
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/app/chrome_dll_resource.h" // IDC_* 8 #include "chrome/app/chrome_dll_resource.h" // IDC_*
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/common/pref_service.h" 29 #include "chrome/common/pref_service.h"
30 30
31 namespace { 31 namespace {
32 32
33 // Size of the gradient. Empirically determined so that the gradient looks 33 // Size of the gradient. Empirically determined so that the gradient looks
34 // like what the heuristic does when there are just a few tabs. 34 // like what the heuristic does when there are just a few tabs.
35 const int kWindowGradientHeight = 24; 35 const int kWindowGradientHeight = 24;
36 36
37 } 37 }
38 38
39 @interface NSWindow (NSPrivateApis)
40 // Note: These functions are private, use -[NSObject respondsToSelector:]
41 // before calling them.
42
43 - (void)setAutorecalculatesContentBorderThickness:(BOOL)b
44 forEdge:(NSRectEdge)e;
45 - (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e;
46
47 - (void)setBottomCornerRounded:(BOOL)rounded;
48
49 - (NSRect)_growBoxRect;
50 @end
51
52
39 @interface BrowserWindowController(Private) 53 @interface BrowserWindowController(Private)
40 54
41 - (void)positionToolbar; 55 - (void)positionToolbar;
42 - (void)installIncognitoBadge; 56 - (void)installIncognitoBadge;
43 57
44 // Leopard's gradient heuristic gets confused by our tabs and makes the title 58 // Leopard's gradient heuristic gets confused by our tabs and makes the title
45 // gradient jump when creating a tab that is less than a tab width from the 59 // gradient jump when creating a tab that is less than a tab width from the
46 // right side of the screen. This function disables Leopard's gradient 60 // right side of the screen. This function disables Leopard's gradient
47 // heuristic. 61 // heuristic.
48 - (void)fixWindowGradient; 62 - (void)fixWindowGradient;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 tabObserver_.reset( 102 tabObserver_.reset(
89 new TabStripModelObserverBridge(browser->tabstrip_model(), self)); 103 new TabStripModelObserverBridge(browser->tabstrip_model(), self));
90 windowShim_.reset(new BrowserWindowCocoa(browser, self, [self window])); 104 windowShim_.reset(new BrowserWindowCocoa(browser, self, [self window]));
91 105
92 // The window is now fully realized and |-windowDidLoad:| has been 106 // The window is now fully realized and |-windowDidLoad:| has been
93 // called. We shouldn't do much in wDL because |windowShim_| won't yet 107 // called. We shouldn't do much in wDL because |windowShim_| won't yet
94 // be initialized (as it's called in response to |[self window]| above). 108 // be initialized (as it's called in response to |[self window]| above).
95 // Retain it per the comment in the header. 109 // Retain it per the comment in the header.
96 window_.reset([[self window] retain]); 110 window_.reset([[self window] retain]);
97 111
112 // Sets the window to not have rounded corners, which prevents
113 // the resize control from being inset slightly and looking ugly.
114 if ([window_ respondsToSelector:@selector(setBottomCornerRounded:)])
115 [window_ setBottomCornerRounded:NO];
116
98 // Since we don't have a standard resize control, Cocoa won't enable the 117 // Since we don't have a standard resize control, Cocoa won't enable the
99 // zoom (green) button on the titlebar for us. Grab it and enable it 118 // zoom (green) button on the titlebar for us. Grab it and enable it
100 // manually. Note that when launched from XCode, the doesn't work for the 119 // manually. Note that when launched from XCode, the doesn't work for the
101 // first window (and only the first window). There's some activation 120 // first window (and only the first window). There's some activation
102 // wonkiness there, since XCode stays active and the menus don't switch 121 // wonkiness there, since XCode stays active and the menus don't switch
103 // either. It always works when launched from the Finder. 122 // either. It always works when launched from the Finder.
104 NSButton* zoomButton = 123 NSButton* zoomButton =
105 [[self window] standardWindowButton:NSWindowZoomButton]; 124 [[self window] standardWindowButton:NSWindowZoomButton];
106 [zoomButton setEnabled:YES]; 125 [zoomButton setEnabled:YES];
107 126
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 396 }
378 397
379 - (void)setStarredState:(BOOL)isStarred { 398 - (void)setStarredState:(BOOL)isStarred {
380 [toolbarController_ setStarredState:isStarred]; 399 [toolbarController_ setStarredState:isStarred];
381 } 400 }
382 401
383 // Return the rect, in WebKit coordinates (flipped), of the window's grow box 402 // Return the rect, in WebKit coordinates (flipped), of the window's grow box
384 // in the coordinate system of the content area of the currently selected tab. 403 // in the coordinate system of the content area of the currently selected tab.
385 // |windowGrowBox| needs to be in the window's coordinate system. 404 // |windowGrowBox| needs to be in the window's coordinate system.
386 - (NSRect)selectedTabGrowBoxRect { 405 - (NSRect)selectedTabGrowBoxRect {
387 return [tabStripController_ selectedTabGrowBoxRect]; 406 if (![window_ respondsToSelector:@selector(_growBoxRect)])
407 return NSZeroRect;
408
409 // Before we return a rect, we need to convert it from window coordinates
410 // to tab content area coordinates and flip the coordinate system.
411 NSRect growBoxRect =
412 [[self tabContentArea] convertRect:[window_ _growBoxRect] fromView:nil];
413 growBoxRect.origin.y =
414 [[self tabContentArea] frame].size.height - growBoxRect.size.height -
415 growBoxRect.origin.y;
416 return growBoxRect;
388 } 417 }
389 418
390 // Accept tabs from a BrowserWindowController with the same Profile. 419 // Accept tabs from a BrowserWindowController with the same Profile.
391 - (BOOL)canReceiveFrom:(TabWindowController*)source { 420 - (BOOL)canReceiveFrom:(TabWindowController*)source {
392 if (![source isKindOfClass:[BrowserWindowController class]]) { 421 if (![source isKindOfClass:[BrowserWindowController class]]) {
393 return NO; 422 return NO;
394 } 423 }
395 424
396 BrowserWindowController* realSource = 425 BrowserWindowController* realSource =
397 static_cast<BrowserWindowController*>(source); 426 static_cast<BrowserWindowController*>(source);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 - (void)tabChangedWithContents:(TabContents*)contents 652 - (void)tabChangedWithContents:(TabContents*)contents
624 atIndex:(NSInteger)index 653 atIndex:(NSInteger)index
625 loadingOnly:(BOOL)loading { 654 loadingOnly:(BOOL)loading {
626 // Update titles if this is the currently selected tab. 655 // Update titles if this is the currently selected tab.
627 if (index == browser_->tabstrip_model()->selected_index()) 656 if (index == browser_->tabstrip_model()->selected_index())
628 windowShim_->UpdateTitleBar(); 657 windowShim_->UpdateTitleBar();
629 } 658 }
630 659
631 @end 660 @end
632 661
633
634 @interface NSWindow (NSPrivateApis)
635 // Note: These functions are private, use -[NSObject respondsToSelector:]
636 // before calling them.
637
638 - (void)setAutorecalculatesContentBorderThickness:(BOOL)b
639 forEdge:(NSRectEdge)e;
640 - (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e;
641 @end
642
643
644 @implementation BrowserWindowController (Private) 662 @implementation BrowserWindowController (Private)
645 663
646 // Position |toolbarView_| below the tab strip, but not as a sibling. The 664 // Position |toolbarView_| below the tab strip, but not as a sibling. The
647 // toolbar is part of the window's contentView, mainly because we want the 665 // toolbar is part of the window's contentView, mainly because we want the
648 // opacity during drags to be the same as the web content. 666 // opacity during drags to be the same as the web content.
649 - (void)positionToolbar { 667 - (void)positionToolbar {
650 NSView* contentView = [self tabContentArea]; 668 NSView* contentView = [self tabContentArea];
651 NSRect contentFrame = [contentView frame]; 669 NSRect contentFrame = [contentView frame];
652 NSView* toolbarView = [toolbarController_ view]; 670 NSView* toolbarView = [toolbarController_ view];
653 NSRect toolbarFrame = [toolbarView frame]; 671 NSRect toolbarFrame = [toolbarView frame];
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 browser_->ExecuteCommand(command); 803 browser_->ExecuteCommand(command);
786 } 804 }
787 805
788 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { 806 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj {
789 // Ask the toolbar controller if it wants to return a custom field editor 807 // Ask the toolbar controller if it wants to return a custom field editor
790 // for the specific object. 808 // for the specific object.
791 return [toolbarController_ customFieldEditorForObject:obj]; 809 return [toolbarController_ customFieldEditorForObject:obj];
792 } 810 }
793 811
794 @end 812 @end
OLDNEW
« no previous file with comments | « chrome/app/nibs/en.lproj/TabContents.xib ('k') | chrome/browser/cocoa/tab_contents_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698