| 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/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/themes/browser_theme_pack.h" | 10 #include "chrome/browser/themes/browser_theme_pack.h" |
| 11 #include "skia/ext/skia_utils_mac.h" | 11 #include "skia/ext/skia_utils_mac.h" |
| 12 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" | 12 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/color_utils.h" | 14 #include "ui/gfx/color_utils.h" |
| 15 #include "ui/gfx/image.h" | 15 #include "ui/gfx/image.h" |
| 16 #include "skia/ext/skia_utils_mac.h" |
| 16 | 17 |
| 17 NSString* const kBrowserThemeDidChangeNotification = | 18 NSString* const kBrowserThemeDidChangeNotification = |
| 18 @"BrowserThemeDidChangeNotification"; | 19 @"BrowserThemeDidChangeNotification"; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 void HSLToHSB(const color_utils::HSL& hsl, CGFloat* h, CGFloat* s, CGFloat* b) { | 23 void HSLToHSB(const color_utils::HSL& hsl, CGFloat* h, CGFloat* s, CGFloat* b) { |
| 23 SkColor color = color_utils::HSLToSkColor(hsl, 255); // alpha doesn't matter | 24 SkColor color = color_utils::HSLToSkColor(hsl, 255); // alpha doesn't matter |
| 24 SkScalar hsv[3]; | 25 SkScalar hsv[3]; |
| 25 SkColorToHSV(color, hsv); | 26 SkColorToHSV(color, hsv); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (theme_pack_.get() && theme_pack_->GetColor(id, &sk_color)) { | 126 if (theme_pack_.get() && theme_pack_->GetColor(id, &sk_color)) { |
| 126 is_default = false; | 127 is_default = false; |
| 127 } else { | 128 } else { |
| 128 is_default = true; | 129 is_default = true; |
| 129 sk_color = GetDefaultColor(id); | 130 sk_color = GetDefaultColor(id); |
| 130 } | 131 } |
| 131 | 132 |
| 132 if (is_default && !allow_default) | 133 if (is_default && !allow_default) |
| 133 return nil; | 134 return nil; |
| 134 | 135 |
| 135 NSColor* color = [NSColor | 136 NSColor* color = gfx::SkColorToCalibratedNSColor(sk_color); |
| 136 colorWithCalibratedRed:SkColorGetR(sk_color)/255.0 | |
| 137 green:SkColorGetG(sk_color)/255.0 | |
| 138 blue:SkColorGetB(sk_color)/255.0 | |
| 139 alpha:SkColorGetA(sk_color)/255.0]; | |
| 140 | 137 |
| 141 // We loaded successfully. Cache the color. | 138 // We loaded successfully. Cache the color. |
| 142 if (color) | 139 if (color) |
| 143 nscolor_cache_[id] = std::make_pair([color retain], is_default); | 140 nscolor_cache_[id] = std::make_pair([color retain], is_default); |
| 144 | 141 |
| 145 return color; | 142 return color; |
| 146 } | 143 } |
| 147 | 144 |
| 148 NSColor* ThemeService::GetNSColorTint(int id, bool allow_default) const { | 145 NSColor* ThemeService::GetNSColorTint(int id, bool allow_default) const { |
| 149 DCHECK(CalledOnValidThread()); | 146 DCHECK(CalledOnValidThread()); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 313 } |
| 317 nscolor_cache_.clear(); | 314 nscolor_cache_.clear(); |
| 318 | 315 |
| 319 // Free gradients. | 316 // Free gradients. |
| 320 for (NSGradientMap::iterator i = nsgradient_cache_.begin(); | 317 for (NSGradientMap::iterator i = nsgradient_cache_.begin(); |
| 321 i != nsgradient_cache_.end(); i++) { | 318 i != nsgradient_cache_.end(); i++) { |
| 322 [i->second release]; | 319 [i->second release]; |
| 323 } | 320 } |
| 324 nsgradient_cache_.clear(); | 321 nsgradient_cache_.clear(); |
| 325 } | 322 } |
| OLD | NEW |