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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 SwizzleAllMethods(imposterClass, originalClass); | 94 SwizzleAllMethods(imposterClass, originalClass); |
95 // and then class methods. | 95 // and then class methods. |
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 // Load a data pack. | 102 // Load a data pack. |
103 g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); | 103 g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); |
104 FilePath resources_pak_path; | 104 base::FilePath resources_pak_path; |
105 if (unit_test_mode) { | 105 if (unit_test_mode) { |
106 PathService::Get(base::DIR_EXE, &resources_pak_path); | 106 PathService::Get(base::DIR_EXE, &resources_pak_path); |
107 resources_pak_path = resources_pak_path.Append("DumpRenderTree.app") | 107 resources_pak_path = resources_pak_path.Append("DumpRenderTree.app") |
108 .Append("Contents") | 108 .Append("Contents") |
109 .Append("Resources") | 109 .Append("Resources") |
110 .Append("DumpRenderTree.pak"); | 110 .Append("DumpRenderTree.pak"); |
111 } else { | 111 } else { |
112 NSString* resource_path = | 112 NSString* resource_path = |
113 [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" | 113 [base::mac::FrameworkBundle() pathForResource:@"DumpRenderTree" |
114 ofType:@"pak"]; | 114 ofType:@"pak"]; |
115 resources_pak_path = FilePath([resource_path fileSystemRepresentation]); | 115 resources_pak_path = base::FilePath([resource_path fileSystemRepresentation]
); |
116 } | 116 } |
117 if (!g_resource_data_pack->LoadFromPath(resources_pak_path)) { | 117 if (!g_resource_data_pack->LoadFromPath(resources_pak_path)) { |
118 LOG(FATAL) << "failed to load DumpRenderTree.pak"; | 118 LOG(FATAL) << "failed to load DumpRenderTree.pak"; |
119 } | 119 } |
120 | 120 |
121 if (unit_test_mode) | 121 if (unit_test_mode) |
122 return; | 122 return; |
123 | 123 |
124 // Load font files in the resource folder. | 124 // Load font files in the resource folder. |
125 static const char* const fontFileNames[] = { | 125 static const char* const fontFileNames[] = { |
(...skipping 23 matching lines...) Expand all Loading... |
149 kCTFontManagerScopeProcess, | 149 kCTFontManagerScopeProcess, |
150 &errors)) { | 150 &errors)) { |
151 DLOG(FATAL) << "Fail to activate fonts."; | 151 DLOG(FATAL) << "Fail to activate fonts."; |
152 CFRelease(errors); | 152 CFRelease(errors); |
153 } | 153 } |
154 | 154 |
155 SwizzleNSPasteboard(); | 155 SwizzleNSPasteboard(); |
156 | 156 |
157 // Add <app bundle's parent dir>/plugins to the plugin path so we can load | 157 // Add <app bundle's parent dir>/plugins to the plugin path so we can load |
158 // test plugins. | 158 // test plugins. |
159 FilePath plugins_dir; | 159 base::FilePath plugins_dir; |
160 PathService::Get(base::DIR_EXE, &plugins_dir); | 160 PathService::Get(base::DIR_EXE, &plugins_dir); |
161 plugins_dir = plugins_dir.AppendASCII("../../../plugins"); | 161 plugins_dir = plugins_dir.AppendASCII("../../../plugins"); |
162 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(plugins_dir); | 162 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(plugins_dir); |
163 } | 163 } |
164 | 164 |
165 void BeforeShutdown() { | 165 void BeforeShutdown() { |
166 } | 166 } |
167 | 167 |
168 void AfterShutdown() { | 168 void AfterShutdown() { |
169 [DumpRenderTreePasteboard releaseLocalPasteboards]; | 169 [DumpRenderTreePasteboard releaseLocalPasteboards]; |
(...skipping 25 matching lines...) Expand all Loading... |
195 break; | 195 break; |
196 case ui::DataPack::BINARY: | 196 case ui::DataPack::BINARY: |
197 NOTREACHED(); | 197 NOTREACHED(); |
198 break; | 198 break; |
199 } | 199 } |
200 | 200 |
201 return msg; | 201 return msg; |
202 } | 202 } |
203 | 203 |
204 // Helper method for getting the path to the test shell resources directory. | 204 // Helper method for getting the path to the test shell resources directory. |
205 static FilePath GetResourcesFilePath() { | 205 static base::FilePath GetResourcesFilePath() { |
206 FilePath path; | 206 base::FilePath path; |
207 // We assume the application is bundled. | 207 // We assume the application is bundled. |
208 if (!base::mac::AmIBundled()) { | 208 if (!base::mac::AmIBundled()) { |
209 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; | 209 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; |
210 } | 210 } |
211 PathService::Get(base::DIR_EXE, &path); | 211 PathService::Get(base::DIR_EXE, &path); |
212 path = path.Append(FilePath::kParentDirectory); | 212 path = path.Append(base::FilePath::kParentDirectory); |
213 return path.AppendASCII("Resources"); | 213 return path.AppendASCII("Resources"); |
214 } | 214 } |
215 | 215 |
216 base::StringPiece TestWebKitPlatformSupport::GetDataResource( | 216 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
217 int resource_id, | 217 int resource_id, |
218 ui::ScaleFactor scale_factor) { | 218 ui::ScaleFactor scale_factor) { |
219 switch (resource_id) { | 219 switch (resource_id) { |
220 case IDR_BROKENIMAGE: { | 220 case IDR_BROKENIMAGE: { |
221 // Use webkit's broken image icon (16x16) | 221 // Use webkit's broken image icon (16x16) |
222 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); | 222 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); |
223 if (broken_image_data.empty()) { | 223 if (broken_image_data.empty()) { |
224 FilePath path = GetResourcesFilePath(); | 224 base::FilePath path = GetResourcesFilePath(); |
225 // In order to match WebKit's colors for the missing image, we have to | 225 // In order to match WebKit's colors for the missing image, we have to |
226 // use a PNG. The GIF doesn't have the color range needed to correctly | 226 // use a PNG. The GIF doesn't have the color range needed to correctly |
227 // match the TIFF they use in Safari. | 227 // match the TIFF they use in Safari. |
228 path = path.AppendASCII("missingImage.png"); | 228 path = path.AppendASCII("missingImage.png"); |
229 file_util::AbsolutePath(&path); | 229 file_util::AbsolutePath(&path); |
230 bool success = file_util::ReadFileToString(path, &broken_image_data); | 230 bool success = file_util::ReadFileToString(path, &broken_image_data); |
231 if (!success) { | 231 if (!success) { |
232 LOG(FATAL) << "Failed reading: " << path.value(); | 232 LOG(FATAL) << "Failed reading: " << path.value(); |
233 } | 233 } |
234 } | 234 } |
235 return broken_image_data; | 235 return broken_image_data; |
236 } | 236 } |
237 case IDR_TEXTAREA_RESIZER: { | 237 case IDR_TEXTAREA_RESIZER: { |
238 // Use webkit's text area resizer image. | 238 // Use webkit's text area resizer image. |
239 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); | 239 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); |
240 if (resize_corner_data.empty()) { | 240 if (resize_corner_data.empty()) { |
241 FilePath path = GetResourcesFilePath(); | 241 base::FilePath path = GetResourcesFilePath(); |
242 path = path.AppendASCII("textAreaResizeCorner.png"); | 242 path = path.AppendASCII("textAreaResizeCorner.png"); |
243 file_util::AbsolutePath(&path); | 243 file_util::AbsolutePath(&path); |
244 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 244 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
245 if (!success) { | 245 if (!success) { |
246 LOG(FATAL) << "Failed reading: " << path.value(); | 246 LOG(FATAL) << "Failed reading: " << path.value(); |
247 } | 247 } |
248 } | 248 } |
249 return resize_corner_data; | 249 return resize_corner_data; |
250 } | 250 } |
251 } | 251 } |
252 base::StringPiece res; | 252 base::StringPiece res; |
253 if (g_resource_data_pack) | 253 if (g_resource_data_pack) |
254 g_resource_data_pack->GetStringPiece(resource_id, &res); | 254 g_resource_data_pack->GetStringPiece(resource_id, &res); |
255 return res; | 255 return res; |
256 } | 256 } |
OLD | NEW |