| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 resource_path = [base::mac::FrameworkBundle() pathForResource:name | 32 resource_path = [base::mac::FrameworkBundle() pathForResource:name |
| 33 ofType:@"pak" | 33 ofType:@"pak" |
| 34 inDirectory:@"" | 34 inDirectory:@"" |
| 35 forLocalization:mac_locale]; | 35 forLocalization:mac_locale]; |
| 36 } else { | 36 } else { |
| 37 resource_path = [base::mac::FrameworkBundle() pathForResource:name | 37 resource_path = [base::mac::FrameworkBundle() pathForResource:name |
| 38 ofType:@"pak"]; | 38 ofType:@"pak"]; |
| 39 } | 39 } |
| 40 | 40 |
| 41 if (!resource_path) { | 41 if (!resource_path) { |
| 42 // Return just the name of the pack file. | 42 // Trying to load a resources file that doesn't exist is an error. Return |
| 43 return base::FilePath(base::SysNSStringToUTF8(name) + ".pak"); | 43 // just the name of the pack file so that further down the line it is easier |
| 44 // to track down what happened. |
| 45 std::string name_string = base::SysNSStringToUTF8(name); |
| 46 std::string locale_string = base::SysNSStringToUTF8(mac_locale); |
| 47 LOG(ERROR) << "Tried to get the file path of a non-existent pak file '" |
| 48 << name_string << "' for locale '" << locale_string << "'"; |
| 49 return base::FilePath(name_string + ".pak"); |
| 44 } | 50 } |
| 45 | 51 |
| 46 return base::FilePath([resource_path fileSystemRepresentation]); | 52 return base::FilePath([resource_path fileSystemRepresentation]); |
| 47 } | 53 } |
| 48 | 54 |
| 49 } // namespace | 55 } // namespace |
| 50 | 56 |
| 51 void ResourceBundle::LoadCommonResources() { | 57 void ResourceBundle::LoadCommonResources() { |
| 52 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", | 58 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", |
| 53 nil), SCALE_FACTOR_100P); | 59 nil), SCALE_FACTOR_100P); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 150 |
| 145 // Another thread raced the load and has already cached the image. | 151 // Another thread raced the load and has already cached the image. |
| 146 if (images_.count(resource_id)) | 152 if (images_.count(resource_id)) |
| 147 return images_[resource_id]; | 153 return images_[resource_id]; |
| 148 | 154 |
| 149 images_[resource_id] = image; | 155 images_[resource_id] = image; |
| 150 return images_[resource_id]; | 156 return images_[resource_id]; |
| 151 } | 157 } |
| 152 | 158 |
| 153 } // namespace ui | 159 } // namespace ui |
| OLD | NEW |