summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.h3
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm43
-rw-r--r--chrome/browser/cocoa/hyperlink_button_cell.h2
-rw-r--r--chrome/browser/cocoa/hyperlink_button_cell.mm8
4 files changed, 53 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h
index 872ac3b..92411e8 100644
--- a/chrome/browser/cocoa/download_shelf_controller.h
+++ b/chrome/browser/cocoa/download_shelf_controller.h
@@ -16,6 +16,7 @@ class Browser;
@class DownloadItemController;
class DownloadShelf;
@class DownloadShelfView;
+@class HyperlinkButtonCell;
// A controller class that manages the download shelf for one window. It is
// responsible for the behavior of the shelf itself (showing/hiding, handling
@@ -36,7 +37,7 @@ class DownloadShelf;
@interface DownloadShelfController : NSViewController<NSTextViewDelegate> {
@private
- IBOutlet NSButton* showAllDownloadsLink_;
+ IBOutlet HyperlinkButtonCell* showAllDownloadsCell_;
IBOutlet NSImageView* image_;
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index 13bdc69..28aa118 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -9,13 +9,16 @@
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_theme_provider.h"
#import "chrome/browser/cocoa/animatable_view.h"
#import "chrome/browser/cocoa/browser_window_controller.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#include "chrome/browser/cocoa/download_item_controller.h"
#include "chrome/browser/cocoa/download_shelf_mac.h"
#import "chrome/browser/cocoa/download_shelf_view.h"
+#import "chrome/browser/cocoa/hyperlink_button_cell.h"
#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/profile.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -40,6 +43,9 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
- (void)showDownloadShelf:(BOOL)enable;
- (void)layoutItems:(BOOL)skipFirst;
- (void)closed;
+
+- (void)updateTheme:(GTMTheme*)theme;
+- (void)themeDidChangeNotification:(NSNotification*)aNotification;
@end
@@ -69,6 +75,12 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
}
- (void)awakeFromNib {
+ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
+ [defaultCenter addObserver:self
+ selector:@selector(themeDidChangeNotification:)
+ name:kGTMThemeDidChangeNotification
+ object:nil];
+
[[self animatableView] setResizeDelegate:resizeDelegate_];
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -78,11 +90,39 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
}
- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
// The controllers will unregister themselves as observers when they are
// deallocated. No need to do that here.
[super dealloc];
}
+- (void)themeDidChangeNotification:(NSNotification*)aNotification {
+ GTMTheme* theme = [aNotification object];
+ [self updateTheme:theme];
+}
+
+- (void)updateTheme:(GTMTheme*)theme {
+ // For the default theme, use a blue color for the link. Ideally, we'd want to
+ // compare the current theme id with kDefaultThemeID, but the classic theme
+ // from the gallery does have a different id. Hence, we use the blue color if
+ // the current theme does not change the bookmark text color.
+ BOOL useDefaultColor = YES;
+ if (bridge_.get() && bridge_->browser() && bridge_->browser()->profile()) {
+ ThemeProvider* provider = bridge_->browser()->profile()->GetThemeProvider();
+ if (provider)
+ useDefaultColor = provider->GetColor(
+ BrowserThemeProvider::COLOR_BOOKMARK_TEXT) ==
+ BrowserThemeProvider::kDefaultColorBookmarkText;
+ }
+
+ NSColor* color = useDefaultColor ?
+ [HyperlinkButtonCell defaultTextColor] :
+ [theme textColorForStyle:GTMThemeStyleBookmarksBarButton
+ state:GTMThemeStateActiveWindow];
+ [showAllDownloadsCell_ setTextColor:color];
+}
+
- (AnimatableView*)animatableView {
return static_cast<AnimatableView*>([self view]);
}
@@ -123,6 +163,9 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
if ([self isVisible] == enable)
return;
+ if ([[self view] window])
+ [self updateTheme:[[self view] gtm_theme]];
+
// Animate the shelf out, but not in.
// TODO(rohitrao): We do not animate on the way in because Cocoa is already
// doing a lot of work to set up the download arrow animation. I've chosen to
diff --git a/chrome/browser/cocoa/hyperlink_button_cell.h b/chrome/browser/cocoa/hyperlink_button_cell.h
index 2342050..ec22a12 100644
--- a/chrome/browser/cocoa/hyperlink_button_cell.h
+++ b/chrome/browser/cocoa/hyperlink_button_cell.h
@@ -20,4 +20,6 @@
}
@property (retain) NSColor* textColor;
++ (NSColor*)defaultTextColor;
+
@end
diff --git a/chrome/browser/cocoa/hyperlink_button_cell.mm b/chrome/browser/cocoa/hyperlink_button_cell.mm
index 8493a8c..ceaea3f 100644
--- a/chrome/browser/cocoa/hyperlink_button_cell.mm
+++ b/chrome/browser/cocoa/hyperlink_button_cell.mm
@@ -12,6 +12,10 @@
@implementation HyperlinkButtonCell
@dynamic textColor;
++ (NSColor*)defaultTextColor {
+ return [NSColor blueColor];
+}
+
// Designated initializer.
- (id)init {
if ((self = [super init])) {
@@ -40,7 +44,7 @@
// common cell customization code.
- (void)customizeButtonCell {
[self setBordered:NO];
- [self setTextColor:[NSColor blueColor]];
+ [self setTextColor:[HyperlinkButtonCell defaultTextColor]];
CGFloat fontSize = [NSFont systemFontSizeForControlSize:[self controlSize]];
NSFont* font = [NSFont controlContentFontOfSize:fontSize];
@@ -99,7 +103,7 @@
}
- (void)setTextColor:(NSColor*)color {
- textColor_.reset(color);
+ textColor_.reset([color retain]);
}
@end