summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.h2
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm6
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h7
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm12
-rw-r--r--chrome/browser/cocoa/tab_controller.h12
-rw-r--r--chrome/browser/cocoa/tab_controller.mm27
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm39
-rw-r--r--chrome/browser/cocoa/tab_view.mm9
8 files changed, 83 insertions, 31 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h
index ec1e0e5..2dc2f4b 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 val) {}
+ virtual void SetToolbarCollapsedMode(bool collapsed);
// 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 e3fecac..556263b 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -23,12 +23,14 @@
#import "chrome/browser/cocoa/html_dialog_window_controller.h"
#import "chrome/browser/cocoa/import_settings_dialog.h"
#import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h"
+#import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/cocoa/nsmenuitem_additions.h"
#include "chrome/browser/cocoa/page_info_window_mac.h"
#include "chrome/browser/cocoa/repost_form_warning_mac.h"
#include "chrome/browser/cocoa/status_bubble_mac.h"
#include "chrome/browser/cocoa/task_manager_mac.h"
#import "chrome/browser/cocoa/theme_install_bubble_view.h"
+#import "chrome/browser/cocoa/toolbar_controller.h"
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/global_keyboard_shortcuts_mac.h"
#include "chrome/browser/pref_service.h"
@@ -548,6 +550,10 @@ 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 3d49356..aaf843a 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -122,6 +122,9 @@ 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
@@ -252,6 +255,10 @@ 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 360dead..96b0245 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -1633,6 +1633,18 @@ willAnimateFromState:(bookmarks::VisualState)oldState
return browser_->tabstrip_model()->delegate()->UseVerticalTabs();
}
+- (void)setToolbarCollapsedMode:(BOOL)collapsed {
+ if (toolbarCollapsed_ == collapsed)
+ return;
+
+ static_cast<LocationBarViewMac*>([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.h b/chrome/browser/cocoa/tab_controller.h
index 4e28954..36ddad1 100644
--- a/chrome/browser/cocoa/tab_controller.h
+++ b/chrome/browser/cocoa/tab_controller.h
@@ -43,10 +43,12 @@ class MenuDelegate;
NSRect originalIconFrame_; // frame of iconView_ as loaded from nib
BOOL isIconShowing_; // last state of iconView_ in updateVisibility
- BOOL selected_;
+
+ BOOL app_;
BOOL mini_;
BOOL pinned_;
BOOL phantom_;
+ BOOL selected_;
TabLoadingState loadingState_;
CGFloat iconTitleXOffset_; // between left edges of icon and title
CGFloat titleCloseWidthOffset_; // between right edges of icon and close btn.
@@ -59,12 +61,13 @@ class MenuDelegate;
@property(assign, nonatomic) TabLoadingState loadingState;
-@property(assign, nonatomic) BOOL selected;
+@property(assign, nonatomic) SEL action;
+@property(assign, nonatomic) BOOL app;
@property(assign, nonatomic) BOOL mini;
-@property(assign, nonatomic) BOOL pinned;
@property(assign, nonatomic) BOOL phantom;
+@property(assign, nonatomic) BOOL pinned;
+@property(assign, nonatomic) BOOL selected;
@property(assign, nonatomic) id target;
-@property(assign, nonatomic) SEL action;
// Minimum and maximum allowable tab width. The minimum width does not show
// the icon or the close button. The selected tab always has at least a close
@@ -73,6 +76,7 @@ class MenuDelegate;
+ (CGFloat)maxTabWidth;
+ (CGFloat)minSelectedTabWidth;
+ (CGFloat)miniTabWidth;
++ (CGFloat)appTabWidth;
// The view associated with this controller, pre-casted as a TabView
- (TabView*)tabView;
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];
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 7930da7..ee4f9bf 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -35,6 +35,7 @@
#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"
@@ -57,6 +58,9 @@ 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 amount by which the new tab button is offset (from the tabs).
const CGFloat kNewTabButtonOffset = 8.0;
@@ -687,6 +691,7 @@ private:
const CGFloat kMinTabWidth = [TabController minTabWidth];
const CGFloat kMinSelectedTabWidth = [TabController minSelectedTabWidth];
const CGFloat kMiniTabWidth = [TabController miniTabWidth];
+ const CGFloat kAppTabWidth = [TabController appTabWidth];
NSRect enclosingRect = NSZeroRect;
ScopedNSAnimationContextGroup mainAnimationGroup(animate);
@@ -813,7 +818,8 @@ private:
// Set the width. Selected tabs are slightly wider when things get really
// small and thus we enforce a different minimum width.
- tabFrame.size.width = [tab mini] ? kMiniTabWidth : nonMiniTabWidth;
+ tabFrame.size.width = [tab mini] ?
+ ([tab app] ? kAppTabWidth : kMiniTabWidth) : nonMiniTabWidth;
if ([tab selected])
tabFrame.size.width = MAX(tabFrame.size.width, kMinSelectedTabWidth);
@@ -949,6 +955,7 @@ private:
TabController* newController = [self newTab];
[newController setMini:tabStripModel_->IsMiniTab(modelIndex)];
[newController setPinned:tabStripModel_->IsTabPinned(modelIndex)];
+ [newController setApp:tabStripModel_->IsAppTab(modelIndex)];
[tabArray_ insertObject:newController atIndex:index];
NSView* newView = [newController view];
@@ -1145,28 +1152,23 @@ private:
object:self];
}
-// A helper routine for creating an NSImageView to hold the fav icon for
-// |contents|.
-- (NSImageView*)favIconImageViewForContents:(TabContents*)contents {
- NSRect iconFrame = NSMakeRect(0, 0, 16, 16);
- NSImageView* view = [[[NSImageView alloc] initWithFrame:iconFrame]
- autorelease];
+// A helper routine for creating an NSImageView to hold the fav icon or app icon
+// for |contents|.
+- (NSImageView*)iconImageViewForContents:(TabContents*)contents {
+ BOOL isApp = contents->is_app();
- NSImage* image = nil;
-
- NavigationEntry* navEntry = contents->controller().GetLastCommittedEntry();
- if (navEntry != NULL) {
- NavigationEntry::FaviconStatus favIcon = navEntry->favicon();
- const SkBitmap& bitmap = favIcon.bitmap();
- if (favIcon.is_valid() && !bitmap.isNull())
- image = gfx::SkBitmapToNSImage(bitmap);
- }
+ NSImage* image = gfx::SkBitmapToNSImage(
+ isApp ? *(contents->GetExtensionAppIcon()) : 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];
[view setImage:image];
return view;
}
@@ -1229,9 +1231,9 @@ private:
NSView* iconView = nil;
if (newHasIcon) {
if (newState == kTabDone) {
- iconView = [self favIconImageViewForContents:contents];
+ iconView = [self iconImageViewForContents:contents];
} else if (newState == kTabCrashed) {
- NSImage* oldImage = [[self favIconImageViewForContents:contents] image];
+ NSImage* oldImage = [[self iconImageViewForContents:contents] image];
NSRect frame = NSMakeRect(0, 0, 16, 16);
iconView = [ThrobberView toastThrobberViewWithFrame:frame
beforeImage:oldImage
@@ -1315,6 +1317,7 @@ private:
DCHECK([tabController isKindOfClass:[TabController class]]);
[tabController setMini:tabStripModel_->IsMiniTab(modelIndex)];
[tabController setPinned:tabStripModel_->IsTabPinned(modelIndex)];
+ [tabController setApp:tabStripModel_->IsAppTab(modelIndex)];
[self updateFavIconForContents:contents atIndex:modelIndex];
// If the tab is being restored and it's pinned, the mini state is set after
// the tab has already been rendered, so re-layout the tabstrip. In all other
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm
index 8e4c8e3..8f6baf5 100644
--- a/chrome/browser/cocoa/tab_view.mm
+++ b/chrome/browser/cocoa/tab_view.mm
@@ -610,10 +610,13 @@ 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). Subtract 1px of height to compensate,
- // otherwise clipping will occur.
+ // would cause blurry pixels). For non-app tabs, subtract 1px of height to
+ // compensate, otherwise clipping will occur.
rect = NSInsetRect(rect, -0.5, -0.5);
- rect.size.height -= 1;
+ if ([controller_ app])
+ rect.size.height = 12.0;
+ else
+ rect.size.height -= 1.0;
NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect) + 2);
NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect) + 2);