summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-03 05:00:10 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-03 05:00:10 +0000
commitcdfa6da6a635e56c0818ae973317af59c3280c59 (patch)
treec9053f64ad19a51774b3a5556246fc82c134d0d0 /webkit
parent6540f83c68927d090d06ee099b6e5af921618343 (diff)
downloadchromium_src-cdfa6da6a635e56c0818ae973317af59c3280c59.zip
chromium_src-cdfa6da6a635e56c0818ae973317af59c3280c59.tar.gz
chromium_src-cdfa6da6a635e56c0818ae973317af59c3280c59.tar.bz2
Add resources to Linux DRT so things like the broken image
icon appear. Review URL: http://codereview.chromium.org/2548001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/support/platform_support_gtk.cc66
-rw-r--r--webkit/support/platform_support_mac.mm6
-rw-r--r--webkit/support/webkit_support.gypi13
-rw-r--r--webkit/support/webkit_support_glue.cc13
4 files changed, 74 insertions, 24 deletions
diff --git a/webkit/support/platform_support_gtk.cc b/webkit/support/platform_support_gtk.cc
index 4b1c6d4..e9d5dff 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
diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm
index e84dcd2..305adbf 100644
--- a/webkit/support/platform_support_mac.mm
+++ b/webkit/support/platform_support_mac.mm
@@ -182,8 +182,7 @@ base::StringPiece GetDataResource(int resource_id) {
// use a PNG. The GIF doesn't have the color range needed to correctly
// match the TIFF they use in Safari.
path = path.AppendASCII("missingImage.png");
- bool success = file_util::ReadFileToString(path.ToWStringHack(),
- &broken_image_data);
+ bool success = file_util::ReadFileToString(path, &broken_image_data);
if (!success) {
LOG(FATAL) << "Failed reading: " << path.value();
}
@@ -196,8 +195,7 @@ base::StringPiece GetDataResource(int resource_id) {
if (resize_corner_data.empty()) {
FilePath path = GetResourcesFilePath();
path = path.AppendASCII("textAreaResizeCorner.png");
- bool success = file_util::ReadFileToString(path.ToWStringHack(),
- &resize_corner_data);
+ bool success = file_util::ReadFileToString(path, &resize_corner_data);
if (!success) {
LOG(FATAL) << "Failed reading: " << path.value();
}
diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi
index 50f79bf..e39840c 100644
--- a/webkit/support/webkit_support.gypi
+++ b/webkit/support/webkit_support.gypi
@@ -53,7 +53,12 @@
'<(DEPTH)/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h',
],
'conditions': [
- ['OS=="win"', {
+ ['OS=="mac"', {
+ 'copies': [{
+ 'destination': '<(SHARED_INTERMEDIATE_DIR)/webkit',
+ 'files': ['../tools/test_shell/resources/textAreaResizeCorner.png'],
+ }],
+ },{ # OS!="mac"
'copies': [{
'destination': '<(PRODUCT_DIR)/DumpRenderTree_resources',
'files': [
@@ -62,12 +67,6 @@
],
}],
}],
- ['OS=="mac"', {
- 'copies': [{
- 'destination': '<(SHARED_INTERMEDIATE_DIR)/webkit',
- 'files': ['../tools/test_shell/resources/textAreaResizeCorner.png'],
- }],
- }],
],
},
],
diff --git a/webkit/support/webkit_support_glue.cc b/webkit/support/webkit_support_glue.cc
index 2d77d16..5f11be0 100644
--- a/webkit/support/webkit_support_glue.cc
+++ b/webkit/support/webkit_support_glue.cc
@@ -45,19 +45,6 @@ bool IsProtocolSupportedForMedia(const GURL& url) {
return false;
}
-#if !defined(OS_MACOSX) && !defined(OS_WIN)
-// These functions should be implemented in platform_support_*.cc
-string16 GetLocalizedString(int message_id) {
- // TODO(tkent): implement this.
- return string16();
-}
-
-base::StringPiece GetDataResource(int resource_id) {
- // TODO(tkent): implement this.
- return "";
-}
-#endif
-
void CloseCurrentConnections() {
}