| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" | 5 #include "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #import "chrome/browser/themes/theme_service.h" | 8 #import "chrome/browser/themes/theme_service.h" |
| 9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/themed_window.h" | 10 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 11 | 11 #include "chrome/browser/ui/infobar.h" |
| 12 namespace { | 12 #include "skia/ext/skia_utils_mac.h" |
| 13 | |
| 14 const double kBackgroundColorTop[3] = | |
| 15 {255.0 / 255.0, 242.0 / 255.0, 183.0 / 255.0}; | |
| 16 const double kBackgroundColorBottom[3] = | |
| 17 {250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0}; | |
| 18 } | |
| 19 | 13 |
| 20 @implementation InfoBarGradientView | 14 @implementation InfoBarGradientView |
| 21 | 15 |
| 22 - (id)initWithFrame:(NSRect)frameRect { | 16 - (void)setInfobarType:(InfoBarDelegate::Type)infobarType { |
| 23 if ((self = [super initWithFrame:frameRect])) { | 17 SkColor topColor = infobar::GetTopColor(infobarType); |
| 24 NSColor* startingColor = | 18 SkColor bottomColor = infobar::GetBottomColor(infobarType); |
| 25 [NSColor colorWithCalibratedRed:kBackgroundColorTop[0] | 19 scoped_nsobject<NSGradient> gradient([[NSGradient alloc] |
| 26 green:kBackgroundColorTop[1] | 20 initWithStartingColor:gfx::SkColorToCalibratedNSColor(topColor) |
| 27 blue:kBackgroundColorTop[2] | 21 endingColor:gfx::SkColorToCalibratedNSColor(bottomColor)]); |
| 28 alpha:1.0]; | 22 [self setGradient:gradient]; |
| 29 NSColor* endingColor = | |
| 30 [NSColor colorWithCalibratedRed:kBackgroundColorBottom[0] | |
| 31 green:kBackgroundColorBottom[1] | |
| 32 blue:kBackgroundColorBottom[2] | |
| 33 alpha:1.0]; | |
| 34 scoped_nsobject<NSGradient> gradient( | |
| 35 [[NSGradient alloc] initWithStartingColor:startingColor | |
| 36 endingColor:endingColor]); | |
| 37 [self setGradient:gradient]; | |
| 38 } | |
| 39 return self; | |
| 40 } | 23 } |
| 41 | 24 |
| 42 - (NSColor*)strokeColor { | 25 - (NSColor*)strokeColor { |
| 43 ui::ThemeProvider* themeProvider = [[self window] themeProvider]; | 26 ui::ThemeProvider* themeProvider = [[self window] themeProvider]; |
| 44 if (!themeProvider) | 27 if (!themeProvider) |
| 45 return [NSColor blackColor]; | 28 return [NSColor blackColor]; |
| 46 | 29 |
| 47 BOOL active = [[self window] isMainWindow]; | 30 BOOL active = [[self window] isMainWindow]; |
| 48 return themeProvider->GetNSColor( | 31 return themeProvider->GetNSColor( |
| 49 active ? ThemeService::COLOR_TOOLBAR_STROKE : | 32 active ? ThemeService::COLOR_TOOLBAR_STROKE : |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 80 } |
| 98 | 81 |
| 99 - (id)accessibilityAttributeValue:(NSString*)attribute { | 82 - (id)accessibilityAttributeValue:(NSString*)attribute { |
| 100 if ([attribute isEqual:NSAccessibilityRoleAttribute]) | 83 if ([attribute isEqual:NSAccessibilityRoleAttribute]) |
| 101 return NSAccessibilityGroupRole; | 84 return NSAccessibilityGroupRole; |
| 102 | 85 |
| 103 return [super accessibilityAttributeValue:attribute]; | 86 return [super accessibilityAttributeValue:attribute]; |
| 104 } | 87 } |
| 105 | 88 |
| 106 @end | 89 @end |
| OLD | NEW |