OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "grit/webkit_resources.h" | 14 #include "grit/webkit_resources.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "webkit/support/test_webkit_platform_support.h" |
16 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 17 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
17 | 18 |
18 namespace webkit_support { | 19 namespace webkit_support { |
19 | 20 |
20 void BeforeInitialize(bool unit_test_mode) { | 21 void BeforeInitialize(bool unit_test_mode) { |
21 NOTIMPLEMENTED(); // TODO(zhenghao): Implement this function. | 22 NOTIMPLEMENTED(); // TODO(zhenghao): Implement this function. |
22 } | 23 } |
23 | 24 |
24 void AfterInitialize(bool unit_test_mode) { | 25 void AfterInitialize(bool unit_test_mode) { |
25 if (unit_test_mode) | 26 if (unit_test_mode) |
(...skipping 20 matching lines...) Expand all Loading... |
46 void BeforeShutdown() { | 47 void BeforeShutdown() { |
47 ResourceBundle::CleanupSharedInstance(); | 48 ResourceBundle::CleanupSharedInstance(); |
48 } | 49 } |
49 | 50 |
50 void AfterShutdown() { | 51 void AfterShutdown() { |
51 NOTIMPLEMENTED(); // TODO(zhenghao): Implement this function. | 52 NOTIMPLEMENTED(); // TODO(zhenghao): Implement this function. |
52 } | 53 } |
53 | 54 |
54 } // namespace webkit_support | 55 } // namespace webkit_support |
55 | 56 |
56 namespace webkit_glue { | 57 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
57 | |
58 string16 GetLocalizedString(int message_id) { | |
59 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); | 58 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); |
60 } | 59 } |
61 | 60 |
62 base::StringPiece GetDataResource(int resource_id) { | 61 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { |
63 FilePath resources_path; | 62 FilePath resources_path; |
64 PathService::Get(base::DIR_EXE, &resources_path); | 63 PathService::Get(base::DIR_EXE, &resources_path); |
65 resources_path = resources_path.Append("DumpRenderTree_resources"); | 64 resources_path = resources_path.Append("DumpRenderTree_resources"); |
66 switch (resource_id) { | 65 switch (resource_id) { |
67 case IDR_BROKENIMAGE: { | 66 case IDR_BROKENIMAGE: { |
68 static std::string broken_image_data; | 67 static std::string broken_image_data; |
69 if (broken_image_data.empty()) { | 68 if (broken_image_data.empty()) { |
70 FilePath path = resources_path.Append("missingImage.gif"); | 69 FilePath path = resources_path.Append("missingImage.gif"); |
71 bool success = file_util::ReadFileToString(path, &broken_image_data); | 70 bool success = file_util::ReadFileToString(path, &broken_image_data); |
72 if (!success) | 71 if (!success) |
73 LOG(FATAL) << "Failed reading: " << path.value(); | 72 LOG(FATAL) << "Failed reading: " << path.value(); |
74 } | 73 } |
75 return broken_image_data; | 74 return broken_image_data; |
76 } | 75 } |
77 case IDR_TEXTAREA_RESIZER: { | 76 case IDR_TEXTAREA_RESIZER: { |
78 static std::string resize_corner_data; | 77 static std::string resize_corner_data; |
79 if (resize_corner_data.empty()) { | 78 if (resize_corner_data.empty()) { |
80 FilePath path = resources_path.Append("textAreaResizeCorner.png"); | 79 FilePath path = resources_path.Append("textAreaResizeCorner.png"); |
81 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 80 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
82 if (!success) | 81 if (!success) |
83 LOG(FATAL) << "Failed reading: " << path.value(); | 82 LOG(FATAL) << "Failed reading: " << path.value(); |
84 } | 83 } |
85 return resize_corner_data; | 84 return resize_corner_data; |
86 } | 85 } |
87 } | 86 } |
88 | 87 |
89 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 88 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); |
90 } | 89 } |
91 | |
92 } // namespace webkit_glue | |
OLD | NEW |