summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-08 17:49:05 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-08 17:49:05 +0000
commit63597e4ebc117bb561b93f4d775d787120e6728a (patch)
treea4825625ef2ff06b339e56a30fa5ae80aea29160 /webkit/tools
parentc48abb01ae7e295e283f190bd05270e835b8d37f (diff)
downloadchromium_src-63597e4ebc117bb561b93f4d775d787120e6728a.zip
chromium_src-63597e4ebc117bb561b93f4d775d787120e6728a.tar.gz
chromium_src-63597e4ebc117bb561b93f4d775d787120e6728a.tar.bz2
Deprecate most of the remaining wstring file_util functions.
These still exist on Windows due to being used by the installer, but by moving them into the Windows-only block we prevent them from being used in new code. (I am already finding new code using some of these! I am glad to be rid of them.) BUG=24672 Review URL: http://codereview.chromium.org/2850042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r--webkit/tools/test_shell/test_shell.cc8
-rw-r--r--webkit/tools/test_shell/test_shell.h8
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc11
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm10
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc4
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc4
6 files changed, 22 insertions, 23 deletions
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 63de00b..a73dc95 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -325,7 +325,7 @@ void TestShell::Dump(TestShell* shell) {
// static
std::string TestShell::DumpImage(skia::PlatformCanvas* canvas,
- const std::wstring& file_name, const std::string& pixel_hash) {
+ const FilePath& path, const std::string& pixel_hash) {
skia::BitmapPlatformDevice& device =
static_cast<skia::BitmapPlatformDevice&>(canvas->getTopPlatformDevice());
const SkBitmap& src_bmp = device.accessBitmap(false);
@@ -371,7 +371,7 @@ std::string TestShell::DumpImage(skia::PlatformCanvas* canvas,
static_cast<int>(src_bmp.rowBytes()), discard_transparency, &png);
// Write to disk.
- file_util::WriteFile(file_name, reinterpret_cast<const char *>(&png[0]),
+ file_util::WriteFile(path, reinterpret_cast<const char *>(&png[0]),
png.size());
}
@@ -692,7 +692,7 @@ void TestShell::GoBackOrForward(int offset) {
}
void TestShell::DumpDocumentText() {
- std::wstring file_path;
+ FilePath file_path;
if (!PromptForSaveFile(L"Dump document text", &file_path))
return;
@@ -702,7 +702,7 @@ void TestShell::DumpDocumentText() {
}
void TestShell::DumpRenderTree() {
- std::wstring file_path;
+ FilePath file_path;
if (!PromptForSaveFile(L"Dump render tree", &file_path))
return;
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index 117e2d2..8f7e60c 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -32,6 +32,7 @@
#include <list>
#include "base/basictypes.h"
+#include "base/file_path.h"
#if defined(OS_MACOSX)
#include "base/lazy_instance.h"
#endif
@@ -50,7 +51,6 @@ typedef std::list<gfx::NativeWindow> WindowList;
struct WebPreferences;
class AccessibilityController;
-class FilePath;
class GURL;
class TestNavigationEntry;
class TestNavigationController;
@@ -75,7 +75,7 @@ public:
bool dump_pixels;
// Filename we dump pixels to (when pixel testing is enabled).
- std::wstring pixel_file_name;
+ FilePath pixel_file_name;
// The md5 hash of the bitmap dump (when pixel testing is enabled).
std::string pixel_hash;
// URL of the test.
@@ -202,7 +202,7 @@ public:
void Reload();
bool Navigate(const TestNavigationEntry& entry, bool reload);
- bool PromptForSaveFile(const wchar_t* prompt_title, std::wstring* result);
+ bool PromptForSaveFile(const wchar_t* prompt_title, FilePath* result);
std::wstring GetDocumentText();
void DumpDocumentText();
void DumpRenderTree();
@@ -262,7 +262,7 @@ public:
// Writes the image captured from the given web frame to the given file.
// The returned string is the ASCII-ized MD5 sum of the image.
static std::string DumpImage(skia::PlatformCanvas* canvas,
- const std::wstring& file_name,
+ const FilePath& path,
const std::string& pixel_hash);
static void ResetWebPreferences();
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 92f1f19..3d08253 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -491,7 +491,8 @@ void TestShell::ResizeSubViews() {
iter != TestShell::windowList()->end(); iter++) {
GtkWindow* window = *iter;
TestShell* shell =
- static_cast<TestShell*>(g_object_get_data(G_OBJECT(window), "test-shell"));
+ static_cast<TestShell*>(g_object_get_data(G_OBJECT(window),
+ "test-shell"));
shell->DumpBackForwardList(result);
}
}
@@ -505,7 +506,8 @@ void TestShell::ResizeSubViews() {
GtkWindow* window = *(TestShell::windowList()->begin());
TestShell* shell =
- static_cast<TestShell*>(g_object_get_data(G_OBJECT(window), "test-shell"));
+ static_cast<TestShell*>(g_object_get_data(G_OBJECT(window),
+ "test-shell"));
// Clear focus between tests.
shell->m_focusedWidgetHost = NULL;
@@ -570,9 +572,8 @@ void TestShell::LoadURLForFrame(const GURL& url,
new TestNavigationEntry(-1, url, std::wstring(), frame_name));
}
-// TODO(agl): PromptForSaveFile should use FilePath
bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
- std::wstring* result) {
+ FilePath* result) {
GtkWidget* dialog;
dialog = gtk_file_chooser_dialog_new(WideToUTF8(prompt_title).c_str(),
GTK_WINDOW(m_mainWnd),
@@ -589,7 +590,7 @@ bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
}
char* path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
gtk_widget_destroy(dialog);
- *result = UTF8ToWide(path);
+ *result = FilePath(path);
g_free(path);
return true;
}
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index 9b9b9aa..08c1432 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -593,7 +593,7 @@ void TestShell::LoadURLForFrame(const GURL& url,
}
bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
- std::wstring* result)
+ FilePath* result)
{
NSSavePanel* save_panel = [NSSavePanel savePanel];
@@ -605,7 +605,7 @@ bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
/* display the NSSavePanel */
if ([save_panel runModalForDirectory:NSHomeDirectory() file:@""] ==
NSOKButton) {
- result->assign(UTF8ToWide([[save_panel filename] UTF8String]));
+ *result = FilePath([[save_panel filename] fileSystemRepresentation]);
return true;
}
return false;
@@ -672,8 +672,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();
}
@@ -686,8 +685,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/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index 412cd3a..5cca69d 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -305,9 +305,9 @@ int main(int argc, char* argv[]) {
if (parsed_command_line.HasSwitch(test_shell::kDumpPixels)) {
// The pixel test flag also gives the image file name to use.
params.dump_pixels = true;
- params.pixel_file_name = parsed_command_line.GetSwitchValue(
+ params.pixel_file_name = parsed_command_line.GetSwitchValuePath(
test_shell::kDumpPixels);
- if (params.pixel_file_name.size() == 0) {
+ if (params.pixel_file_name.empty()) {
fprintf(stderr, "No file specified for pixel tests");
exit(1);
}
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index 079a830..07b9859 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -700,7 +700,7 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
}
bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
- std::wstring* result) {
+ FilePath* result) {
wchar_t path_buf[MAX_PATH] = L"data.txt";
OPENFILENAME info = {0};
@@ -714,7 +714,7 @@ bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
if (!GetSaveFileName(&info))
return false;
- result->assign(info.lpstrFile);
+ *result = FilePath(info.lpstrFile);
return true;
}