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" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 void AfterShutdown() { | 55 void AfterShutdown() { |
56 } | 56 } |
57 | 57 |
58 } // namespace webkit_support | 58 } // namespace webkit_support |
59 | 59 |
60 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | 60 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
61 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); | 61 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); |
62 } | 62 } |
63 | 63 |
64 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { | 64 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
65 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | |
66 } | |
67 | |
68 base::StringPiece TestWebKitPlatformSupport::GetImageResource( | |
69 int resource_id, | 65 int resource_id, |
70 float scale_factor) { | 66 ui::ScaleFactor scale_factor) { |
71 FilePath resources_path; | 67 FilePath resources_path; |
72 PathService::Get(base::DIR_EXE, &resources_path); | 68 PathService::Get(base::DIR_EXE, &resources_path); |
73 resources_path = resources_path.Append("DumpRenderTree_resources"); | 69 resources_path = resources_path.Append("DumpRenderTree_resources"); |
74 switch (resource_id) { | 70 switch (resource_id) { |
75 case IDR_BROKENIMAGE: { | 71 case IDR_BROKENIMAGE: { |
76 static std::string broken_image_data; | 72 static std::string broken_image_data; |
77 if (broken_image_data.empty()) { | 73 if (broken_image_data.empty()) { |
78 FilePath path = resources_path.Append("missingImage.gif"); | 74 FilePath path = resources_path.Append("missingImage.gif"); |
79 bool success = file_util::ReadFileToString(path, &broken_image_data); | 75 bool success = file_util::ReadFileToString(path, &broken_image_data); |
80 if (!success) | 76 if (!success) |
81 LOG(FATAL) << "Failed reading: " << path.value(); | 77 LOG(FATAL) << "Failed reading: " << path.value(); |
82 } | 78 } |
83 return broken_image_data; | 79 return broken_image_data; |
84 } | 80 } |
85 case IDR_TEXTAREA_RESIZER: { | 81 case IDR_TEXTAREA_RESIZER: { |
86 static std::string resize_corner_data; | 82 static std::string resize_corner_data; |
87 if (resize_corner_data.empty()) { | 83 if (resize_corner_data.empty()) { |
88 FilePath path = resources_path.Append("textAreaResizeCorner.png"); | 84 FilePath path = resources_path.Append("textAreaResizeCorner.png"); |
89 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 85 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
90 if (!success) | 86 if (!success) |
91 LOG(FATAL) << "Failed reading: " << path.value(); | 87 LOG(FATAL) << "Failed reading: " << path.value(); |
92 } | 88 } |
93 return resize_corner_data; | 89 return resize_corner_data; |
94 } | 90 } |
95 } | 91 } |
96 | 92 |
97 // TODO(flackr): Pass scale_factor to ResourceBundle. | 93 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
98 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 94 resource_id, scale_factor); |
99 } | 95 } |
OLD | NEW |