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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 if (!resource_path) { | 37 if (!resource_path) { |
38 // Return just the name of the pak file. | 38 // Return just the name of the pak file. |
39 return base::FilePath(base::SysNSStringToUTF8(name) + ".pak"); | 39 return base::FilePath(base::SysNSStringToUTF8(name) + ".pak"); |
40 } | 40 } |
41 return base::FilePath([resource_path fileSystemRepresentation]); | 41 return base::FilePath([resource_path fileSystemRepresentation]); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 void ResourceBundle::LoadCommonResources() { | |
47 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome", nil), | |
48 ui::SCALE_FACTOR_NONE); | |
49 | |
50 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { | |
51 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_100_percent", nil), | |
52 SCALE_FACTOR_100P); | |
53 } | |
54 | |
55 if (IsScaleFactorSupported(SCALE_FACTOR_200P)) { | |
56 AddDataPackFromPath(GetResourcesPakFilePath(@"chrome_200_percent", nil), | |
57 SCALE_FACTOR_200P); | |
58 } | |
59 } | |
60 | |
61 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, | 46 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, |
62 bool test_file_exists) { | 47 bool test_file_exists) { |
63 NSString* mac_locale = base::SysUTF8ToNSString(app_locale); | 48 NSString* mac_locale = base::SysUTF8ToNSString(app_locale); |
64 | 49 |
65 // iOS uses "_" instead of "-", so swap to get a iOS-style value. | 50 // iOS uses "_" instead of "-", so swap to get a iOS-style value. |
66 mac_locale = [mac_locale stringByReplacingOccurrencesOfString:@"-" | 51 mac_locale = [mac_locale stringByReplacingOccurrencesOfString:@"-" |
67 withString:@"_"]; | 52 withString:@"_"]; |
68 | 53 |
69 // On disk, the "en_US" resources are just "en" (http://crbug.com/25578). | 54 // On disk, the "en_US" resources are just "en" (http://crbug.com/25578). |
70 if ([mac_locale isEqual:@"en_US"]) | 55 if ([mac_locale isEqual:@"en_US"]) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 157 |
173 // Another thread raced the load and has already cached the image. | 158 // Another thread raced the load and has already cached the image. |
174 if (images_.count(resource_id)) | 159 if (images_.count(resource_id)) |
175 return images_[resource_id]; | 160 return images_[resource_id]; |
176 | 161 |
177 images_[resource_id] = image; | 162 images_[resource_id] = image; |
178 return images_[resource_id]; | 163 return images_[resource_id]; |
179 } | 164 } |
180 | 165 |
181 } // namespace ui | 166 } // namespace ui |
OLD | NEW |