Skip to content

Commit

Permalink
Theme the text of the download item so it's readable with dark themes.
Browse files Browse the repository at this point in the history
BUG=http://crbug.com/21559
TEST=as in bug

Review URL: http://codereview.chromium.org/377015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31462 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
avi@chromium.org committed Nov 9, 2009
1 parent b4aa6f7 commit 73b51a3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions chrome/browser/cocoa/download_item_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "chrome/browser/download/download_util.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#import "third_party/GTM/AppKit/GTMTheme.h"
#include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"

static const int kTextWidth = 140; // Pixels
Expand Down Expand Up @@ -65,6 +66,8 @@ void WidenView(NSView* view, CGFloat widthChange) {
};

@interface DownloadItemController (Private)
- (void)themeDidChangeNotification:(NSNotification*)aNotification;
- (void)updateTheme:(GTMTheme*)theme;
- (void)setState:(DownoadItemState)state;
@end

Expand All @@ -80,6 +83,12 @@ - (id)initWithModel:(BaseDownloadItemModel*)downloadModel
bridge_.reset(new DownloadItemMac(downloadModel, self));
menuBridge_.reset(new DownloadShelfContextMenuMac(downloadModel));

NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(themeDidChangeNotification:)
name:kGTMThemeDidChangeNotification
object:nil];

shelf_ = shelf;
state_ = kNormal;
creationTime_ = base::Time::Now();
Expand Down Expand Up @@ -171,6 +180,9 @@ - (void)remove {
}

- (void)updateVisibility:(id)sender {
if ([[self view] window])
[self updateTheme:[[self view] gtm_theme]];

// TODO(thakis): Make this prettier, by fading the items out or overlaying
// the partial visible one with a horizontal alpha gradient -- crbug.com/17830
NSView* view = [self view];
Expand Down Expand Up @@ -226,6 +238,17 @@ - (void)setState:(DownoadItemState)state {
[shelf_ layoutItems];
}

- (void)themeDidChangeNotification:(NSNotification*)aNotification {
GTMTheme* theme = [aNotification object];
[self updateTheme:theme];
}

- (void)updateTheme:(GTMTheme*)theme {
NSColor* color = [theme textColorForStyle:GTMThemeStyleTabBarSelected
state:GTMThemeStateActiveWindow];
[dangerousDownloadLabel_ setTextColor:color];
}

- (IBAction)saveDownload:(id)sender {
// The user has confirmed a dangerous download. We record how quickly the
// user did this to detect whether we're being clickjacked.
Expand Down

0 comments on commit 73b51a3

Please sign in to comment.