diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-14 20:54:23 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-14 20:54:23 +0000 |
commit | 6fba10cb982c7cceb17aebbf8319e8d2271086be (patch) | |
tree | 5a5f81bfc65d5879a76ca18be02040e47479011b /chrome/browser | |
parent | fceab60b63b40d8f9da30192dd9da0e58a1a95f4 (diff) | |
download | chromium_src-6fba10cb982c7cceb17aebbf8319e8d2271086be.zip chromium_src-6fba10cb982c7cceb17aebbf8319e8d2271086be.tar.gz chromium_src-6fba10cb982c7cceb17aebbf8319e8d2271086be.tar.bz2 |
[Mac] Finish implementation of App Tabs. This takes into account the UI consolidation of pinned and nano tabs tracked in issue 49013.
TEST=none
BUG=45539,49013
Review URL: http://codereview.chromium.org/2952004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 13 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_controller.mm | 13 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 29 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 9 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_menu_model.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_menu_model.h | 6 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 3 |
11 files changed, 34 insertions, 58 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 2dc2f4b..56727ca 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -105,7 +105,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual void Copy(); virtual void Paste(); virtual void ToggleTabStripMode(); - virtual void SetToolbarCollapsedMode(bool collapsed); + virtual void SetToolbarCollapsedMode(bool val) {}; // Overridden from NotificationObserver virtual void Observe(NotificationType type, diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 274f5b8..bd409a2 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -550,10 +550,6 @@ void BrowserWindowCocoa::ToggleTabStripMode() { [controller_ toggleTabStripDisplayMode]; } -void BrowserWindowCocoa::SetToolbarCollapsedMode(bool collapsed) { - [controller_ setToolbarCollapsedMode:collapsed]; -} - void BrowserWindowCocoa::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index f7a63a2..ab44977 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -120,9 +120,6 @@ class TabStripModelObserverBridge; // Bar visibility locks and releases only result (when appropriate) in changes // in visible state when the following is |YES|. BOOL barVisibilityUpdatesEnabled_; - - // Whether the toolbar is collapsed. Currently used only by extension apps. - BOOL toolbarCollapsed_; } // A convenience class method which gets the |BrowserWindowController| for a @@ -255,10 +252,6 @@ class TabStripModelObserverBridge; // browser. - (void)toggleTabStripDisplayMode; -// Called when the toolbar is to be hidden or shown. Right now this only occurs -// when extension apps don't want the toolbar to be shown. -- (void)setToolbarCollapsedMode:(BOOL)collapsed; - // Called when the Add Search Engine dialog is closed. - (void)sheetDidEnd:(NSWindow*)sheet returnCode:(NSInteger)code diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index a8c6053..1c5c681 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -793,7 +793,7 @@ } // Update a toggle state for an NSMenuItem if modified. -// Take care to insure |item| looks like a NSMenuItem. +// Take care to ensure |item| looks like a NSMenuItem. // Called by validateUserInterfaceItem:. - (void)updateToggleStateWithTag:(NSInteger)tag forItem:(id)item { if (![item respondsToSelector:@selector(state)] || @@ -1633,17 +1633,6 @@ willAnimateFromState:(bookmarks::VisualState)oldState return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); } -- (void)setToolbarCollapsedMode:(BOOL)collapsed { - if (toolbarCollapsed_ == collapsed) - return; - - [self locationBarBridge]->SetEditable(!collapsed); - - // TODO(andybons): Actually hide toolbar if collapsed. - - toolbarCollapsed_ = collapsed; -} - - (void)sheetDidEnd:(NSWindow*)sheet returnCode:(NSInteger)code context:(void*)context { diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm index 918858d..50eb268 100644 --- a/chrome/browser/cocoa/tab_controller.mm +++ b/chrome/browser/cocoa/tab_controller.mm @@ -23,10 +23,6 @@ @synthesize pinned = pinned_; @synthesize target = target_; -namespace { -const CGFloat kAppIconTopOffsetPx = 2.0; -} // anonymous namespace - namespace TabControllerInternal { // A C++ delegate that handles enabling/disabling menu items and handling when @@ -68,7 +64,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { + (CGFloat)minSelectedTabWidth { return 46; } + (CGFloat)maxTabWidth { return 220; } + (CGFloat)miniTabWidth { return 53; } -+ (CGFloat)appTabWidth { return 46; } ++ (CGFloat)appTabWidth { return 66; } - (TabView*)tabView { return static_cast<TabView*>([self view]); @@ -134,7 +130,10 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { contextMenuDelegate_.reset( new TabControllerInternal::MenuDelegate(target_, self)); contextMenuModel_.reset(new TabMenuModel(contextMenuDelegate_.get(), - [self pinned], false, true)); + [self pinned], + false, // allow_toolbar_toggle + true)); // is_toolbar_visible + contextMenuController_.reset( [[MenuController alloc] initWithModel:contextMenuModel_.get() useWithPopUpButtonCell:NO]); @@ -173,8 +172,6 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { 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; diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 85444e7..d2caf62 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -35,7 +35,6 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/common/extensions/extension.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -58,8 +57,8 @@ const CGFloat kUseFullAvailableWidth = -1.0; // The amount by which tabs overlap. const CGFloat kTabOverlap = 20.0; -// The amount by which app tabs overlap with themselves and normal tabs. -const CGFloat kAppTabOverlap = 5.0; +// The width and height for a tab's icon. +const CGFloat kIconWidthAndHeight = 16.0; // The amount by which the new tab button is offset (from the tabs). const CGFloat kNewTabButtonOffset = 8.0; @@ -1156,19 +1155,21 @@ private: // for |contents|. - (NSImageView*)iconImageViewForContents:(TabContents*)contents { BOOL isApp = contents->is_app(); - - NSImage* image = gfx::SkBitmapToNSImage( - isApp ? *(contents->GetExtensionAppIcon()) : contents->GetFavIcon()); + NSImage* image = nil; + if (isApp) { + SkBitmap* icon = contents->GetExtensionAppIcon(); + if (icon) + image = gfx::SkBitmapToNSImage(*icon); + } else { + image = gfx::SkBitmapToNSImage(contents->GetFavIcon()); + } // Either we don't have a valid favicon or there was some issue converting it // from an SkBitmap. Either way, just show the default. if (!image) image = defaultFavIcon_.get(); - - CGFloat iconWidthAndHeight = isApp ? Extension::EXTENSION_ICON_SMALLISH : 16; - NSRect iconFrame = NSMakeRect(0, 0, iconWidthAndHeight, iconWidthAndHeight); - NSImageView* view = [[[NSImageView alloc] initWithFrame:iconFrame] - autorelease]; + NSRect frame = NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); + NSImageView* view = [[[NSImageView alloc] initWithFrame:frame] autorelease]; [view setImage:image]; return view; } @@ -1234,12 +1235,14 @@ private: iconView = [self iconImageViewForContents:contents]; } else if (newState == kTabCrashed) { NSImage* oldImage = [[self iconImageViewForContents:contents] image]; - NSRect frame = NSMakeRect(0, 0, 16, 16); + NSRect frame = + NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); iconView = [ThrobberView toastThrobberViewWithFrame:frame beforeImage:oldImage afterImage:sadFaviconImage]; } else { - NSRect frame = NSMakeRect(0, 0, 16, 16); + NSRect frame = + NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); iconView = [ThrobberView filmstripThrobberViewWithFrame:frame image:throbberImage]; } diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index 8f6baf5..7f34aa5 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -610,13 +610,10 @@ const CGFloat kRapidCloseDist = 2.5; BOOL selected = [self state]; // Outset by 0.5 in order to draw on pixels rather than on borders (which - // would cause blurry pixels). For non-app tabs, subtract 1px of height to - // compensate, otherwise clipping will occur. + // would cause blurry pixels). Subtract 1px of height to compensate, otherwise + // clipping will occur. rect = NSInsetRect(rect, -0.5, -0.5); - if ([controller_ app]) - rect.size.height = 12.0; - else - rect.size.height -= 1.0; + rect.size.height -= 1.0; NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect) + 2); NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect) + 2); diff --git a/chrome/browser/cocoa/toolbar_controller.h b/chrome/browser/cocoa/toolbar_controller.h index 9396c85..2b40d45 100644 --- a/chrome/browser/cocoa/toolbar_controller.h +++ b/chrome/browser/cocoa/toolbar_controller.h @@ -30,7 +30,7 @@ class LocationBarViewMac; namespace ToolbarControllerInternal { class MenuDelegate; class PrefObserverBridge; -} +} // namespace ToolbarControllerInternal class Profile; @class ReloadButton; class TabContents; diff --git a/chrome/browser/tab_menu_model.cc b/chrome/browser/tab_menu_model.cc index 50a9540..41667b2 100644 --- a/chrome/browser/tab_menu_model.cc +++ b/chrome/browser/tab_menu_model.cc @@ -10,11 +10,11 @@ #include "grit/generated_resources.h" TabMenuModel::TabMenuModel(menus::SimpleMenuModel::Delegate* delegate, + bool is_pinned, bool allow_toolbar_toggle, - bool is_app_tab, bool is_toolbar_visible) : menus::SimpleMenuModel(delegate) { - Build(allow_toolbar_toggle, is_app_tab, is_toolbar_visible); + Build(is_pinned, allow_toolbar_toggle, is_toolbar_visible); } // static diff --git a/chrome/browser/tab_menu_model.h b/chrome/browser/tab_menu_model.h index 9712175..d0c29eb 100644 --- a/chrome/browser/tab_menu_model.h +++ b/chrome/browser/tab_menu_model.h @@ -1,6 +1,6 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef CHROME_BROWSER_TAB_MENU_MODEL_H_ #define CHROME_BROWSER_TAB_MENU_MODEL_H_ diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index ba613a1..ef4677b 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -464,7 +464,8 @@ bool TabStripModel::IsMiniTab(int index) const { } bool TabStripModel::IsAppTab(int index) const { - return GetTabContentsAt(index)->is_app(); + TabContents* contents = GetTabContentsAt(index); + return contents && contents->is_app(); } bool TabStripModel::IsToolbarVisible(int index) const { |