summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_util_deprecated.h16
-rw-r--r--base/file_util_unittest.cc3
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc9
-rw-r--r--views/drag_utils.cc2
-rw-r--r--webkit/tools/test_shell/test_shell.cc3
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc4
6 files changed, 23 insertions, 14 deletions
diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h
index 6eae211..a5b7899 100644
--- a/base/file_util_deprecated.h
+++ b/base/file_util_deprecated.h
@@ -17,14 +17,6 @@
namespace file_util {
-// Use FilePath::DirName instead.
-void UpOneDirectory(std::wstring* dir);
-// Use FilePath::DirName instead.
-void UpOneDirectoryOrEmpty(std::wstring* dir);
-
-// Use FilePath::BaseName instead.
-std::wstring GetFilenameFromPath(const std::wstring& path);
-
// Use FilePath::Extension instead.
FilePath::StringType GetFileExtensionFromPath(const FilePath& path);
std::wstring GetFileExtensionFromPath(const std::wstring& path);
@@ -46,6 +38,14 @@ int WriteFile(const std::wstring& filename, const char* data, int size);
// Functions successfully deprecated on non-Windows, but Win-specific
// callers remain.
#if defined(OS_WIN)
+// Use FilePath::DirName instead.
+void UpOneDirectory(std::wstring* dir);
+// Use FilePath::DirName instead.
+void UpOneDirectoryOrEmpty(std::wstring* dir);
+
+// Use FilePath::BaseName instead.
+std::wstring GetFilenameFromPath(const std::wstring& path);
+
// Returns the directory component of a path, without the trailing
// path separator, or an empty string on error. The function does not
// check for the existence of the path, so if it is passed a directory
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 4827f59..fd54963 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -325,6 +325,8 @@ static const struct filename_case {
#endif
};
+#if defined(OS_WIN)
+// This function is deprecated on non-Windows.
TEST_F(FileUtilTest, GetFilenameFromPath) {
for (unsigned int i = 0; i < arraysize(filename_cases); ++i) {
const filename_case& value = filename_cases[i];
@@ -332,6 +334,7 @@ TEST_F(FileUtilTest, GetFilenameFromPath) {
EXPECT_EQ(value.filename, result);
}
}
+#endif
// Test finding the file type from a path name
static const struct extension_case {
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index 6efd343..5b0e157 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -255,10 +255,15 @@ NavigationEntry* NavigationController::CreateNavigationEntry(
entry->set_user_typed_url(url);
entry->set_update_virtual_url_with_url(reverse_on_redirect);
if (url.SchemeIsFile()) {
+ // Use the filename as the title, not the full path.
+ // We need to call FormatUrl() to perform URL de-escaping;
+ // it's a bit ugly to grab the filename out of the resulting string.
std::wstring languages = UTF8ToWide(profile->GetPrefs()->GetString(
prefs::kAcceptLanguages));
- entry->set_title(WideToUTF16Hack(
- file_util::GetFilenameFromPath(net::FormatUrl(url, languages))));
+ std::wstring formatted = net::FormatUrl(url, languages);
+ std::wstring filename =
+ FilePath::FromWStringHack(formatted).BaseName().ToWStringHack();
+ entry->set_title(WideToUTF16Hack(filename));
}
return entry;
}
diff --git a/views/drag_utils.cc b/views/drag_utils.cc
index 07e9359..aff790a 100644
--- a/views/drag_utils.cc
+++ b/views/drag_utils.cc
@@ -81,7 +81,7 @@ void CreateDragImageForFile(const FilePath::StringType& file_name,
width - 2, font.height(),
gfx::Canvas::TEXT_ALIGN_CENTER);
#else
- std::wstring name = file_util::GetFilenameFromPath(UTF8ToWide(file_name));
+ std::wstring name = FilePath(file_name).BaseName().ToWStringHack();
canvas.DrawStringInt(name, font, kFileDragImageTextColor,
0, icon->height() + kLinkDragImageVPadding,
width, font.height(), gfx::Canvas::TEXT_ALIGN_CENTER);
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 62bacb2..6845a95 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -773,8 +773,7 @@ bool IsDefaultPluginEnabled() {
FilePath exe_path;
if (PathService::Get(base::FILE_EXE, &exe_path)) {
- std::wstring exe_name = file_util::GetFilenameFromPath(
- exe_path.ToWStringHack());
+ std::wstring exe_name = exe_path.BaseName().ToWStringHack();
if (StartsWith(exe_name, L"test_shell_tests", false))
return true;
}
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 8c27c3a..cc5ced31 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -137,8 +137,10 @@ std::string UrlSuitableForTestResult(const std::string& url) {
if (url.empty() || std::string::npos == url.find("file://"))
return url;
+ // TODO: elsewhere in the codebase we use net::FormatUrl() for this.
std::string filename =
- WideToUTF8(file_util::GetFilenameFromPath(UTF8ToWide(url)));
+ WideToUTF8(FilePath::FromWStringHack(UTF8ToWide(url))
+ .BaseName().ToWStringHack());
if (filename.empty())
return "file:"; // A WebKit test has this in its expected output.
return filename;