OLD | NEW |
1 // Copyright (c) 2010 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/base_paths.h" | 7 #include "base/base_paths.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 "base/win/resource_util.h" | 14 #include "base/win/resource_util.h" |
15 #include "grit/webkit_chromium_resources.h" | 15 #include "grit/webkit_chromium_resources.h" |
16 #include "grit/webkit_resources.h" | 16 #include "grit/webkit_resources.h" |
| 17 #include "webkit/support/test_webkit_platform_support.h" |
17 | 18 |
18 #define MAX_LOADSTRING 100 | 19 #define MAX_LOADSTRING 100 |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 FilePath GetResourceFilePath(const char* ascii_name) { | 23 FilePath GetResourceFilePath(const char* ascii_name) { |
23 FilePath path; | 24 FilePath path; |
24 PathService::Get(base::DIR_EXE, &path); | 25 PathService::Get(base::DIR_EXE, &path); |
25 path = path.AppendASCII("DumpRenderTree_resources"); | 26 path = path.AppendASCII("DumpRenderTree_resources"); |
26 return path.AppendASCII(ascii_name); | 27 return path.AppendASCII(ascii_name); |
(...skipping 26 matching lines...) Expand all Loading... |
53 } | 54 } |
54 | 55 |
55 void BeforeShutdown() { | 56 void BeforeShutdown() { |
56 } | 57 } |
57 | 58 |
58 void AfterShutdown() { | 59 void AfterShutdown() { |
59 } | 60 } |
60 | 61 |
61 } // namespace webkit_support | 62 } // namespace webkit_support |
62 | 63 |
63 namespace webkit_glue { | 64 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
64 | |
65 string16 GetLocalizedString(int message_id) { | |
66 wchar_t localized[MAX_LOADSTRING]; | 65 wchar_t localized[MAX_LOADSTRING]; |
67 int length = ::LoadString(::GetModuleHandle(NULL), message_id, | 66 int length = ::LoadString(::GetModuleHandle(NULL), message_id, |
68 localized, MAX_LOADSTRING); | 67 localized, MAX_LOADSTRING); |
69 if (!length && ::GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND) { | 68 if (!length && ::GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND) { |
70 NOTREACHED(); | 69 NOTREACHED(); |
71 return L"No string for this identifier!"; | 70 return L"No string for this identifier!"; |
72 } | 71 } |
73 return string16(localized, length); | 72 return string16(localized, length); |
74 } | 73 } |
75 | 74 |
76 base::StringPiece GetDataResource(int resource_id) { | 75 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { |
77 switch (resource_id) { | 76 switch (resource_id) { |
78 case IDR_BROKENIMAGE: { | 77 case IDR_BROKENIMAGE: { |
79 // Use webkit's broken image icon (16x16) | 78 // Use webkit's broken image icon (16x16) |
80 static std::string broken_image_data; | 79 static std::string broken_image_data; |
81 if (broken_image_data.empty()) { | 80 if (broken_image_data.empty()) { |
82 FilePath path = GetResourceFilePath("missingImage.gif"); | 81 FilePath path = GetResourceFilePath("missingImage.gif"); |
83 bool success = file_util::ReadFileToString(path, &broken_image_data); | 82 bool success = file_util::ReadFileToString(path, &broken_image_data); |
84 if (!success) { | 83 if (!success) { |
85 LOG(FATAL) << "Failed reading: " << path.value(); | 84 LOG(FATAL) << "Failed reading: " << path.value(); |
86 } | 85 } |
87 } | 86 } |
88 return broken_image_data; | 87 return broken_image_data; |
89 } | 88 } |
90 case IDR_TEXTAREA_RESIZER: { | 89 case IDR_TEXTAREA_RESIZER: { |
91 // Use webkit's text area resizer image. | 90 // Use webkit's text area resizer image. |
92 static std::string resize_corner_data; | 91 static std::string resize_corner_data; |
93 if (resize_corner_data.empty()) { | 92 if (resize_corner_data.empty()) { |
94 FilePath path = GetResourceFilePath("textAreaResizeCorner.png"); | 93 FilePath path = GetResourceFilePath("textAreaResizeCorner.png"); |
95 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 94 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
96 if (!success) { | 95 if (!success) { |
97 LOG(FATAL) << "Failed reading: " << path.value(); | 96 LOG(FATAL) << "Failed reading: " << path.value(); |
98 } | 97 } |
99 } | 98 } |
100 return resize_corner_data; | 99 return resize_corner_data; |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 return ResourceProvider(resource_id); | 103 return ResourceProvider(resource_id); |
105 } | 104 } |
106 | |
107 } // namespace webkit_glue | |
OLD | NEW |