diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 01:22:15 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 01:22:15 +0000 |
commit | 8c3ba4d09e4d94decf1cb1759a0c58fa7459e6ef (patch) | |
tree | 678f0426ae32e7dc48c8572fa4e8d3c1cf360d80 /chrome/browser/cocoa | |
parent | 9492e4abf1be2910ab72f300abb7e0f28118b434 (diff) | |
download | chromium_src-8c3ba4d09e4d94decf1cb1759a0c58fa7459e6ef.zip chromium_src-8c3ba4d09e4d94decf1cb1759a0c58fa7459e6ef.tar.gz chromium_src-8c3ba4d09e4d94decf1cb1759a0c58fa7459e6ef.tar.bz2 |
Next batch of changes to kill GTMTheme.
BUG=http://crbug.com/35554
TEST=no visible change in normal mode; incognito mode still being worked on
Review URL: http://codereview.chromium.org/652179
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-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 |
6 files changed, 77 insertions, 53 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index b68b19f..874987a 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:(GTMTheme*)theme; +- (void)updateTheme:(ThemeProvider*)themeProvider; @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 f2a5687..adb6e13 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" -#include "chrome/browser/browser_theme_provider.h" +#import "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,6 +25,7 @@ #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" @@ -203,7 +204,7 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kGTMThemeDidChangeNotification + name:kBrowserThemeDidChangeNotification object:nil]; // This call triggers an awakeFromNib, which builds the bar, which @@ -241,11 +242,12 @@ 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:(GTMTheme*)theme { - if (!theme) +- (void)updateTheme:(ThemeProvider*)themeProvider { + if (!themeProvider) return; - NSColor* color = [theme textColorForStyle:GTMThemeStyleBookmarksBarButton - state:GTMThemeStateActiveWindow]; + NSColor* color = + themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + true); for (BookmarkButton* button in buttons_.get()) { BookmarkButtonCell* cell = [button cell]; [cell setTextColor:color]; @@ -255,8 +257,9 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - GTMTheme* theme = [aNotification object]; - [self updateTheme:theme]; + ThemeProvider* themeProvider = + static_cast<ThemeProvider*>([[aNotification object] pointerValue]); + [self updateTheme:themeProvider]; } - (void)awakeFromNib { @@ -1210,7 +1213,7 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12; [self clearBookmarkBar]; [self addNodesToButtonList:node]; [self createOtherBookmarksButton]; - [self updateTheme:[[self view] gtm_theme]]; + [self updateTheme:[[[self view] window] themeProvider]]; [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 345b96e..4e1aa933 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -4,6 +4,7 @@ #import <Cocoa/Cocoa.h> +#include "app/theme_provider.h" #include "base/basictypes.h" #include "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" @@ -80,25 +81,28 @@ @end -@interface FakeTheme : GTMTheme { +class FakeTheme : public ThemeProvider { + public: + FakeTheme(NSColor* color) : color_(color) { } scoped_nsobject<NSColor> color_; -} -@end -@implementation FakeTheme -- (id)initWithColor:(NSColor*)color { - if ((self = [super init])) { - color_.reset([color retain]); + 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; } - return self; -} - -- (NSColor*)textColorForStyle:(GTMThemeStyle)style - state:(GTMThemeState)state { - return color_.get(); -} -@end - + virtual NSColor* GetNSColor(int id, bool allow_default) const { + return color_.get(); + } + virtual NSColor* GetNSColorTint(int id, bool allow_default) const { + return nil; + } +}; namespace { @@ -881,8 +885,8 @@ TEST_F(BookmarkBarControllerTest, TestThemedButton) { [NSColor blueColor], nil]; for (NSColor* color in colors) { - scoped_nsobject<FakeTheme> theme([[FakeTheme alloc] initWithColor:color]); - [bar_ updateTheme:theme.get()]; + FakeTheme theme(color); + [bar_ updateTheme:&theme]; 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 ae8ca8c..96b7594 100644 --- a/chrome/browser/cocoa/bookmark_bar_view.mm +++ b/chrome/browser/cocoa/bookmark_bar_view.mm @@ -4,14 +4,15 @@ #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/GTMTheme.h" +#import "chrome/browser/cocoa/themed_window.h" #import "third_party/mozilla/include/NSPasteboard+Utils.h" @interface BookmarkBarView (Private) - (void)themeDidChangeNotification:(NSNotification*)aNotification; -- (void)updateTheme:(GTMTheme*)theme; +- (void)updateTheme:(ThemeProvider*)themeProvider; @end @implementation BookmarkBarView @@ -27,7 +28,7 @@ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kGTMThemeDidChangeNotification + name:kBrowserThemeDidChangeNotification object:nil]; DCHECK(controller_ && "Expected this to be hooked up via Interface Builder"); @@ -44,21 +45,27 @@ // 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 { - [self updateTheme:[window gtm_theme]]; - [controller_ updateTheme:[window gtm_theme]]; + ThemeProvider* themeProvider = [window themeProvider]; + [self updateTheme:themeProvider]; + [controller_ updateTheme:themeProvider]; } // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - GTMTheme* theme = [aNotification object]; - [self updateTheme:theme]; + ThemeProvider* themeProvider = + static_cast<ThemeProvider*>([[aNotification object] pointerValue]); + [self updateTheme:themeProvider]; } // Adapt appearance to the current theme. Called after theme changes and before // this is shown for the first time. -- (void)updateTheme:(GTMTheme*)theme { - NSColor* color = [theme textColorForStyle:GTMThemeStyleBookmarksBarButton - state:GTMThemeStateActiveWindow]; +- (void)updateTheme:(ThemeProvider*)themeProvider { + if (!themeProvider) + return; + + NSColor* color = + themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + true); [noItemTextfield_ setTextColor:color]; } @@ -88,9 +95,8 @@ NSRect uglyBlackBar = NSMakeRect(xLeft, kBarVertPad, kBarWidth, NSHeight([self bounds]) - 2 * kBarVertPad); - NSColor* uglyBlackBarColor = - [[self gtm_theme] textColorForStyle:GTMThemeStyleBookmarksBarButton - state:GTMThemeStateActiveWindow]; + NSColor* uglyBlackBarColor = [[self window] themeProvider]-> + GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, true); [[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 ec6fe8e..7b32994 100644 --- a/chrome/browser/cocoa/download_item_controller.mm +++ b/chrome/browser/cocoa/download_item_controller.mm @@ -9,11 +9,12 @@ #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/GTMTheme.h" +#import "chrome/browser/cocoa/themed_window.h" #import "chrome/browser/cocoa/ui_localizer.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_shelf.h" @@ -69,7 +70,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { @interface DownloadItemController (Private) - (void)themeDidChangeNotification:(NSNotification*)aNotification; -- (void)updateTheme:(GTMTheme*)theme; +- (void)updateTheme:(ThemeProvider*)themeProvider; - (void)setState:(DownoadItemState)state; @end @@ -88,7 +89,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kGTMThemeDidChangeNotification + name:kBrowserThemeDidChangeNotification object:nil]; shelf_ = shelf; @@ -187,7 +188,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { - (void)updateVisibility:(id)sender { if ([[self view] window]) - [self updateTheme:[[self view] gtm_theme]]; + [self updateTheme:[[[self view] window] themeProvider]]; // TODO(thakis): Make this prettier, by fading the items out or overlaying // the partial visible one with a horizontal alpha gradient -- crbug.com/17830 @@ -240,15 +241,16 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - GTMTheme* theme = [aNotification object]; - [self updateTheme:theme]; + ThemeProvider* themeProvider = + static_cast<ThemeProvider*>([[aNotification object] pointerValue]); + [self updateTheme:themeProvider]; } // Adapt appearance to the current theme. Called after theme changes and before // this is shown for the first time. -- (void)updateTheme:(GTMTheme*)theme { - NSColor* color = [theme textColorForStyle:GTMThemeStyleTabBarSelected - state:GTMThemeStateActiveWindow]; +- (void)updateTheme:(ThemeProvider*)themeProvider { + NSColor* color = + themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, true); [dangerousDownloadLabel_ setTextColor:color]; } diff --git a/chrome/browser/cocoa/infobar_gradient_view.mm b/chrome/browser/cocoa/infobar_gradient_view.mm index cba6574..6af8fbb 100644 --- a/chrome/browser/cocoa/infobar_gradient_view.mm +++ b/chrome/browser/cocoa/infobar_gradient_view.mm @@ -3,7 +3,9 @@ // found in the LICENSE file. #include "chrome/browser/cocoa/infobar_gradient_view.h" -#import "chrome/browser/cocoa/GTMTheme.h" + +#import "chrome/browser/browser_theme_provider.h" +#import "chrome/browser/cocoa/themed_window.h" const double kBackgroundColorTop[3] = {255.0 / 255.0, 242.0 / 255.0, 183.0 / 255.0}; @@ -43,8 +45,15 @@ const double kBackgroundColorBottom[3] = } - (NSColor*)strokeColor { - return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar - state:[[self window] isKeyWindow]]; + 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); } - (void)drawRect:(NSRect)rect { |