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

Unified Diff: webkit/support/platform_support_gtk.cc

Issue 2548001: Add resources to Linux DRT so things like the broken image (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: clean Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/support/platform_support_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/support/platform_support_gtk.cc
diff --git a/webkit/support/platform_support_gtk.cc b/webkit/support/platform_support_gtk.cc
index 4b1c6d4bc170878513e7e77ec5365b1067bfee0d..e9d5dffd028639a31244c51e1d818c8000a211c0 100644
--- a/webkit/support/platform_support_gtk.cc
+++ b/webkit/support/platform_support_gtk.cc
@@ -4,6 +4,22 @@
#include "webkit/support/platform_support.h"
+#include "base/data_pack.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/string16.h"
+#include "base/string_piece.h"
+#include "grit/webkit_resources.h"
+
+namespace {
+
+// Data resources on linux. This is a pointer to the mmapped resources file.
+base::DataPack* g_resource_data_pack = NULL;
+
+}
+
namespace webkit_support {
// TODO(tkent): Implement some of the followings for platform-dependent tasks
@@ -13,6 +29,12 @@ void BeforeInitialize() {
}
void AfterInitialize() {
+ g_resource_data_pack = new base::DataPack;
+ FilePath data_path;
+ PathService::Get(base::DIR_EXE, &data_path);
+ data_path = data_path.Append("DumpRenderTree.pak");
+ if (!g_resource_data_pack->Load(data_path))
+ LOG(FATAL) << "failed to load DumpRenderTree.pak";
}
void BeforeShutdown() {
@@ -22,3 +44,47 @@ void AfterShutdown() {
}
} // namespace webkit_support
+
+namespace webkit_glue {
+
+string16 GetLocalizedString(int message_id) {
+ base::StringPiece res;
+ if (!g_resource_data_pack->GetStringPiece(message_id, &res))
+ LOG(FATAL) << "failed to load webkit string with id " << message_id;
+
+ return string16(reinterpret_cast<const char16*>(res.data()),
+ res.length() / 2);
+}
+
+base::StringPiece GetDataResource(int resource_id) {
+ FilePath resources_path;
+ PathService::Get(base::DIR_EXE, &resources_path);
+ resources_path = resources_path.Append("DumpRenderTree_resources");
+ switch (resource_id) {
+ case IDR_BROKENIMAGE: {
+ static std::string broken_image_data;
+ if (broken_image_data.empty()) {
+ FilePath path = resources_path.Append("missingImage.gif");
+ bool success = file_util::ReadFileToString(path, &broken_image_data);
+ if (!success)
+ LOG(FATAL) << "Failed reading: " << path.value();
+ }
+ return broken_image_data;
+ }
+ case IDR_TEXTAREA_RESIZER: {
+ static std::string resize_corner_data;
+ if (resize_corner_data.empty()) {
+ FilePath path = resources_path.Append("textAreaResizeCorner.png");
+ bool success = file_util::ReadFileToString(path, &resize_corner_data);
+ if (!success)
+ LOG(FATAL) << "Failed reading: " << path.value();
+ }
+ return resize_corner_data;
+ }
+ }
+ base::StringPiece res;
+ g_resource_data_pack->GetStringPiece(resource_id, &res);
+ return res;
+}
+
+} // namespace webkit_glue
« no previous file with comments | « no previous file | webkit/support/platform_support_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698