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 "webkit/support/platform_support.h" | 5 #include "webkit/support/platform_support.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #include <AvailabilityMacros.h> | 8 #include <AvailabilityMacros.h> |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 #import <objc/objc-runtime.h> | 10 #import <objc/objc-runtime.h> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 SwizzleAllMethods(object_getClass(imposterClass), | 96 SwizzleAllMethods(object_getClass(imposterClass), |
97 object_getClass(originalClass)); | 97 object_getClass(originalClass)); |
98 #endif | 98 #endif |
99 } | 99 } |
100 | 100 |
101 void AfterInitialize(bool unit_test_mode) { | 101 void AfterInitialize(bool unit_test_mode) { |
102 if (unit_test_mode) | 102 if (unit_test_mode) |
103 return; // We don't have a resource pack when running the unit-tests. | 103 return; // We don't have a resource pack when running the unit-tests. |
104 | 104 |
105 // Load a data pack. | 105 // Load a data pack. |
106 g_resource_data_pack = new ui::DataPack(ui::ResourceHandle::kScaleFactor100x); | 106 g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); |
107 NSString* resource_path = | 107 NSString* resource_path = |
108 [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" | 108 [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" |
109 ofType:@"pak"]; | 109 ofType:@"pak"]; |
110 FilePath resources_pak_path([resource_path fileSystemRepresentation]); | 110 FilePath resources_pak_path([resource_path fileSystemRepresentation]); |
111 if (!g_resource_data_pack->Load(resources_pak_path)) { | 111 if (!g_resource_data_pack->Load(resources_pak_path)) { |
112 LOG(FATAL) << "failed to load DumpRenderTree.pak"; | 112 LOG(FATAL) << "failed to load DumpRenderTree.pak"; |
113 } | 113 } |
114 | 114 |
115 // Load font files in the resource folder. | 115 // Load font files in the resource folder. |
116 static const char* const fontFileNames[] = { | 116 static const char* const fontFileNames[] = { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 FilePath path; | 209 FilePath path; |
210 // We assume the application is bundled. | 210 // We assume the application is bundled. |
211 if (!base::mac::AmIBundled()) { | 211 if (!base::mac::AmIBundled()) { |
212 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; | 212 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; |
213 } | 213 } |
214 PathService::Get(base::DIR_EXE, &path); | 214 PathService::Get(base::DIR_EXE, &path); |
215 path = path.Append(FilePath::kParentDirectory); | 215 path = path.Append(FilePath::kParentDirectory); |
216 return path.AppendASCII("Resources"); | 216 return path.AppendASCII("Resources"); |
217 } | 217 } |
218 | 218 |
219 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { | 219 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
220 base::StringPiece res; | |
221 if (g_resource_data_pack) | |
222 g_resource_data_pack->GetStringPiece(resource_id, &res); | |
223 return res; | |
224 } | |
225 | |
226 base::StringPiece TestWebKitPlatformSupport::GetImageResource( | |
227 int resource_id, | 220 int resource_id, |
228 float scale_factor) { | 221 ui::ScaleFactor scale_factor) { |
229 switch (resource_id) { | 222 switch (resource_id) { |
230 case IDR_BROKENIMAGE: { | 223 case IDR_BROKENIMAGE: { |
231 // Use webkit's broken image icon (16x16) | 224 // Use webkit's broken image icon (16x16) |
232 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); | 225 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); |
233 if (broken_image_data.empty()) { | 226 if (broken_image_data.empty()) { |
234 FilePath path = GetResourcesFilePath(); | 227 FilePath path = GetResourcesFilePath(); |
235 // In order to match WebKit's colors for the missing image, we have to | 228 // In order to match WebKit's colors for the missing image, we have to |
236 // use a PNG. The GIF doesn't have the color range needed to correctly | 229 // use a PNG. The GIF doesn't have the color range needed to correctly |
237 // match the TIFF they use in Safari. | 230 // match the TIFF they use in Safari. |
238 path = path.AppendASCII("missingImage.png"); | 231 path = path.AppendASCII("missingImage.png"); |
(...skipping 16 matching lines...) Expand all Loading... |
255 } | 248 } |
256 } | 249 } |
257 return resize_corner_data; | 250 return resize_corner_data; |
258 } | 251 } |
259 } | 252 } |
260 base::StringPiece res; | 253 base::StringPiece res; |
261 if (g_resource_data_pack) | 254 if (g_resource_data_pack) |
262 g_resource_data_pack->GetStringPiece(resource_id, &res); | 255 g_resource_data_pack->GetStringPiece(resource_id, &res); |
263 return res; | 256 return res; |
264 } | 257 } |
OLD | NEW |