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/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 #include "webkit/support/test_webkit_platform_support.h" |
18 | 18 |
19 #define MAX_LOADSTRING 100 | 19 #define MAX_LOADSTRING 100 |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 FilePath GetResourceFilePath(const char* ascii_name) { | 23 base::FilePath GetResourceFilePath(const char* ascii_name) { |
24 FilePath path; | 24 base::FilePath path; |
25 PathService::Get(base::DIR_EXE, &path); | 25 PathService::Get(base::DIR_EXE, &path); |
26 path = path.AppendASCII("DumpRenderTree_resources"); | 26 path = path.AppendASCII("DumpRenderTree_resources"); |
27 return path.AppendASCII(ascii_name); | 27 return path.AppendASCII(ascii_name); |
28 } | 28 } |
29 | 29 |
30 base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { | 30 base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { |
31 void* data_ptr; | 31 void* data_ptr; |
32 size_t data_size; | 32 size_t data_size; |
33 return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr, | 33 return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr, |
34 &data_size) | 34 &data_size) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 base::StringPiece TestWebKitPlatformSupport::GetDataResource( | 75 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
76 int resource_id, | 76 int resource_id, |
77 ui::ScaleFactor scale_factor) { | 77 ui::ScaleFactor scale_factor) { |
78 switch (resource_id) { | 78 switch (resource_id) { |
79 case IDR_BROKENIMAGE: { | 79 case IDR_BROKENIMAGE: { |
80 // Use webkit's broken image icon (16x16) | 80 // Use webkit's broken image icon (16x16) |
81 static std::string broken_image_data; | 81 static std::string broken_image_data; |
82 if (broken_image_data.empty()) { | 82 if (broken_image_data.empty()) { |
83 FilePath path = GetResourceFilePath("missingImage.gif"); | 83 base::FilePath path = GetResourceFilePath("missingImage.gif"); |
84 bool success = file_util::ReadFileToString(path, &broken_image_data); | 84 bool success = file_util::ReadFileToString(path, &broken_image_data); |
85 if (!success) { | 85 if (!success) { |
86 LOG(FATAL) << "Failed reading: " << path.value(); | 86 LOG(FATAL) << "Failed reading: " << path.value(); |
87 } | 87 } |
88 } | 88 } |
89 return broken_image_data; | 89 return broken_image_data; |
90 } | 90 } |
91 case IDR_TEXTAREA_RESIZER: { | 91 case IDR_TEXTAREA_RESIZER: { |
92 // Use webkit's text area resizer image. | 92 // Use webkit's text area resizer image. |
93 static std::string resize_corner_data; | 93 static std::string resize_corner_data; |
94 if (resize_corner_data.empty()) { | 94 if (resize_corner_data.empty()) { |
95 FilePath path = GetResourceFilePath("textAreaResizeCorner.png"); | 95 base::FilePath path = GetResourceFilePath("textAreaResizeCorner.png"); |
96 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 96 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
97 if (!success) { | 97 if (!success) { |
98 LOG(FATAL) << "Failed reading: " << path.value(); | 98 LOG(FATAL) << "Failed reading: " << path.value(); |
99 } | 99 } |
100 } | 100 } |
101 return resize_corner_data; | 101 return resize_corner_data; |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 // TODO(flackr): Pass scale_factor to ResourceProvider. | 105 // TODO(flackr): Pass scale_factor to ResourceProvider. |
106 return ResourceProvider(resource_id); | 106 return ResourceProvider(resource_id); |
107 } | 107 } |
OLD | NEW |