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 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome", nil), | |
48 ui::SCALE_FACTOR_NONE); | |
49 | |
50 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { | 54 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { |
51 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), | 55 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), |
52 SCALE_FACTOR_100P); | 56 SCALE_FACTOR_100P); |
53 } | 57 } |
54 | 58 |
55 if (IsScaleFactorSupported(SCALE_FACTOR_200P)) { | 59 if (IsScaleFactorSupported(SCALE_FACTOR_200P)) { |
56 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_200_percent", nil), | 60 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_200_percent", nil), |
57 SCALE_FACTOR_200P); | 61 SCALE_FACTOR_200P); |
58 } | 62 } |
59 } | 63 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 176 |
173 // Another thread raced the load and has already cached the image. | 177 // Another thread raced the load and has already cached the image. |
174 if (images_.count(resource_id)) | 178 if (images_.count(resource_id)) |
175 return images_[resource_id]; | 179 return images_[resource_id]; |
176 | 180 |
177 images_[resource_id] = image; | 181 images_[resource_id] = image; |
178 return images_[resource_id]; | 182 return images_[resource_id]; |
179 } | 183 } |
180 | 184 |
181 } // namespace ui | 185 } // namespace ui |
OLD | NEW |