diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 01:41:13 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 01:41:13 +0000 |
commit | ee81de2a38a40c70f096e15780b28b89bfacd819 (patch) | |
tree | 210b8dcc124a4f5a64be4b6ed6adcd453ceb8c2b | |
parent | 5999209ebf35148c2ee8dd0bc1cdbbcfc61c5ddd (diff) | |
download | chromium_src-ee81de2a38a40c70f096e15780b28b89bfacd819.zip chromium_src-ee81de2a38a40c70f096e15780b28b89bfacd819.tar.gz chromium_src-ee81de2a38a40c70f096e15780b28b89bfacd819.tar.bz2 |
Reverting r39825.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39830 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_theme_provider.cc | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 21 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | 40 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_view.mm | 32 | ||||
-rw-r--r-- | chrome/browser/cocoa/download_item_controller.mm | 20 | ||||
-rw-r--r-- | chrome/browser/cocoa/infobar_gradient_view.mm | 15 |
7 files changed, 53 insertions, 81 deletions
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index 6bc95ca..a51d8a5 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -72,11 +72,7 @@ const SkColor kDefaultColorToolbar = SkColorSetRGB(210, 225, 246); #endif const SkColor kDefaultColorTabText = SK_ColorBLACK; const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); -#if defined (OS_MACOSX) -const SkColor kDefaultColorBookmarkText = SkColorSetRGB(0, 0, 0); -#else const SkColor kDefaultColorBookmarkText = SkColorSetRGB(18, 50, 114); -#endif #if defined(OS_WIN) const SkColor kDefaultColorNTPBackground = color_utils::GetSysSkColor(COLOR_WINDOW); diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index 874987a..b68b19f 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -242,7 +242,7 @@ willAnimateFromState:(bookmarks::VisualState)oldState - (NSButton*)offTheSideButton; - (NSButton*)otherBookmarksButton; - (BookmarkNode*)nodeFromMenuItem:(id)sender; -- (void)updateTheme:(ThemeProvider*)themeProvider; +- (void)updateTheme:(GTMTheme*)theme; @end // The (internal) |NSPasteboard| type string for bookmark button drags, used for diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index adb6e13..f2a5687 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -10,7 +10,7 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" -#import "chrome/browser/browser_theme_provider.h" +#include "chrome/browser/browser_theme_provider.h" #import "chrome/browser/cocoa/background_gradient_view.h" #import "chrome/browser/cocoa/bookmark_bar_bridge.h" #import "chrome/browser/cocoa/bookmark_bar_constants.h" @@ -25,7 +25,6 @@ #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" #import "chrome/browser/cocoa/event_utils.h" #import "chrome/browser/cocoa/menu_button.h" -#import "chrome/browser/cocoa/themed_window.h" #import "chrome/browser/cocoa/toolbar_controller.h" #import "chrome/browser/cocoa/view_resizer.h" #include "chrome/browser/metrics/user_metrics.h" @@ -204,7 +203,7 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kBrowserThemeDidChangeNotification + name:kGTMThemeDidChangeNotification object:nil]; // This call triggers an awakeFromNib, which builds the bar, which @@ -242,12 +241,11 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; // because our trigger is an [NSView viewWillMoveToWindow:], which the // controller doesn't normally know about. Otherwise we don't have // access to the theme before we know what window we will be on. -- (void)updateTheme:(ThemeProvider*)themeProvider { - if (!themeProvider) +- (void)updateTheme:(GTMTheme*)theme { + if (!theme) return; - NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, - true); + NSColor* color = [theme textColorForStyle:GTMThemeStyleBookmarksBarButton + state:GTMThemeStateActiveWindow]; for (BookmarkButton* button in buttons_.get()) { BookmarkButtonCell* cell = [button cell]; [cell setTextColor:color]; @@ -257,9 +255,8 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - ThemeProvider* themeProvider = - static_cast<ThemeProvider*>([[aNotification object] pointerValue]); - [self updateTheme:themeProvider]; + GTMTheme* theme = [aNotification object]; + [self updateTheme:theme]; } - (void)awakeFromNib { @@ -1213,7 +1210,7 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; [self clearBookmarkBar]; [self addNodesToButtonList:node]; [self createOtherBookmarksButton]; - [self updateTheme:[[[self view] window] themeProvider]]; + [self updateTheme:[[self view] gtm_theme]]; [self resizeButtons]; [self positionOffTheSideButton]; [self addNonBookmarkButtonsToView]; diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index 4e1aa933..345b96e 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -4,7 +4,6 @@ #import <Cocoa/Cocoa.h> -#include "app/theme_provider.h" #include "base/basictypes.h" #include "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" @@ -81,28 +80,25 @@ @end -class FakeTheme : public ThemeProvider { - public: - FakeTheme(NSColor* color) : color_(color) { } +@interface FakeTheme : GTMTheme { scoped_nsobject<NSColor> color_; +} +@end - virtual void Init(Profile* profile) { } - virtual SkBitmap* GetBitmapNamed(int id) const { return nil; } - virtual SkColor GetColor(int id) const { return SkColor(); } - virtual bool GetDisplayProperty(int id, int* result) const { return false; } - virtual bool ShouldUseNativeFrame() const { return false; } - virtual bool HasCustomImage(int id) const { return false; } - virtual RefCountedMemory* GetRawData(int id) const { return NULL; } - virtual NSImage* GetNSImageNamed(int id, bool allow_default) const { - return nil; +@implementation FakeTheme +- (id)initWithColor:(NSColor*)color { + if ((self = [super init])) { + color_.reset([color retain]); } - virtual NSColor* GetNSColor(int id, bool allow_default) const { - return color_.get(); - } - virtual NSColor* GetNSColorTint(int id, bool allow_default) const { - return nil; - } -}; + return self; +} + +- (NSColor*)textColorForStyle:(GTMThemeStyle)style + state:(GTMThemeState)state { + return color_.get(); +} +@end + namespace { @@ -885,8 +881,8 @@ TEST_F(BookmarkBarControllerTest, TestThemedButton) { [NSColor blueColor], nil]; for (NSColor* color in colors) { - FakeTheme theme(color); - [bar_ updateTheme:&theme]; + scoped_nsobject<FakeTheme> theme([[FakeTheme alloc] initWithColor:color]); + [bar_ updateTheme:theme.get()]; NSAttributedString* astr = [button attributedTitle]; EXPECT_TRUE(astr); EXPECT_TRUE([[astr string] isEqual:@"small"]); diff --git a/chrome/browser/cocoa/bookmark_bar_view.mm b/chrome/browser/cocoa/bookmark_bar_view.mm index 96b7594..ae8ca8c 100644 --- a/chrome/browser/cocoa/bookmark_bar_view.mm +++ b/chrome/browser/cocoa/bookmark_bar_view.mm @@ -4,15 +4,14 @@ #import "chrome/browser/cocoa/bookmark_bar_view.h" -#import "chrome/browser/browser_theme_provider.h" #import "chrome/browser/cocoa/bookmark_bar_controller.h" #import "chrome/browser/cocoa/bookmark_button.h" -#import "chrome/browser/cocoa/themed_window.h" +#import "chrome/browser/cocoa/GTMTheme.h" #import "third_party/mozilla/include/NSPasteboard+Utils.h" @interface BookmarkBarView (Private) - (void)themeDidChangeNotification:(NSNotification*)aNotification; -- (void)updateTheme:(ThemeProvider*)themeProvider; +- (void)updateTheme:(GTMTheme*)theme; @end @implementation BookmarkBarView @@ -28,7 +27,7 @@ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kBrowserThemeDidChangeNotification + name:kGTMThemeDidChangeNotification object:nil]; DCHECK(controller_ && "Expected this to be hooked up via Interface Builder"); @@ -45,27 +44,21 @@ // controller desn't have access to it until it's placed in the view // hierarchy. This is the spot where we close the loop. - (void)viewWillMoveToWindow:(NSWindow*)window { - ThemeProvider* themeProvider = [window themeProvider]; - [self updateTheme:themeProvider]; - [controller_ updateTheme:themeProvider]; + [self updateTheme:[window gtm_theme]]; + [controller_ updateTheme:[window gtm_theme]]; } // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - ThemeProvider* themeProvider = - static_cast<ThemeProvider*>([[aNotification object] pointerValue]); - [self updateTheme:themeProvider]; + GTMTheme* theme = [aNotification object]; + [self updateTheme:theme]; } // Adapt appearance to the current theme. Called after theme changes and before // this is shown for the first time. -- (void)updateTheme:(ThemeProvider*)themeProvider { - if (!themeProvider) - return; - - NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, - true); +- (void)updateTheme:(GTMTheme*)theme { + NSColor* color = [theme textColorForStyle:GTMThemeStyleBookmarksBarButton + state:GTMThemeStateActiveWindow]; [noItemTextfield_ setTextColor:color]; } @@ -95,8 +88,9 @@ NSRect uglyBlackBar = NSMakeRect(xLeft, kBarVertPad, kBarWidth, NSHeight([self bounds]) - 2 * kBarVertPad); - NSColor* uglyBlackBarColor = [[self window] themeProvider]-> - GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, true); + NSColor* uglyBlackBarColor = + [[self gtm_theme] textColorForStyle:GTMThemeStyleBookmarksBarButton + state:GTMThemeStateActiveWindow]; [[uglyBlackBarColor colorWithAlphaComponent:kBarOpacity] setFill]; [[NSBezierPath bezierPathWithRect:uglyBlackBar] fill]; } diff --git a/chrome/browser/cocoa/download_item_controller.mm b/chrome/browser/cocoa/download_item_controller.mm index 7b32994..ec6fe8e 100644 --- a/chrome/browser/cocoa/download_item_controller.mm +++ b/chrome/browser/cocoa/download_item_controller.mm @@ -9,12 +9,11 @@ #include "app/resource_bundle.h" #include "base/mac_util.h" #include "base/sys_string_conversions.h" -#import "chrome/browser/browser_theme_provider.h" #import "chrome/browser/cocoa/download_item_button.h" #import "chrome/browser/cocoa/download_item_cell.h" #include "chrome/browser/cocoa/download_item_mac.h" #import "chrome/browser/cocoa/download_shelf_controller.h" -#import "chrome/browser/cocoa/themed_window.h" +#import "chrome/browser/cocoa/GTMTheme.h" #import "chrome/browser/cocoa/ui_localizer.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_shelf.h" @@ -70,7 +69,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { @interface DownloadItemController (Private) - (void)themeDidChangeNotification:(NSNotification*)aNotification; -- (void)updateTheme:(ThemeProvider*)themeProvider; +- (void)updateTheme:(GTMTheme*)theme; - (void)setState:(DownoadItemState)state; @end @@ -89,7 +88,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kBrowserThemeDidChangeNotification + name:kGTMThemeDidChangeNotification object:nil]; shelf_ = shelf; @@ -188,7 +187,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { - (void)updateVisibility:(id)sender { if ([[self view] window]) - [self updateTheme:[[[self view] window] themeProvider]]; + [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 @@ -241,16 +240,15 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - ThemeProvider* themeProvider = - static_cast<ThemeProvider*>([[aNotification object] pointerValue]); - [self updateTheme:themeProvider]; + GTMTheme* theme = [aNotification object]; + [self updateTheme:theme]; } // Adapt appearance to the current theme. Called after theme changes and before // this is shown for the first time. -- (void)updateTheme:(ThemeProvider*)themeProvider { - NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, true); +- (void)updateTheme:(GTMTheme*)theme { + NSColor* color = [theme textColorForStyle:GTMThemeStyleTabBarSelected + state:GTMThemeStateActiveWindow]; [dangerousDownloadLabel_ setTextColor:color]; } diff --git a/chrome/browser/cocoa/infobar_gradient_view.mm b/chrome/browser/cocoa/infobar_gradient_view.mm index 6af8fbb..cba6574 100644 --- a/chrome/browser/cocoa/infobar_gradient_view.mm +++ b/chrome/browser/cocoa/infobar_gradient_view.mm @@ -3,9 +3,7 @@ // found in the LICENSE file. #include "chrome/browser/cocoa/infobar_gradient_view.h" - -#import "chrome/browser/browser_theme_provider.h" -#import "chrome/browser/cocoa/themed_window.h" +#import "chrome/browser/cocoa/GTMTheme.h" const double kBackgroundColorTop[3] = {255.0 / 255.0, 242.0 / 255.0, 183.0 / 255.0}; @@ -45,15 +43,8 @@ const double kBackgroundColorBottom[3] = } - (NSColor*)strokeColor { - ThemeProvider* themeProvider = [[self window] themeProvider]; - if (!themeProvider) - return [NSColor blackColor]; - - BOOL active = [[self window] isMainWindow]; - return themeProvider->GetNSColor( - active ? BrowserThemeProvider::COLOR_TOOLBAR_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_STROKE_INACTIVE, - true); + return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar + state:[[self window] isKeyWindow]]; } - (void)drawRect:(NSRect)rect { |