summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/tab_controller.mm
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 17:57:53 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 17:57:53 +0000
commit14e336a1b5a8ffe8512c63837599b449fa5540ee (patch)
treea0046049e053a00f3428dc0d7dbb8aacd59c11e7 /chrome/browser/cocoa/tab_controller.mm
parent33bd60f508a0eaa7ddfefb497b35c1627a6ff0be (diff)
downloadchromium_src-14e336a1b5a8ffe8512c63837599b449fa5540ee.zip
chromium_src-14e336a1b5a8ffe8512c63837599b449fa5540ee.tar.gz
chromium_src-14e336a1b5a8ffe8512c63837599b449fa5540ee.tar.bz2
[Mac] Initial implementation of app tabs. Loads the app and displays the correct icon (http://cl.ly/97c1b5e22eb32075d497).
Still to be done: o there should be a much smaller overlap of app tabs with other tabs. o The toolbar should hide when necessary. o The context menu for the tab should have the option of hiding/showing the toolbar on a per-app basis. TEST=none BUG=45539 Review URL: http://codereview.chromium.org/2847052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/tab_controller.mm')
-rw-r--r--chrome/browser/cocoa/tab_controller.mm27
1 files changed, 22 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm
index 3450814..918858d 100644
--- a/chrome/browser/cocoa/tab_controller.mm
+++ b/chrome/browser/cocoa/tab_controller.mm
@@ -10,16 +10,22 @@
#import "chrome/browser/cocoa/tab_controller_target.h"
#import "chrome/browser/cocoa/tab_view.h"
#import "chrome/browser/cocoa/themed_window.h"
+#import "chrome/common/extensions/extension.h"
#include "grit/generated_resources.h"
@implementation TabController
+@synthesize action = action_;
+@synthesize app = app_;
@synthesize loadingState = loadingState_;
@synthesize mini = mini_;
-@synthesize pinned = pinned_;
@synthesize phantom = phantom_;
+@synthesize pinned = pinned_;
@synthesize target = target_;
-@synthesize action = action_;
+
+namespace {
+const CGFloat kAppIconTopOffsetPx = 2.0;
+} // anonymous namespace
namespace TabControllerInternal {
@@ -59,9 +65,10 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate {
// padding, of which we have no comparable constants (we draw using paths, not
// images). The selected tab width includes the close button width.
+ (CGFloat)minTabWidth { return 31; }
-+ (CGFloat)minSelectedTabWidth { return 47; }
++ (CGFloat)minSelectedTabWidth { return 46; }
+ (CGFloat)maxTabWidth { return 220; }
+ (CGFloat)miniTabWidth { return 53; }
++ (CGFloat)appTabWidth { return 46; }
- (TabView*)tabView {
return static_cast<TabView*>([self view]);
@@ -163,8 +170,18 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate {
- (void)setIconView:(NSView*)iconView {
[iconView_ removeFromSuperview];
iconView_ = iconView;
- [iconView_ setFrame:originalIconFrame_];
-
+ if ([self app]) {
+ NSRect appIconFrame = [iconView frame];
+ appIconFrame.origin = originalIconFrame_.origin;
+ // Adjust the position to prevent clipping due to the icon's larger size.
+ appIconFrame.origin.y -= kAppIconTopOffsetPx;
+ // Center the icon.
+ appIconFrame.origin.x = ([TabController appTabWidth] -
+ NSWidth(appIconFrame)) / 2.0;
+ [iconView setFrame:appIconFrame];
+ } else {
+ [iconView_ setFrame:originalIconFrame_];
+ }
// Ensure that the icon is suppressed if no icon is set or if the tab is too
// narrow to display one.
[self updateVisibility];