| 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/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 NSString *resource_path; | 27 NSString *resource_path; |
| 28 if ([mac_locale length]) { | 28 if ([mac_locale length]) { |
| 29 resource_path = [base::mac::FrameworkBundle() pathForResource:name | 29 resource_path = [base::mac::FrameworkBundle() pathForResource:name |
| 30 ofType:@"pak" | 30 ofType:@"pak" |
| 31 inDirectory:@"" | 31 inDirectory:@"" |
| 32 forLocalization:mac_locale]; | 32 forLocalization:mac_locale]; |
| 33 } else { | 33 } else { |
| 34 resource_path = [base::mac::FrameworkBundle() pathForResource:name | 34 resource_path = [base::mac::FrameworkBundle() pathForResource:name |
| 35 ofType:@"pak"]; | 35 ofType:@"pak"]; |
| 36 } | 36 } |
| 37 | |
| 38 if (!resource_path) { | 37 if (!resource_path) { |
| 39 // Trying to load a resources file that doesn't exist is an error. Return | 38 // Return just the name of the pak file. |
| 40 // just the name of the pack file so that further down the line it is easier | 39 return base::FilePath(base::SysNSStringToUTF8(name) + ".pak"); |
| 41 // to track down what happened. | |
| 42 std::string name_string = base::SysNSStringToUTF8(name); | |
| 43 std::string locale_string = base::SysNSStringToUTF8(mac_locale); | |
| 44 LOG(ERROR) << "Tried to get the file path of a non-existent pak file '" | |
| 45 << name_string << "' for locale '" << locale_string << "'"; | |
| 46 return base::FilePath(name_string + ".pak"); | |
| 47 } | 40 } |
| 48 return base::FilePath([resource_path fileSystemRepresentation]); | 41 return base::FilePath([resource_path fileSystemRepresentation]); |
| 49 } | 42 } |
| 50 | 43 |
| 51 } // namespace | 44 } // namespace |
| 52 | 45 |
| 53 void ResourceBundle::LoadCommonResources() { | 46 void ResourceBundle::LoadCommonResources() { |
| 54 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { | 47 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { |
| 55 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), | 48 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), |
| 56 SCALE_FACTOR_100P); | 49 SCALE_FACTOR_100P); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 186 |
| 194 // Another thread raced the load and has already cached the image. | 187 // Another thread raced the load and has already cached the image. |
| 195 if (images_.count(resource_id)) | 188 if (images_.count(resource_id)) |
| 196 return images_[resource_id]; | 189 return images_[resource_id]; |
| 197 | 190 |
| 198 images_[resource_id] = image; | 191 images_[resource_id] = image; |
| 199 return images_[resource_id]; | 192 return images_[resource_id]; |
| 200 } | 193 } |
| 201 | 194 |
| 202 } // namespace ui | 195 } // namespace ui |
| OLD | NEW |