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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 void AfterShutdown() { | 39 void AfterShutdown() { |
40 } | 40 } |
41 | 41 |
42 } // namespace webkit_support | 42 } // namespace webkit_support |
43 | 43 |
44 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | 44 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
45 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); | 45 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); |
46 } | 46 } |
47 | 47 |
48 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { | 48 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
49 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | |
50 } | |
51 | |
52 base::StringPiece TestWebKitPlatformSupport::GetImageResource( | |
53 int resource_id, | 49 int resource_id, |
54 float scale_factor) { | 50 ui::ScaleFactor scale_factor) { |
55 FilePath resources_path; | 51 FilePath resources_path; |
56 PathService::Get(base::DIR_EXE, &resources_path); | 52 PathService::Get(base::DIR_EXE, &resources_path); |
57 resources_path = resources_path.Append("DumpRenderTree_resources"); | 53 resources_path = resources_path.Append("DumpRenderTree_resources"); |
58 switch (resource_id) { | 54 switch (resource_id) { |
59 case IDR_BROKENIMAGE: { | 55 case IDR_BROKENIMAGE: { |
60 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); | 56 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); |
61 if (broken_image_data.empty()) { | 57 if (broken_image_data.empty()) { |
62 FilePath path = resources_path.Append("missingImage.gif"); | 58 FilePath path = resources_path.Append("missingImage.gif"); |
63 bool success = file_util::ReadFileToString(path, &broken_image_data); | 59 bool success = file_util::ReadFileToString(path, &broken_image_data); |
64 if (!success) | 60 if (!success) |
65 LOG(FATAL) << "Failed reading: " << path.value(); | 61 LOG(FATAL) << "Failed reading: " << path.value(); |
66 } | 62 } |
67 return broken_image_data; | 63 return broken_image_data; |
68 } | 64 } |
69 case IDR_TEXTAREA_RESIZER: { | 65 case IDR_TEXTAREA_RESIZER: { |
70 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); | 66 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); |
71 if (resize_corner_data.empty()) { | 67 if (resize_corner_data.empty()) { |
72 FilePath path = resources_path.Append("textAreaResizeCorner.png"); | 68 FilePath path = resources_path.Append("textAreaResizeCorner.png"); |
73 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 69 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
74 if (!success) | 70 if (!success) |
75 LOG(FATAL) << "Failed reading: " << path.value(); | 71 LOG(FATAL) << "Failed reading: " << path.value(); |
76 } | 72 } |
77 return resize_corner_data; | 73 return resize_corner_data; |
78 } | 74 } |
79 } | 75 } |
80 | 76 |
81 // TODO(flackr): Pass scale_factor to ResourceBundle. | 77 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
82 return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 78 resource_id, scale_factor); |
83 } | 79 } |
OLD | NEW |