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 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
13 #include "grit/webkit_resources.h" | 13 #include "grit/webkit_resources.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "webkit/support/test_webkit_platform_support.h" | 15 #include "webkit/support/test_webkit_platform_support.h" |
16 | 16 |
17 namespace webkit_support { | 17 namespace webkit_support { |
18 | 18 |
19 // TODO(tkent): Implement some of the followings for platform-dependent tasks | 19 // TODO(tkent): Implement some of the followings for platform-dependent tasks |
20 // such as loading resource. | 20 // such as loading resource. |
21 | 21 |
22 void BeforeInitialize(bool unit_test_mode) { | 22 void BeforeInitialize(bool unit_test_mode) { |
23 } | 23 } |
24 | 24 |
25 void AfterInitialize(bool unit_test_mode) { | 25 void AfterInitialize(bool unit_test_mode) { |
26 FilePath data_path; | 26 base::FilePath data_path; |
27 PathService::Get(base::DIR_EXE, &data_path); | 27 PathService::Get(base::DIR_EXE, &data_path); |
28 data_path = data_path.Append("DumpRenderTree.pak"); | 28 data_path = data_path.Append("DumpRenderTree.pak"); |
29 ResourceBundle::InitSharedInstanceWithPakPath(data_path); | 29 ResourceBundle::InitSharedInstanceWithPakPath(data_path); |
30 } | 30 } |
31 | 31 |
32 void BeforeShutdown() { | 32 void BeforeShutdown() { |
33 ResourceBundle::CleanupSharedInstance(); | 33 ResourceBundle::CleanupSharedInstance(); |
34 } | 34 } |
35 | 35 |
36 void AfterShutdown() { | 36 void AfterShutdown() { |
37 } | 37 } |
38 | 38 |
39 } // namespace webkit_support | 39 } // namespace webkit_support |
40 | 40 |
41 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | 41 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
42 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); | 42 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); |
43 } | 43 } |
44 | 44 |
45 base::StringPiece TestWebKitPlatformSupport::GetDataResource( | 45 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
46 int resource_id, | 46 int resource_id, |
47 ui::ScaleFactor scale_factor) { | 47 ui::ScaleFactor scale_factor) { |
48 FilePath resources_path; | 48 base::FilePath resources_path; |
49 PathService::Get(base::DIR_EXE, &resources_path); | 49 PathService::Get(base::DIR_EXE, &resources_path); |
50 resources_path = resources_path.Append("DumpRenderTree_resources"); | 50 resources_path = resources_path.Append("DumpRenderTree_resources"); |
51 switch (resource_id) { | 51 switch (resource_id) { |
52 case IDR_BROKENIMAGE: { | 52 case IDR_BROKENIMAGE: { |
53 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); | 53 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); |
54 if (broken_image_data.empty()) { | 54 if (broken_image_data.empty()) { |
55 FilePath path = resources_path.Append("missingImage.gif"); | 55 base::FilePath path = resources_path.Append("missingImage.gif"); |
56 bool success = file_util::ReadFileToString(path, &broken_image_data); | 56 bool success = file_util::ReadFileToString(path, &broken_image_data); |
57 if (!success) | 57 if (!success) |
58 LOG(FATAL) << "Failed reading: " << path.value(); | 58 LOG(FATAL) << "Failed reading: " << path.value(); |
59 } | 59 } |
60 return broken_image_data; | 60 return broken_image_data; |
61 } | 61 } |
62 case IDR_TEXTAREA_RESIZER: { | 62 case IDR_TEXTAREA_RESIZER: { |
63 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); | 63 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); |
64 if (resize_corner_data.empty()) { | 64 if (resize_corner_data.empty()) { |
65 FilePath path = resources_path.Append("textAreaResizeCorner.png"); | 65 base::FilePath path = resources_path.Append("textAreaResizeCorner.png"); |
66 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 66 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
67 if (!success) | 67 if (!success) |
68 LOG(FATAL) << "Failed reading: " << path.value(); | 68 LOG(FATAL) << "Failed reading: " << path.value(); |
69 } | 69 } |
70 return resize_corner_data; | 70 return resize_corner_data; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | 74 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( |
75 resource_id, scale_factor); | 75 resource_id, scale_factor); |
76 } | 76 } |
OLD | NEW |