| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_pack_.get()) { |
| 55 const gfx::Image* image = theme_pack_->GetImageNamed(id); | 55 gfx::Image image = theme_pack_->GetImageNamed(id); |
| 56 if (image) | 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 |
| 66 // We loaded successfully. Cache the image. | 66 // We loaded successfully. Cache the image. |
| 67 if (nsimage) { | 67 if (nsimage) { |
| (...skipping 248 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 |