| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // Don't try to load empty values or values that are not absolute paths. | 82 // Don't try to load empty values or values that are not absolute paths. |
| 83 if (locale_file_path.empty() || !locale_file_path.IsAbsolute()) | 83 if (locale_file_path.empty() || !locale_file_path.IsAbsolute()) |
| 84 return base::FilePath(); | 84 return base::FilePath(); |
| 85 | 85 |
| 86 if (test_file_exists && !base::PathExists(locale_file_path)) | 86 if (test_file_exists && !base::PathExists(locale_file_path)) |
| 87 return base::FilePath(); | 87 return base::FilePath(); |
| 88 | 88 |
| 89 return locale_file_path; | 89 return locale_file_path; |
| 90 } | 90 } |
| 91 | 91 |
| 92 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 92 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) { |
| 93 // Flipped images are not used on iOS. | |
| 94 DCHECK_EQ(rtl, RTL_DISABLED); | |
| 95 | |
| 96 // Check to see if the image is already in the cache. | 93 // Check to see if the image is already in the cache. |
| 97 { | 94 { |
| 98 base::AutoLock lock(*images_and_fonts_lock_); | 95 base::AutoLock lock(*images_and_fonts_lock_); |
| 99 ImageMap::iterator found = images_.find(resource_id); | 96 ImageMap::iterator found = images_.find(resource_id); |
| 100 if (found != images_.end()) { | 97 if (found != images_.end()) { |
| 101 return found->second; | 98 return found->second; |
| 102 } | 99 } |
| 103 } | 100 } |
| 104 | 101 |
| 105 gfx::Image image; | 102 gfx::Image image; |
| 106 if (delegate_) | 103 if (delegate_) |
| 107 image = delegate_->GetNativeImageNamed(resource_id, rtl); | 104 image = delegate_->GetNativeImageNamed(resource_id); |
| 108 | 105 |
| 109 if (image.IsEmpty()) { | 106 if (image.IsEmpty()) { |
| 110 // Load the raw data from the resource pack at the current supported scale | 107 // Load the raw data from the resource pack at the current supported scale |
| 111 // factor. This code assumes that only one of the possible scale factors is | 108 // factor. This code assumes that only one of the possible scale factors is |
| 112 // supported at runtime, based on the device resolution. | 109 // supported at runtime, based on the device resolution. |
| 113 ui::ScaleFactor scale_factor = GetMaxScaleFactor(); | 110 ui::ScaleFactor scale_factor = GetMaxScaleFactor(); |
| 114 | 111 |
| 115 scoped_refptr<base::RefCountedStaticMemory> data( | 112 scoped_refptr<base::RefCountedStaticMemory> data( |
| 116 LoadDataResourceBytesForScale(resource_id, scale_factor)); | 113 LoadDataResourceBytesForScale(resource_id, scale_factor)); |
| 117 | 114 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 170 |
| 174 // Another thread raced the load and has already cached the image. | 171 // Another thread raced the load and has already cached the image. |
| 175 if (images_.count(resource_id)) | 172 if (images_.count(resource_id)) |
| 176 return images_[resource_id]; | 173 return images_[resource_id]; |
| 177 | 174 |
| 178 images_[resource_id] = image; | 175 images_[resource_id] = image; |
| 179 return images_[resource_id]; | 176 return images_[resource_id]; |
| 180 } | 177 } |
| 181 | 178 |
| 182 } // namespace ui | 179 } // namespace ui |
| OLD | NEW |