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 |
37 if (!resource_path) { | 38 if (!resource_path) { |
38 // Return just the name of the pak file. | 39 // Trying to load a resources file that doesn't exist is an error. Return |
39 return base::FilePath(base::SysNSStringToUTF8(name) + ".pak"); | 40 // just the name of the pack file so that further down the line it is easier |
| 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"); |
40 } | 47 } |
41 return base::FilePath([resource_path fileSystemRepresentation]); | 48 return base::FilePath([resource_path fileSystemRepresentation]); |
42 } | 49 } |
43 | 50 |
44 } // namespace | 51 } // namespace |
45 | 52 |
46 void ResourceBundle::LoadCommonResources() { | 53 void ResourceBundle::LoadCommonResources() { |
47 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { | 54 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { |
48 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), | 55 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), |
49 SCALE_FACTOR_100P); | 56 SCALE_FACTOR_100P); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 193 |
187 // Another thread raced the load and has already cached the image. | 194 // Another thread raced the load and has already cached the image. |
188 if (images_.count(resource_id)) | 195 if (images_.count(resource_id)) |
189 return images_[resource_id]; | 196 return images_[resource_id]; |
190 | 197 |
191 images_[resource_id] = image; | 198 images_[resource_id] = image; |
192 return images_[resource_id]; | 199 return images_[resource_id]; |
193 } | 200 } |
194 | 201 |
195 } // namespace ui | 202 } // namespace ui |
OLD | NEW |