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 #include "app/data_pack.h" | 7 #include "app/data_pack.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
| 14 #include "gfx/gfx_module.h" |
14 #include "grit/webkit_resources.h" | 15 #include "grit/webkit_resources.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // Data resources on linux. This is a pointer to the mmapped resources file. | 19 // Data resources on linux. This is a pointer to the mmapped resources file. |
19 app::DataPack* g_resource_data_pack = NULL; | 20 app::DataPack* g_resource_data_pack = NULL; |
20 | 21 |
| 22 base::StringPiece TestResourceProvider(int resource_id) { |
| 23 base::StringPiece res; |
| 24 if (g_resource_data_pack) |
| 25 g_resource_data_pack->GetStringPiece(resource_id, &res); |
| 26 return res; |
| 27 } |
| 28 |
21 } | 29 } |
22 | 30 |
23 namespace webkit_support { | 31 namespace webkit_support { |
24 | 32 |
25 // TODO(tkent): Implement some of the followings for platform-dependent tasks | 33 // TODO(tkent): Implement some of the followings for platform-dependent tasks |
26 // such as loading resource. | 34 // such as loading resource. |
27 | 35 |
28 void BeforeInitialize(bool unit_test_mode) { | 36 void BeforeInitialize(bool unit_test_mode) { |
29 } | 37 } |
30 | 38 |
31 void AfterInitialize(bool unit_test_mode) { | 39 void AfterInitialize(bool unit_test_mode) { |
32 if (unit_test_mode) | 40 if (unit_test_mode) |
33 return; // We don't have a resource pack when running the unit-tests. | 41 return; // We don't have a resource pack when running the unit-tests. |
34 g_resource_data_pack = new app::DataPack; | 42 g_resource_data_pack = new app::DataPack; |
35 FilePath data_path; | 43 FilePath data_path; |
36 PathService::Get(base::DIR_EXE, &data_path); | 44 PathService::Get(base::DIR_EXE, &data_path); |
37 data_path = data_path.Append("DumpRenderTree.pak"); | 45 data_path = data_path.Append("DumpRenderTree.pak"); |
38 if (!g_resource_data_pack->Load(data_path)) | 46 if (!g_resource_data_pack->Load(data_path)) |
39 LOG(FATAL) << "failed to load DumpRenderTree.pak"; | 47 LOG(FATAL) << "failed to load DumpRenderTree.pak"; |
| 48 |
| 49 // Config the modules that need access to a limited set of resources. |
| 50 gfx::GfxModule::SetResourceProvider(TestResourceProvider); |
40 } | 51 } |
41 | 52 |
42 void BeforeShutdown() { | 53 void BeforeShutdown() { |
43 } | 54 } |
44 | 55 |
45 void AfterShutdown() { | 56 void AfterShutdown() { |
46 } | 57 } |
47 | 58 |
48 } // namespace webkit_support | 59 } // namespace webkit_support |
49 | 60 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 94 } |
84 return resize_corner_data; | 95 return resize_corner_data; |
85 } | 96 } |
86 } | 97 } |
87 base::StringPiece res; | 98 base::StringPiece res; |
88 g_resource_data_pack->GetStringPiece(resource_id, &res); | 99 g_resource_data_pack->GetStringPiece(resource_id, &res); |
89 return res; | 100 return res; |
90 } | 101 } |
91 | 102 |
92 } // namespace webkit_glue | 103 } // namespace webkit_glue |
OLD | NEW |