diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 18:36:12 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 18:36:12 +0000 |
commit | 53ee4e180c8481c8054e5f8997376f1c79544b1f (patch) | |
tree | 0e87181b12dc6777aa26533cbc6716ce3409cff1 /chrome | |
parent | a05c2ef0084fecfdfe297abeb2a6268b73abfce5 (diff) | |
download | chromium_src-53ee4e180c8481c8054e5f8997376f1c79544b1f.zip chromium_src-53ee4e180c8481c8054e5f8997376f1c79544b1f.tar.gz chromium_src-53ee4e180c8481c8054e5f8997376f1c79544b1f.tar.bz2 |
Another pass at removal of GTMTheme. Also fixes unreadability of bookmark bar/status bubble in unthemed incognito mode.
BUG=http://crbug.com/35554 ; http://crbug.com/29845
TEST=no visible change in normal mode; themed incognito windows should look ugly still but in a different way
Review URL: http://codereview.chromium.org/650092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
19 files changed, 146 insertions, 96 deletions
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index b96e653..a51d8a5 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -65,7 +65,11 @@ const SkColor kDefaultColorFrameInactive = SkColorSetRGB(152, 188, 233); const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139); const SkColor kDefaultColorFrameIncognitoInactive = SkColorSetRGB(126, 139, 156); +#if defined(OS_MACOSX) +const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); +#else const SkColor kDefaultColorToolbar = SkColorSetRGB(210, 225, 246); +#endif const SkColor kDefaultColorTabText = SK_ColorBLACK; const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); const SkColor kDefaultColorBookmarkText = SkColorSetRGB(18, 50, 114); @@ -88,6 +92,13 @@ const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); const SkColor kDefaultColorControlBackground = SkColorSetARGB(0, 0, 0, 0); const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); +#if defined(OS_MACOSX) +const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); +const SkColor kDefaultColorToolbarButtonStrokeInactive = + SkColorSetARGB(75, 99, 99, 99); +const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); +const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(123, 123, 123); +#endif // Default tints. const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; @@ -445,6 +456,16 @@ SkColor BrowserThemeProvider::GetDefaultColor(int id) { return kDefaultColorControlBackground; case COLOR_BUTTON_BACKGROUND: return kDefaultColorButtonBackground; +#if defined(OS_MACOSX) + case COLOR_TOOLBAR_BUTTON_STROKE: + return kDefaultColorToolbarButtonStroke; + case COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE: + return kDefaultColorToolbarButtonStrokeInactive; + case COLOR_TOOLBAR_STROKE: + return kDefaultColorToolbarStroke; + case COLOR_TOOLBAR_STROKE_INACTIVE: + return kDefaultColorToolbarStrokeInactive; +#endif default: // Return a debugging red color. return 0xffff0000; diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h index 73b01ac..26a556d 100644 --- a/chrome/browser/browser_theme_provider.h +++ b/chrome/browser/browser_theme_provider.h @@ -87,6 +87,13 @@ class BrowserThemeProvider : public NonThreadSafe, NTP_BACKGROUND_ALIGNMENT, NTP_BACKGROUND_TILING, NTP_LOGO_ALTERNATE +#if defined(OS_MACOSX) + , + COLOR_TOOLBAR_BUTTON_STROKE = 1000, + COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + COLOR_TOOLBAR_STROKE, + COLOR_TOOLBAR_STROKE_INACTIVE +#endif // OS_MACOSX }; // A bitfield mask for alignments. diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm index 8772f5a..01f5395 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm @@ -7,7 +7,6 @@ #include "app/gfx/font.h" #include "app/resource_bundle.h" #include "base/logging.h" -#import "chrome/browser/cocoa/GTMTheme.h" namespace { diff --git a/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm b/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm index 39efab9..bf0d9fc 100644 --- a/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm +++ b/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm @@ -8,10 +8,10 @@ #include "app/theme_provider.h" #include "base/gfx/rect.h" #include "chrome/browser/browser_theme_provider.h" -#import "chrome/browser/cocoa/browser_window_controller.h" #import "chrome/browser/cocoa/bookmark_bar_constants.h" #import "chrome/browser/cocoa/bookmark_bar_controller.h" -#import "chrome/browser/cocoa/GTMTheme.h" +#import "chrome/browser/cocoa/browser_window_controller.h" +#import "chrome/browser/cocoa/themed_window.h" #include "chrome/browser/ntp_background_util.h" const CGFloat kBorderRadius = 3.0; @@ -89,15 +89,7 @@ const CGFloat kBorderRadius = 3.0; // Draw the rounded rectangle. NSColor* toolbarColor = - [[self gtm_theme] backgroundColorForStyle:GTMThemeStyleToolBar - state:GTMThemeStateActiveWindow]; - // workaround for default theme - // TODO(alcor) next GTM update return nil for background color if not set; - // http://crbug.com/25196 - if ([toolbarColor isEqual:[NSColor colorWithCalibratedWhite:0.5 alpha:1.0]]) - toolbarColor = nil; - if (!toolbarColor) - toolbarColor = [NSColor colorWithCalibratedWhite:0.9 alpha:1.0]; + themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TOOLBAR, true); CGFloat alpha = morph * [toolbarColor alphaComponent]; [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. [border fill]; @@ -114,9 +106,8 @@ const CGFloat kBorderRadius = 3.0; [context restoreGraphicsState]; // Draw the border of the rounded rectangle. - NSColor* borderColor = - [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBarButton - state:GTMThemeStateActiveWindow]; + NSColor* borderColor = themeProvider->GetNSColor( + BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE, true); alpha = morph * [borderColor alphaComponent]; [[borderColor colorWithAlphaComponent:alpha] set]; // Set with opacity. [border stroke]; diff --git a/chrome/browser/cocoa/bookmark_button_cell.mm b/chrome/browser/cocoa/bookmark_button_cell.mm index 884a00a..8be166a 100644 --- a/chrome/browser/cocoa/bookmark_button_cell.mm +++ b/chrome/browser/cocoa/bookmark_button_cell.mm @@ -5,7 +5,6 @@ #include "base/logging.h" #import "chrome/browser/cocoa/bookmark_button_cell.h" #import "chrome/browser/cocoa/bookmark_menu.h" -#import "chrome/browser/cocoa/GTMTheme.h" @implementation BookmarkButtonCell diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index f15e9a7..6c8fd46 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -223,6 +223,12 @@ class TabStripModelObserverBridge; // Shows or hides the docked web inspector depending on |contents|'s state. - (void)updateDevToolsForContents:(TabContents*)contents; +// Gets the current theme provider. +- (ThemeProvider*)themeProvider; + +// Gets the pattern phase for the window. +- (NSPoint)themePatternPhase; + @end // @interface BrowserWindowController diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index d2460ac..d31b544 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -14,6 +14,7 @@ #include "chrome/app/chrome_dll_resource.h" // IDC_* #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/dock_info.h" #include "chrome/browser/encoding_menu_controller.h" #include "chrome/browser/location_bar.h" @@ -42,6 +43,7 @@ #import "chrome/browser/cocoa/tab_strip_controller.h" #import "chrome/browser/cocoa/tab_strip_view.h" #import "chrome/browser/cocoa/tab_view.h" +#import "chrome/browser/cocoa/themed_window.h" #import "chrome/browser/cocoa/toolbar_controller.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/sync/profile_sync_service.h" @@ -1307,6 +1309,14 @@ } - (NSPoint)gtm_themePatternPhaseForWindow:(NSWindow*)window { + return [self themePatternPhase]; +} + +- (ThemeProvider*)themeProvider { + return browser_->profile()->GetThemeProvider(); +} + +- (NSPoint)themePatternPhase { // Our patterns want to be drawn from the upper left hand corner of the view. // Cocoa wants to do it from the lower left of the window. // @@ -1318,7 +1328,7 @@ const CGFloat kPatternHorizontalOffset = -5; NSView* tabStripView = [self tabStripView]; NSRect tabStripViewWindowBounds = [tabStripView bounds]; - NSView* windowChromeView = [[window contentView] superview]; + NSView* windowChromeView = [[[self window] contentView] superview]; tabStripViewWindowBounds = [tabStripView convertRect:tabStripViewWindowBounds toView:windowChromeView]; diff --git a/chrome/browser/cocoa/bubble_view.h b/chrome/browser/cocoa/bubble_view.h index 761c5a8..8b52779 100644 --- a/chrome/browser/cocoa/bubble_view.h +++ b/chrome/browser/cocoa/bubble_view.h @@ -7,10 +7,8 @@ #include "base/scoped_nsobject.h" // A view class that looks like a "bubble" with rounded corners and displays -// text inside. Can be themed with a GTMTheme object. To put flush -// against the sides of a window, the corner flags can be adjusted. - -@protocol GTMThemeDelegate; +// text inside. Can be themed. To put flush against the sides of a window, the +// corner flags can be adjusted. // Constants that define where the bubble will have a rounded corner. If // not set, the corner will be square. diff --git a/chrome/browser/cocoa/bubble_view.mm b/chrome/browser/cocoa/bubble_view.mm index 515b9a5..685f3bc 100644 --- a/chrome/browser/cocoa/bubble_view.mm +++ b/chrome/browser/cocoa/bubble_view.mm @@ -4,7 +4,8 @@ #import "chrome/browser/cocoa/bubble_view.h" -#import "chrome/browser/cocoa/GTMTheme.h" +#include "chrome/browser/browser_theme_provider.h" +#import "chrome/browser/cocoa/themed_window.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" @@ -51,16 +52,6 @@ const float kWindowEdge = 0.7f; return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; } -// Asks the given theme provider for its theme. If there isn't one specified, -// check the window we are in. May still return nil if the window doesn't -// support themeing. -- (GTMTheme*)gtm_theme { - GTMTheme* theme = [themeProvider_ gtm_theme]; - if (!theme) - theme = [[self window] gtm_theme]; - return theme; -} - // Draws the themed background and the text. Will draw a gray bg if no theme. - (void)drawRect:(NSRect)rect { float topLeftRadius = @@ -72,7 +63,7 @@ const float kWindowEdge = 0.7f; float bottomRightRadius = cornerFlags_ & kRoundedBottomRightCorner ? kBubbleCornerRadius : 0; - GTMTheme* theme = [self gtm_theme]; + ThemeProvider* themeProvider = [themeProvider_ themeProvider]; // Background / Edge @@ -85,26 +76,18 @@ const float kWindowEdge = 0.7f; bottomLeftCornerRadius:bottomLeftRadius bottomRightCornerRadius:bottomRightRadius]; - NSColor* color = - [theme backgroundColorForStyle:GTMThemeStyleToolBar - state:GTMThemeStateActiveWindow]; - - // workaround for default theme - // TODO(alcor) next GTM update return nil for background color if not set; - // http://crbug.com/25196 - if ([color isEqual:[NSColor colorWithCalibratedWhite:0.5 alpha:1.0]]) - color = nil; - if (!color) - color = [NSColor colorWithCalibratedWhite:0.9 alpha:1.0]; - [color set]; + if (themeProvider) + [themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TOOLBAR, true) set]; [border fill]; [[NSColor colorWithDeviceWhite:kWindowEdge alpha:1.0f] set]; [border stroke]; // Text - NSColor* textColor = [theme textColorForStyle:GTMThemeStyleTabBarSelected - state:GTMThemeStateActiveWindow]; + NSColor* textColor = [NSColor blackColor]; + if (themeProvider) + textColor = themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, + true); NSFont* textFont = [self font]; scoped_nsobject<NSShadow> textShadow([[NSShadow alloc] init]); [textShadow setShadowBlurRadius:0.0f]; diff --git a/chrome/browser/cocoa/chrome_browser_window.mm b/chrome/browser/cocoa/chrome_browser_window.mm index 1030bc8..897f6ac 100644 --- a/chrome/browser/cocoa/chrome_browser_window.mm +++ b/chrome/browser/cocoa/chrome_browser_window.mm @@ -5,11 +5,13 @@ #import "chrome/browser/cocoa/chrome_browser_window.h" #include "base/logging.h" -#import "chrome/browser/cocoa/browser_window_controller.h" +#include "chrome/browser/browser_theme_provider.h" #import "chrome/browser/cocoa/browser_frame_view.h" +#import "chrome/browser/cocoa/browser_window_controller.h" #import "chrome/browser/cocoa/tab_strip_controller.h" -#import "chrome/browser/renderer_host/render_widget_host_view_mac.h" +#import "chrome/browser/cocoa/themed_window.h" #include "chrome/browser/global_keyboard_shortcuts_mac.h" +#import "chrome/browser/renderer_host/render_widget_host_view_mac.h" namespace { // Size of the gradient. Empirically determined so that the gradient looks @@ -81,7 +83,7 @@ namespace { NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(themeDidChangeNotification:) - name:kGTMThemeDidChangeNotification + name:kBrowserThemeDidChangeNotification object:nil]; // Hook ourselves up to get notified if the user changes the system @@ -263,10 +265,7 @@ namespace { // Called after the current theme has changed. - (void)themeDidChangeNotification:(NSNotification*)aNotification { - GTMTheme* theme = [aNotification object]; - if ([theme isEqual:[self gtm_theme]]) { - [[self frameView] setNeedsDisplay:YES]; - } + [[self frameView] setNeedsDisplay:YES]; } - (void)systemThemeDidChangeNotification:(NSNotification*)aNotification { @@ -343,4 +342,12 @@ namespace { return [super constrainFrameRect:frame toScreen:screen]; } +- (ThemeProvider*)themeProvider { + return [[self windowController] themeProvider]; +} + +- (NSPoint)themePatternPhase { + return [[self windowController] themePatternPhase]; +} + @end diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm index 259385e..70b0b22 100644 --- a/chrome/browser/cocoa/download_shelf_controller.mm +++ b/chrome/browser/cocoa/download_shelf_controller.mm @@ -46,7 +46,7 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12; - (void)closed; - (void)updateTheme; -- (void)themeDidChangeNotification:(NSNotification*)aNotification; +- (void)themeDidChangeNotification:(NSNotification*)notification; @end diff --git a/chrome/browser/cocoa/gradient_button_cell.mm b/chrome/browser/cocoa/gradient_button_cell.mm index 0ad0bab..e0c90c6 100644 --- a/chrome/browser/cocoa/gradient_button_cell.mm +++ b/chrome/browser/cocoa/gradient_button_cell.mm @@ -217,6 +217,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; NSColor* patternColor = [NSColor colorWithPatternImage:backgroundImage]; [patternColor set]; // Set the phase to match window. + // TODO(avi) http://crbug.com/36485; base != window NSRect trueRect = [controlView convertRectToBase:cellFrame]; [[NSGraphicsContext currentContext] setPatternPhase:NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect))]; diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm index 321437f..a08f732 100644 --- a/chrome/browser/cocoa/status_bubble_mac.mm +++ b/chrome/browser/cocoa/status_bubble_mac.mm @@ -13,7 +13,6 @@ #include "base/string_util.h" #include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/bubble_view.h" -#import "chrome/browser/cocoa/GTMTheme.h" #include "googleurl/src/gurl.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" diff --git a/chrome/browser/cocoa/status_bubble_mac_unittest.mm b/chrome/browser/cocoa/status_bubble_mac_unittest.mm index 0d0fbb9..bb0da90 100644 --- a/chrome/browser/cocoa/status_bubble_mac_unittest.mm +++ b/chrome/browser/cocoa/status_bubble_mac_unittest.mm @@ -9,24 +9,11 @@ #import "chrome/browser/cocoa/bubble_view.h" #import "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" -#import "chrome/browser/cocoa/GTMTheme.h" #import "chrome/browser/cocoa/status_bubble_mac.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -@interface StatusBubbleMacTestWindowDelegate : NSObject <GTMThemeDelegate> -@end -@implementation StatusBubbleMacTestWindowDelegate -- (GTMTheme*)gtm_themeForWindow:(NSWindow*)window { - return [[[GTMTheme alloc] init] autorelease]; -} - -- (NSPoint)gtm_themePatternPhaseForWindow:(NSWindow*)window { - return NSZeroPoint; -} -@end - // The test delegate records all of the status bubble object's state // transitions. @interface StatusBubbleMacTestDelegate : NSObject { @@ -123,14 +110,6 @@ class StatusBubbleMacTest : public CocoaTest { StatusBubbleMac* bubble_; // Strong. }; -TEST_F(StatusBubbleMacTest, Theme) { - bubble_->SetStatus(L"Theme test"); // Creates the window - [GetParent() setDelegate: - [[[StatusBubbleMacTestWindowDelegate alloc] init] autorelease]]; - EXPECT_TRUE([GetParent() gtm_theme] != nil); - EXPECT_TRUE([[GetWindow() contentView] gtm_theme] != nil); -} - TEST_F(StatusBubbleMacTest, SetStatus) { bubble_->SetStatus(L""); bubble_->SetStatus(L"This is a test"); diff --git a/chrome/browser/cocoa/styled_text_field_cell.mm b/chrome/browser/cocoa/styled_text_field_cell.mm index e0134fa..4b34d48 100644 --- a/chrome/browser/cocoa/styled_text_field_cell.mm +++ b/chrome/browser/cocoa/styled_text_field_cell.mm @@ -7,7 +7,9 @@ #include "app/gfx/font.h" #include "app/resource_bundle.h" #include "base/logging.h" -#import "chrome/browser/cocoa/GTMTheme.h" +#include "chrome/browser/browser_theme_provider.h" +#import "chrome/browser/cocoa/themed_window.h" +#include "grit/theme_resources.h" @implementation StyledTextFieldCell @@ -56,13 +58,17 @@ // Paint button background image if there is one (otherwise the border won't // look right). - GTMTheme* theme = [controlView gtm_theme]; - NSImage* backgroundImage = - [theme backgroundImageForStyle:GTMThemeStyleToolBarButton state:YES]; + ThemeProvider* themeProvider = [[controlView window] themeProvider]; + NSImage* backgroundImage = nil; + if (themeProvider) { + backgroundImage = + themeProvider->GetNSImageNamed(IDR_THEME_BUTTON_BACKGROUND, false); + } if (backgroundImage) { NSColor* patternColor = [NSColor colorWithPatternImage:backgroundImage]; [patternColor set]; // Set the phase to match window. + // TODO(avi) http://crbug.com/36485; base != window NSRect trueRect = [controlView convertRectToBase:cellFrame]; [[NSGraphicsContext currentContext] setPatternPhase:NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect))]; @@ -71,7 +77,13 @@ // Draw the outer stroke (over the background). BOOL active = [[controlView window] isMainWindow]; - [[theme strokeColorForStyle:GTMThemeStyleToolBarButton state:active] set]; + if (themeProvider) { + NSColor* strokeColor = themeProvider->GetNSColor( + active ? BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE : + BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + true); + [strokeColor set]; + } NSFrameRectWithWidthUsingOperation(frame, 1, NSCompositeSourceOver); // Draw the background for the interior. diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm index 47360f0..ef0455e 100644 --- a/chrome/browser/cocoa/tab_controller.mm +++ b/chrome/browser/cocoa/tab_controller.mm @@ -4,11 +4,12 @@ #include "app/l10n_util_mac.h" #include "base/mac_util.h" -#import "chrome/browser/cocoa/GTMTheme.h" +#import "chrome/browser/browser_theme_provider.h" #import "chrome/browser/cocoa/menu_controller.h" #import "chrome/browser/cocoa/tab_controller.h" #import "chrome/browser/cocoa/tab_controller_target.h" #import "chrome/browser/cocoa/tab_view.h" +#import "chrome/browser/cocoa/themed_window.h" #include "grit/generated_resources.h" @implementation TabController @@ -88,7 +89,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { object:[self view]]; [defaultCenter addObserver:self selector:@selector(themeChangedNotification:) - name:kGTMThemeDidChangeNotification + name:kBrowserThemeDidChangeNotification object:nil]; } return self; @@ -273,15 +274,16 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { - (void)updateTitleColor { NSColor* titleColor = nil; - GTMTheme* theme = [[self view] gtm_theme]; - if (![self selected]) { - titleColor = [theme textColorForStyle:GTMThemeStyleTabBarDeselected - state:GTMThemeStateActiveWindow]; + ThemeProvider* theme = [[[self view] window] themeProvider]; + if (theme && ![self selected]) { + titleColor = + theme->GetNSColor(BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT, + true); } // Default to the selected text color unless told otherwise. - if (!titleColor) { - titleColor = [theme textColorForStyle:GTMThemeStyleTabBarSelected - state:GTMThemeStateActiveWindow]; + if (theme && !titleColor) { + titleColor = theme->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, + true); } [titleView_ setTextColor:titleColor ? titleColor : [NSColor textColor]]; } @@ -295,11 +297,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { } - (void)themeChangedNotification:(NSNotification*)notification { - GTMTheme* theme = [notification object]; - NSView* view = [self view]; - if ([theme isEqual:[view gtm_theme]]) { - [self updateTitleColor]; - } + [self updateTitleColor]; } // Called by the tabs to determine whether we are in rapid (tab) closure mode. diff --git a/chrome/browser/cocoa/themed_window.h b/chrome/browser/cocoa/themed_window.h new file mode 100644 index 0000000..5319d3c --- /dev/null +++ b/chrome/browser/cocoa/themed_window.h @@ -0,0 +1,19 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_COCOA_THEMED_WINDOW_H_ +#define CHROME_BROWSER_COCOA_THEMED_WINDOW_H_ + +#import <Cocoa/Cocoa.h> + +class ThemeProvider; + +// Implemented by windows that support theming. + +@interface NSWindow (ThemeProvider) +- (ThemeProvider*)themeProvider; +- (NSPoint)themePatternPhase; +@end + +#endif // CHROME_BROWSER_COCOA_THEMED_WINDOW_H_ diff --git a/chrome/browser/cocoa/themed_window.mm b/chrome/browser/cocoa/themed_window.mm new file mode 100644 index 0000000..c110cac --- /dev/null +++ b/chrome/browser/cocoa/themed_window.mm @@ -0,0 +1,19 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "chrome/browser/cocoa/themed_window.h" + +// Default implementations; used mostly for tests so that the hosting windows +// don't needs to know about the theming machinery. +@implementation NSWindow (ThemeProvider) + +- (ThemeProvider*)themeProvider { + return NULL; +} + +- (NSPoint)themePatternPhase { + return NSZeroPoint; +} + +@end diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 0d65bef..53eb819 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -682,6 +682,8 @@ 'browser/cocoa/table_row_nsimage_cache.mm', 'browser/cocoa/task_manager_mac.h', 'browser/cocoa/task_manager_mac.mm', + 'browser/cocoa/themed_window.h', + 'browser/cocoa/themed_window.mm', 'browser/cocoa/theme_install_bubble_view.h', 'browser/cocoa/theme_install_bubble_view.mm', 'browser/cocoa/throbber_view.h', |