OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #import <objc/objc-runtime.h> | 9 #import <objc/objc-runtime.h> |
10 | 10 |
11 #include "app/data_pack.h" | 11 #include "app/data_pack.h" |
12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/mac_util.h" | 15 #include "base/mac/mac_util.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "grit/webkit_resources.h" | 18 #include "grit/webkit_resources.h" |
19 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" | 19 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" |
20 #include "webkit/plugins/npapi/plugin_list.h" | 20 #include "webkit/plugins/npapi/plugin_list.h" |
21 #import "webkit/support/drt_application_mac.h" | 21 #import "webkit/support/drt_application_mac.h" |
22 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" | 22 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" |
23 | 23 |
24 static app::DataPack* g_resource_data_pack = NULL; | 24 static app::DataPack* g_resource_data_pack = NULL; |
25 | 25 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 #endif | 97 #endif |
98 } | 98 } |
99 | 99 |
100 void AfterInitialize(bool unit_test_mode) { | 100 void AfterInitialize(bool unit_test_mode) { |
101 if (unit_test_mode) | 101 if (unit_test_mode) |
102 return; // We don't have a resource pack when running the unit-tests. | 102 return; // We don't have a resource pack when running the unit-tests. |
103 | 103 |
104 // Load a data pack. | 104 // Load a data pack. |
105 g_resource_data_pack = new app::DataPack; | 105 g_resource_data_pack = new app::DataPack; |
106 NSString* resource_path = | 106 NSString* resource_path = |
107 [mac_util::MainAppBundle() pathForResource:@"DumpRenderTree" | 107 [base::mac::MainAppBundle() pathForResource:@"DumpRenderTree" |
108 ofType:@"pak"]; | 108 ofType:@"pak"]; |
109 FilePath resources_pak_path([resource_path fileSystemRepresentation]); | 109 FilePath resources_pak_path([resource_path fileSystemRepresentation]); |
110 if (!g_resource_data_pack->Load(resources_pak_path)) { | 110 if (!g_resource_data_pack->Load(resources_pak_path)) { |
111 LOG(FATAL) << "failed to load DumpRenderTree.pak"; | 111 LOG(FATAL) << "failed to load DumpRenderTree.pak"; |
112 } | 112 } |
113 | 113 |
114 // Load font files in the resource folder. | 114 // Load font files in the resource folder. |
115 static const char* const fontFileNames[] = { | 115 static const char* const fontFileNames[] = { |
116 "AHEM____.TTF", | 116 "AHEM____.TTF", |
117 "WebKitWeightWatcher100.ttf", | 117 "WebKitWeightWatcher100.ttf", |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 LOG(FATAL) << "failed to load webkit string with id " << message_id; | 170 LOG(FATAL) << "failed to load webkit string with id " << message_id; |
171 } | 171 } |
172 return string16(reinterpret_cast<const char16*>(res.data()), | 172 return string16(reinterpret_cast<const char16*>(res.data()), |
173 res.length() / 2); | 173 res.length() / 2); |
174 } | 174 } |
175 | 175 |
176 // Helper method for getting the path to the test shell resources directory. | 176 // Helper method for getting the path to the test shell resources directory. |
177 static FilePath GetResourcesFilePath() { | 177 static FilePath GetResourcesFilePath() { |
178 FilePath path; | 178 FilePath path; |
179 // We assume the application is bundled. | 179 // We assume the application is bundled. |
180 if (!mac_util::AmIBundled()) { | 180 if (!base::mac::AmIBundled()) { |
181 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; | 181 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; |
182 } | 182 } |
183 PathService::Get(base::DIR_EXE, &path); | 183 PathService::Get(base::DIR_EXE, &path); |
184 path = path.Append(FilePath::kParentDirectory); | 184 path = path.Append(FilePath::kParentDirectory); |
185 return path.AppendASCII("Resources"); | 185 return path.AppendASCII("Resources"); |
186 } | 186 } |
187 | 187 |
188 base::StringPiece GetDataResource(int resource_id) { | 188 base::StringPiece GetDataResource(int resource_id) { |
189 switch (resource_id) { | 189 switch (resource_id) { |
190 case IDR_BROKENIMAGE: { | 190 case IDR_BROKENIMAGE: { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return res; | 234 return res; |
235 } | 235 } |
236 | 236 |
237 default: | 237 default: |
238 break; | 238 break; |
239 } | 239 } |
240 return base::StringPiece(); | 240 return base::StringPiece(); |
241 } | 241 } |
242 | 242 |
243 } // namespace webkit_glue | 243 } // namespace webkit_glue |
OLD | NEW |