summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 15:11:55 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 15:11:55 +0000
commit1840cfcf0da037741761abe2c04f73c354dff17a (patch)
treec4c457c2644b8878c3b6cea341cb152efad86d45
parent9e8554820f3b972d410ae9a96b837a65ab8d0333 (diff)
downloadchromium_src-1840cfcf0da037741761abe2c04f73c354dff17a.zip
chromium_src-1840cfcf0da037741761abe2c04f73c354dff17a.tar.gz
chromium_src-1840cfcf0da037741761abe2c04f73c354dff17a.tar.bz2
Deprecate file_util::AppendToPath() on non-Windows.
We still have ~150 callers to AppendToPath in our code, but most of them are in the installer and I'm reluctant to fiddle with that code without having an easy way to test it. BUG=24672 Review URL: http://codereview.chromium.org/654013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40120 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/file_util.cc10
-rw-r--r--base/file_util.h3
-rw-r--r--base/file_util_deprecated.h6
-rw-r--r--base/file_util_unittest.cc4
-rw-r--r--chrome/browser/chrome_plugin_host.cc7
-rw-r--r--chrome/browser/user_data_manager.cc17
-rw-r--r--chrome/common/chrome_constants.cc2
-rw-r--r--chrome/common/chrome_constants.h2
-rw-r--r--chrome/plugin/chrome_plugin_host.cc12
-rw-r--r--printing/printed_document.cc6
10 files changed, 42 insertions, 27 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index e0e6772..b10cd0b 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -331,16 +331,21 @@ bool AbsolutePath(std::wstring* path_str) {
*path_str = path.ToWStringHack();
return true;
}
+
+#if defined(OS_WIN)
+// This function is deprecated; see file_util_deprecated.h for details.
void AppendToPath(std::wstring* path, const std::wstring& new_ending) {
if (!path) {
NOTREACHED();
return; // Don't crash in this function in release builds.
}
- if (!EndsWithSeparator(path))
+ if (!EndsWithSeparator(*path))
path->push_back(FilePath::kSeparators[0]);
path->append(new_ending);
}
+#endif
+
bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path,
bool recursive) {
return CopyDirectory(FilePath::FromWStringHack(from_path),
@@ -350,9 +355,6 @@ bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path,
bool Delete(const std::wstring& path, bool recursive) {
return Delete(FilePath::FromWStringHack(path), recursive);
}
-bool EndsWithSeparator(std::wstring* path) {
- return EndsWithSeparator(FilePath::FromWStringHack(*path));
-}
bool EndsWithSeparator(const std::wstring& path) {
return EndsWithSeparator(FilePath::FromWStringHack(path));
}
diff --git a/base/file_util.h b/base/file_util.h
index fbde3e7..4d6077e 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -49,9 +49,6 @@ bool EndsWithSeparator(const FilePath& path);
// exists. Returns true if |path| is an existing directory, false otherwise.
bool EnsureEndsWithSeparator(FilePath* path);
-// Appends new_ending to path, adding a separator between the two if necessary.
-void AppendToPath(std::wstring* path, const std::wstring& new_ending);
-
// Convert provided relative path into an absolute path. Returns false on
// error. On POSIX, this function fails if the path does not exist.
bool AbsolutePath(FilePath* path);
diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h
index 05fd514..59f8d82 100644
--- a/base/file_util_deprecated.h
+++ b/base/file_util_deprecated.h
@@ -54,7 +54,8 @@ int ReadFile(const std::wstring& filename, char* data, int size);
int WriteFile(const std::wstring& filename, const char* data, int size);
bool GetCurrentDirectory(std::wstring* path);
-// Successfully deprecated on non-Windows, but Win-specific callers remain.
+// Functions successfully deprecated on non-Windows, but Win-specific
+// callers remain.
#if defined(OS_WIN)
// Returns the directory component of a path, without the trailing
// path separator, or an empty string on error. The function does not
@@ -67,6 +68,9 @@ bool GetCurrentDirectory(std::wstring* path);
// path == "C:\Windows\system32", returns "C:\Windows"
// Deprecated. Use FilePath's DirName() instead.
std::wstring GetDirectoryFromPath(const std::wstring& path);
+
+// Appends new_ending to path, adding a separator between the two if necessary.
+void AppendToPath(std::wstring* path, const std::wstring& new_ending);
#endif
}
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index ae6560d..fa92737 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -145,6 +145,8 @@ const struct append_case {
#endif
};
+#if defined(OS_WIN)
+// This function is deprecated, but still used on Windows.
TEST_F(FileUtilTest, AppendToPath) {
for (unsigned int i = 0; i < arraysize(append_cases); ++i) {
const append_case& value = append_cases[i];
@@ -157,6 +159,8 @@ TEST_F(FileUtilTest, AppendToPath) {
file_util::AppendToPath(NULL, L"path"); // asserts in debug mode
#endif
}
+#endif // defined(OS_WIN)
+
static const struct InsertBeforeExtensionCase {
const FilePath::CharType* path;
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc
index 03e23ac..50d9abc 100644
--- a/chrome/browser/chrome_plugin_host.cc
+++ b/chrome/browser/chrome_plugin_host.cc
@@ -461,9 +461,10 @@ int STDCALL CPB_GetBrowsingContextInfo(
PluginService* service = PluginService::GetInstance();
if (!service)
return CPERR_FAILURE;
- std::wstring wretval = service->GetChromePluginDataDir().ToWStringHack();
- file_util::AppendToPath(&wretval, chrome::kChromePluginDataDirname);
- *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, WideToUTF8(wretval));
+ FilePath path = service->GetChromePluginDataDir();
+ std::string retval = WideToUTF8(
+ path.Append(chrome::kChromePluginDataDirname).ToWStringHack());
+ *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, retval);
return CPERR_SUCCESS;
}
case CPBROWSINGCONTEXT_UI_LOCALE_PTR: {
diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc
index 7694c88..7d9c98a 100644
--- a/chrome/browser/user_data_manager.cc
+++ b/chrome/browser/user_data_manager.cc
@@ -221,9 +221,10 @@ std::wstring UserDataManager::GetFolderNameFromProfileName(
std::wstring UserDataManager::GetUserDataFolderForProfile(
const std::wstring& profile_name) const {
std::wstring folder_name = GetFolderNameFromProfileName(profile_name);
- std::wstring folder_path(user_data_root_);
- file_util::AppendToPath(&folder_path, folder_name);
- return folder_path;
+ FilePath folder_path =
+ FilePath::FromWStringHack(user_data_root_)
+ .Append(FilePath::FromWStringHack(folder_name));
+ return folder_path.ToWStringHack();
}
void UserDataManager::LaunchChromeForProfile(
@@ -289,8 +290,7 @@ bool UserDataManager::CreateShortcutForProfileInFolder(
IDS_START_IN_PROFILE_SHORTCUT_NAME,
profile_name);
shortcut_name.append(L".lnk");
-
- std::wstring shortcut_path = folder.Append(shortcut_name).ToWStringHack();
+ FilePath shortcut_path = folder.Append(shortcut_name);
// Profile path from user_data_dir.
FilePath profile_path = FilePath(user_data_dir).Append(
@@ -298,7 +298,7 @@ bool UserDataManager::CreateShortcutForProfileInFolder(
return file_util::CreateShortcutLink(
cmd.c_str(),
- shortcut_path.c_str(),
+ shortcut_path.value().c_str(),
exe_folder.c_str(),
args.c_str(),
NULL,
@@ -306,6 +306,9 @@ bool UserDataManager::CreateShortcutForProfileInFolder(
0,
ShellIntegration::GetChromiumAppId(profile_path).c_str());
#else
+ // TODO(port): should probably use freedesktop.org standard for desktop files.
+ // See shell_integration.h for an implementation; but this code is reportedly
+ // obsolete.
NOTIMPLEMENTED();
return false;
#endif
@@ -321,6 +324,8 @@ bool UserDataManager::CreateDesktopShortcutForProfile(
return CreateShortcutForProfileInFolder(FilePath(desktop_path), profile_name);
#else
// TODO(port): should probably use freedesktop.org standard for desktop files.
+ // See shell_integration.h for an implementation; but this code is reportedly
+ // obsolete.
NOTIMPLEMENTED();
return false;
#endif
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index a4278bb..fe4e0fe 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -84,7 +84,7 @@ const FilePath::CharType kMediaCacheDirname[] = FPL("Media Cache");
const FilePath::CharType kOffTheRecordMediaCacheDirname[] =
FPL("Incognito Media Cache");
const FilePath::CharType kAppCacheDirname[] = FPL("Application Cache");
-const wchar_t kChromePluginDataDirname[] = L"Plugin Data";
+const FilePath::CharType kChromePluginDataDirname[] = FPL("Plugin Data");
const FilePath::CharType kThemePackFilename[] = FPL("Cached Theme.pak");
const FilePath::CharType kCookieFilename[] = FPL("Cookies");
const FilePath::CharType kExtensionsCookieFilename[] = FPL("Extension Cookies");
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index cd85a14..0fe7d13 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -40,7 +40,7 @@ extern const FilePath::CharType kCacheDirname[];
extern const FilePath::CharType kMediaCacheDirname[];
extern const FilePath::CharType kOffTheRecordMediaCacheDirname[];
extern const FilePath::CharType kAppCacheDirname[];
-extern const wchar_t kChromePluginDataDirname[];
+extern const FilePath::CharType kChromePluginDataDirname[];
extern const FilePath::CharType kThemePackFilename[];
extern const FilePath::CharType kCookieFilename[];
extern const FilePath::CharType kExtensionsCookieFilename[];
diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc
index ab459f4..4561cc4 100644
--- a/chrome/plugin/chrome_plugin_host.cc
+++ b/chrome/plugin/chrome_plugin_host.cc
@@ -422,11 +422,13 @@ int STDCALL CPB_GetBrowsingContextInfo(
if (buf_size < sizeof(char*))
return sizeof(char*);
- std::wstring wretval = CommandLine::ForCurrentProcess()->
- GetSwitchValue(switches::kPluginDataDir);
- DCHECK(!wretval.empty());
- file_util::AppendToPath(&wretval, chrome::kChromePluginDataDirname);
- *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, WideToUTF8(wretval));
+ FilePath path = CommandLine::ForCurrentProcess()->
+ GetSwitchValuePath(switches::kPluginDataDir);
+ DCHECK(!path.empty());
+ std::string retval = WideToUTF8(
+ path.Append(chrome::kChromePluginDataDirname).ToWStringHack());
+ *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, retval);
+
return CPERR_SUCCESS;
}
case CPBROWSINGCONTEXT_UI_LOCALE_PTR: {
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index 7452e0e..6058968 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -270,10 +270,10 @@ void PrintedDocument::DebugDump(const PrintedPage& page) {
file_util::ReplaceIllegalCharactersInPath(&narrow_filename, '_');
filename = UTF8ToWide(narrow_filename);
#endif
- std::wstring path(g_debug_dump_info->debug_dump_path);
- file_util::AppendToPath(&path, filename);
+ FilePath path = FilePath::FromWStringHack(
+ g_debug_dump_info->debug_dump_path);
#if defined(OS_WIN)
- page.native_metafile()->SaveTo(path);
+ page.native_metafile()->SaveTo(path.Append(filename).ToWStringHack());
#else // OS_WIN
NOTIMPLEMENTED();
#endif // OS_WIN