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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Check to see if we already have the image in the cache. | 44 // Check to see if we already have the image in the cache. |
45 NSImageMap::const_iterator nsimage_iter = nsimage_cache_.find(id); | 45 NSImageMap::const_iterator nsimage_iter = nsimage_cache_.find(id); |
46 if (nsimage_iter != nsimage_cache_.end()) | 46 if (nsimage_iter != nsimage_cache_.end()) |
47 return nsimage_iter->second; | 47 return nsimage_iter->second; |
48 | 48 |
49 // Why don't we load the file directly into the image instead of the whole | 49 // Why don't we load the file directly into the image instead of the whole |
50 // gfx::Image > native conversion? | 50 // gfx::Image > native conversion? |
51 // - For consistency with other platforms. | 51 // - For consistency with other platforms. |
52 // - To get the generated tinted images. | 52 // - To get the generated tinted images. |
53 NSImage* nsimage = nil; | 53 NSImage* nsimage = nil; |
54 if (theme_pack_.get()) { | 54 if (theme_supplier_.get()) { |
55 gfx::Image image = theme_pack_->GetImageNamed(id); | 55 gfx::Image image = theme_supplier_->GetImageNamed(id); |
56 if (!image.IsEmpty()) | 56 if (!image.IsEmpty()) |
57 nsimage = image.ToNSImage(); | 57 nsimage = image.ToNSImage(); |
58 } | 58 } |
59 | 59 |
60 // If the theme didn't override this image then load it from the resource | 60 // If the theme didn't override this image then load it from the resource |
61 // bundle. | 61 // bundle. |
62 if (!nsimage) { | 62 if (!nsimage) { |
63 nsimage = rb_.GetNativeImageNamed(id).ToNSImage(); | 63 nsimage = rb_.GetNativeImageNamed(id).ToNSImage(); |
64 } | 64 } |
65 | 65 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Check to see if we already have the color in the cache. | 119 // Check to see if we already have the color in the cache. |
120 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); | 120 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); |
121 if (nscolor_iter != nscolor_cache_.end()) { | 121 if (nscolor_iter != nscolor_cache_.end()) { |
122 bool cached_is_default = nscolor_iter->second.second; | 122 bool cached_is_default = nscolor_iter->second.second; |
123 if (!cached_is_default || allow_default) | 123 if (!cached_is_default || allow_default) |
124 return nscolor_iter->second.first; | 124 return nscolor_iter->second.first; |
125 } | 125 } |
126 | 126 |
127 bool is_default = false; | 127 bool is_default = false; |
128 SkColor sk_color; | 128 SkColor sk_color; |
129 if (theme_pack_.get() && theme_pack_->GetColor(id, &sk_color)) { | 129 if (theme_supplier_.get() && theme_supplier_->GetColor(id, &sk_color)) { |
130 is_default = false; | 130 is_default = false; |
131 } else { | 131 } else { |
132 is_default = true; | 132 is_default = true; |
133 sk_color = ThemeProperties::GetDefaultColor(id); | 133 sk_color = ThemeProperties::GetDefaultColor(id); |
134 } | 134 } |
135 | 135 |
136 if (is_default && !allow_default) | 136 if (is_default && !allow_default) |
137 return nil; | 137 return nil; |
138 | 138 |
139 NSColor* color = gfx::SkColorToCalibratedNSColor(sk_color); | 139 NSColor* color = gfx::SkColorToCalibratedNSColor(sk_color); |
(...skipping 11 matching lines...) Expand all Loading... |
151 // Check to see if we already have the color in the cache. | 151 // Check to see if we already have the color in the cache. |
152 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); | 152 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); |
153 if (nscolor_iter != nscolor_cache_.end()) { | 153 if (nscolor_iter != nscolor_cache_.end()) { |
154 bool cached_is_default = nscolor_iter->second.second; | 154 bool cached_is_default = nscolor_iter->second.second; |
155 if (!cached_is_default || allow_default) | 155 if (!cached_is_default || allow_default) |
156 return nscolor_iter->second.first; | 156 return nscolor_iter->second.first; |
157 } | 157 } |
158 | 158 |
159 bool is_default = false; | 159 bool is_default = false; |
160 color_utils::HSL tint; | 160 color_utils::HSL tint; |
161 if (theme_pack_.get() && theme_pack_->GetTint(id, &tint)) { | 161 if (theme_supplier_.get() && theme_supplier_->GetTint(id, &tint)) { |
162 is_default = false; | 162 is_default = false; |
163 } else { | 163 } else { |
164 is_default = true; | 164 is_default = true; |
165 tint = ThemeProperties::GetDefaultTint(id); | 165 tint = ThemeProperties::GetDefaultTint(id); |
166 } | 166 } |
167 | 167 |
168 if (is_default && !allow_default) | 168 if (is_default && !allow_default) |
169 return nil; | 169 return nil; |
170 | 170 |
171 NSColor* tint_color = nil; | 171 NSColor* tint_color = nil; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 316 } |
317 nscolor_cache_.clear(); | 317 nscolor_cache_.clear(); |
318 | 318 |
319 // Free gradients. | 319 // Free gradients. |
320 for (NSGradientMap::iterator i = nsgradient_cache_.begin(); | 320 for (NSGradientMap::iterator i = nsgradient_cache_.begin(); |
321 i != nsgradient_cache_.end(); i++) { | 321 i != nsgradient_cache_.end(); i++) { |
322 [i->second release]; | 322 [i->second release]; |
323 } | 323 } |
324 nsgradient_cache_.clear(); | 324 nsgradient_cache_.clear(); |
325 } | 325 } |
OLD | NEW |