Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: webkit/support/platform_support_win.cc

Issue 17029016: Remove DRT-specific resource loading logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/support/platform_support_mac.mm ('k') | webkit/support/test_webkit_platform_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/support/platform_support.h"
6
7 #include "base/base_paths.h"
8 #include "base/file_util.h"
9 #include "base/files/file_path.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/string_piece.h"
14 #include "base/win/resource_util.h"
15 #include "grit/webkit_chromium_resources.h"
16 #include "grit/webkit_resources.h"
17 #include "ui/base/resource/resource_bundle.h"
18 #include "webkit/support/test_webkit_platform_support.h"
19
20 #define MAX_LOADSTRING 100
21
22 namespace {
23
24 base::FilePath GetResourceFilePath(const char* ascii_name) {
25 base::FilePath path;
26 PathService::Get(base::DIR_EXE, &path);
27 path = path.AppendASCII("DumpRenderTree_resources");
28 return path.AppendASCII(ascii_name);
29 }
30
31 base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
32 void* data_ptr;
33 size_t data_size;
34 return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr,
35 &data_size)
36 ? base::StringPiece(static_cast<char*>(data_ptr), data_size)
37 : base::StringPiece();
38 }
39
40 base::StringPiece ResourceProvider(int key) {
41 return GetRawDataResource(::GetModuleHandle(NULL), key);
42 }
43
44 } // namespace
45
46 namespace webkit_support {
47
48 // TODO(tkent): Implement some of the followings for platform-dependent tasks
49 // such as loading resource.
50
51 void BeforeInitialize() {
52 }
53
54 void AfterInitialize() {
55 // TODO(dpranke): update other resource loading to use the pak
56 // instead of loading resources directly compiled in.
57 base::FilePath path;
58 PathService::Get(base::DIR_EXE, &path);
59 path = path.AppendASCII("DumpRenderTree.pak");
60 ResourceBundle::InitSharedInstanceWithPakPath(path);
61 }
62
63 void BeforeShutdown() {
64 ResourceBundle::CleanupSharedInstance();
65 }
66
67 void AfterShutdown() {
68 }
69
70 } // namespace webkit_support
71
72 base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) {
73 wchar_t localized[MAX_LOADSTRING];
74 int length = ::LoadString(::GetModuleHandle(NULL), message_id,
75 localized, MAX_LOADSTRING);
76 if (!length && ::GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND) {
77 NOTREACHED();
78 return L"No string for this identifier!";
79 }
80 return base::string16(localized, length);
81 }
82
83 base::StringPiece TestWebKitPlatformSupport::GetDataResource(
84 int resource_id,
85 ui::ScaleFactor scale_factor) {
86 switch (resource_id) {
87 case IDR_BROKENIMAGE: {
88 // Use webkit's broken image icon (16x16)
89 static std::string broken_image_data;
90 if (broken_image_data.empty()) {
91 base::FilePath path = GetResourceFilePath("missingImage.gif");
92 bool success = file_util::ReadFileToString(path, &broken_image_data);
93 if (!success) {
94 LOG(FATAL) << "Failed reading: " << path.value();
95 }
96 }
97 return broken_image_data;
98 }
99 case IDR_TEXTAREA_RESIZER: {
100 // Use webkit's text area resizer image.
101 static std::string resize_corner_data;
102 if (resize_corner_data.empty()) {
103 base::FilePath path = GetResourceFilePath("textAreaResizeCorner.png");
104 bool success = file_util::ReadFileToString(path, &resize_corner_data);
105 if (!success) {
106 LOG(FATAL) << "Failed reading: " << path.value();
107 }
108 }
109 return resize_corner_data;
110 }
111 }
112
113 // TODO(flackr): Pass scale_factor to ResourceProvider.
114 return ResourceProvider(resource_id);
115 }
OLDNEW
« no previous file with comments | « webkit/support/platform_support_mac.mm ('k') | webkit/support/test_webkit_platform_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698