OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mac/scoped_nsobject.h" |
8 #include "chrome/browser/infobars/infobar.h" | 8 #include "chrome/browser/infobars/infobar.h" |
9 #import "chrome/browser/themes/theme_properties.h" | 9 #import "chrome/browser/themes/theme_properties.h" |
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
11 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 11 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
13 #import "chrome/browser/ui/cocoa/themed_window.h" | 13 #import "chrome/browser/ui/cocoa/themed_window.h" |
14 #include "skia/ext/skia_utils_mac.h" | 14 #include "skia/ext/skia_utils_mac.h" |
15 #include "ui/base/theme_provider.h" | 15 #include "ui/base/theme_provider.h" |
16 | 16 |
17 namespace { | 17 namespace { |
(...skipping 17 matching lines...) Expand all Loading... |
35 - (id)initWithCoder:(NSCoder*)decoder { | 35 - (id)initWithCoder:(NSCoder*)decoder { |
36 if ((self = [super initWithCoder:decoder])) { | 36 if ((self = [super initWithCoder:decoder])) { |
37 hasTip_ = YES; | 37 hasTip_ = YES; |
38 } | 38 } |
39 return self; | 39 return self; |
40 } | 40 } |
41 | 41 |
42 - (void)setInfobarType:(InfoBarDelegate::Type)infobarType { | 42 - (void)setInfobarType:(InfoBarDelegate::Type)infobarType { |
43 SkColor topColor = GetInfoBarTopColor(infobarType); | 43 SkColor topColor = GetInfoBarTopColor(infobarType); |
44 SkColor bottomColor = GetInfoBarBottomColor(infobarType); | 44 SkColor bottomColor = GetInfoBarBottomColor(infobarType); |
45 scoped_nsobject<NSGradient> gradient([[NSGradient alloc] | 45 base::scoped_nsobject<NSGradient> gradient([[NSGradient alloc] |
46 initWithStartingColor:gfx::SkColorToCalibratedNSColor(topColor) | 46 initWithStartingColor:gfx::SkColorToCalibratedNSColor(topColor) |
47 endingColor:gfx::SkColorToCalibratedNSColor(bottomColor)]); | 47 endingColor:gfx::SkColorToCalibratedNSColor(bottomColor)]); |
48 [self setGradient:gradient]; | 48 [self setGradient:gradient]; |
49 } | 49 } |
50 | 50 |
51 - (NSColor*)strokeColor { | 51 - (NSColor*)strokeColor { |
52 ui::ThemeProvider* themeProvider = [[self window] themeProvider]; | 52 ui::ThemeProvider* themeProvider = [[self window] themeProvider]; |
53 if (!themeProvider) | 53 if (!themeProvider) |
54 return [NSColor blackColor]; | 54 return [NSColor blackColor]; |
55 | 55 |
(...skipping 21 matching lines...) Expand all Loading... |
77 if (hasTip_) { | 77 if (hasTip_) { |
78 [infoBarPath lineToPoint:NSMakePoint(tipXOffset, NSMaxY(bounds))]; | 78 [infoBarPath lineToPoint:NSMakePoint(tipXOffset, NSMaxY(bounds))]; |
79 [infoBarPath relativeLineToPoint:NSMakePoint(kHalfWidth, | 79 [infoBarPath relativeLineToPoint:NSMakePoint(kHalfWidth, |
80 infobars::kTipHeight)]; | 80 infobars::kTipHeight)]; |
81 [infoBarPath relativeLineToPoint:NSMakePoint(kHalfWidth, | 81 [infoBarPath relativeLineToPoint:NSMakePoint(kHalfWidth, |
82 -infobars::kTipHeight)]; | 82 -infobars::kTipHeight)]; |
83 } | 83 } |
84 [infoBarPath lineToPoint:NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))]; | 84 [infoBarPath lineToPoint:NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))]; |
85 | 85 |
86 // Save off the top path of the infobar. | 86 // Save off the top path of the infobar. |
87 scoped_nsobject<NSBezierPath> topPath([infoBarPath copy]); | 87 base::scoped_nsobject<NSBezierPath> topPath([infoBarPath copy]); |
88 | 88 |
89 [infoBarPath lineToPoint:NSMakePoint(NSMaxX(bounds), NSMinY(bounds))]; | 89 [infoBarPath lineToPoint:NSMakePoint(NSMaxX(bounds), NSMinY(bounds))]; |
90 [infoBarPath lineToPoint:NSMakePoint(NSMinX(bounds), NSMinY(bounds))]; | 90 [infoBarPath lineToPoint:NSMakePoint(NSMinX(bounds), NSMinY(bounds))]; |
91 [infoBarPath closePath]; | 91 [infoBarPath closePath]; |
92 | 92 |
93 // Draw the gradient. | 93 // Draw the gradient. |
94 [[self gradient] drawInBezierPath:infoBarPath angle:270]; | 94 [[self gradient] drawInBezierPath:infoBarPath angle:270]; |
95 | 95 |
96 NSColor* strokeColor = [self strokeColor]; | 96 NSColor* strokeColor = [self strokeColor]; |
97 if (strokeColor) { | 97 if (strokeColor) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 - (void)setHasTip:(BOOL)hasTip { | 144 - (void)setHasTip:(BOOL)hasTip { |
145 if (hasTip_ == hasTip) | 145 if (hasTip_ == hasTip) |
146 return; | 146 return; |
147 hasTip_ = hasTip; | 147 hasTip_ = hasTip; |
148 [self setNeedsDisplay:YES]; | 148 [self setNeedsDisplay:YES]; |
149 } | 149 } |
150 | 150 |
151 @end | 151 @end |
OLD | NEW |