diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-21 19:19:16 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-21 19:19:16 +0000 |
commit | 989a9adc283220f30bed65f5254ef63684df3732 (patch) | |
tree | b9d1ceb54771120144ef8d150e04c01c7b3ce0f8 /webkit/tools/test_shell/test_shell_mac.mm | |
parent | 70cbae67f090da022412d43f86684a6a026847cf (diff) | |
download | chromium_src-989a9adc283220f30bed65f5254ef63684df3732.zip chromium_src-989a9adc283220f30bed65f5254ef63684df3732.tar.gz chromium_src-989a9adc283220f30bed65f5254ef63684df3732.tar.bz2 |
Add test shell resources into the linux .pak file.
Add a new test_shell_resources.grd that is only used on linux
and add it into test_shell.pak.
Move the data pack initialization into the global init and cleanup methods.
Move the old code for loading from disk into the platform specific files.
Review URL: http://codereview.chromium.org/18385
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/test_shell_mac.mm')
-rw-r--r-- | webkit/tools/test_shell/test_shell_mac.mm | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index 40a6fd2..4e8c22e 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -38,6 +38,9 @@ #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_navigation_controller.h" +// Generated by GRIT +#include "webkit_resources.h" + #import "skia/include/SkBitmap.h" #import "mac/DumpRenderTreePasteboard.h" @@ -66,6 +69,23 @@ const int kTestWindowYLocation = -14000; base::LazyInstance <std::map<gfx::NativeWindow, TestShell *> > TestShell::window_map_(base::LINKER_INITIALIZED); +// Helper method for getting the path to the test shell resources directory. +FilePath GetResourcesFilePath() { + FilePath path; + // We need to know if we're bundled or not to know which path to use. + if (mac_util::AmIBundled()) { + PathService::Get(base::DIR_EXE, &path); + path = path.Append(FILE_PATH_LITERAL(FilePath::kParentDirectory)); + return path.Append(FILE_PATH_LITERAL("Resources")); + } else { + PathService::Get(base::DIR_SOURCE_ROOT, &path); + path = path.Append(FILE_PATH_LITERAL("webkit")); + path = path.Append(FILE_PATH_LITERAL("tools")); + path = path.Append(FILE_PATH_LITERAL("test_shell")); + return path.Append(FILE_PATH_LITERAL("resources")); + } +} + // Receives notification that the window is closing so that it can start the // tear-down process. Is responsible for deleting itself when done. @interface WindowCloseDelegate : NSObject @@ -878,6 +898,53 @@ std::wstring GetLocalizedString(int message_id) { return UTF8ToWide([localString UTF8String]); } +std::string GetDataResource(int resource_id) { + switch (resource_id) { + case IDR_BROKENIMAGE: { + // Use webkit's broken image icon (16x16) + static std::string broken_image_data; + if (broken_image_data.empty()) { + FilePath path = GetResourcesFilePath(); + // In order to match WebKit's colors for the missing image, we have to + // use a PNG. The GIF doesn't have the color range needed to correctly + // match the TIFF they use in Safari. + path = path.Append(FILE_PATH_LITERAL("missingImage.png")); + bool success = file_util::ReadFileToString(path.ToWStringHack(), + &broken_image_data); + if (!success) { + LOG(FATAL) << "Failed reading: " << path.value(); + } + } + return broken_image_data; + } + case IDR_FEED_PREVIEW: + // It is necessary to return a feed preview template that contains + // a {{URL}} substring where the feed URL should go; see the code + // that computes feed previews in feed_preview.cc:MakeFeedPreview. + // This fixes issue #932714. + return std::string("Feed preview for {{URL}}"); + case IDR_TEXTAREA_RESIZER: { + // Use webkit's text area resizer image. + static std::string resize_corner_data; + if (resize_corner_data.empty()) { + FilePath path = GetResourcesFilePath(); + path = path.Append(FILE_PATH_LITERAL("textAreaResizeCorner.png")); + bool success = file_util::ReadFileToString(path.ToWStringHack(), + &resize_corner_data); + if (!success) { + LOG(FATAL) << "Failed reading: " << path.value(); + } + } + return resize_corner_data; + } + + default: + break; + } + + return std::string(); +} + NSCursor* LoadCursor(int cursor_id) { // TODO(port): add some more options here return [NSCursor arrowCursor]; |