summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorojan@chromium.org <ojan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 08:58:48 +0000
committerojan@chromium.org <ojan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 08:58:48 +0000
commit5775257334a0fc605d27312556ad3123d5909865 (patch)
tree042d664d85ff50ca5d5bf104efad38115e3e4ec3 /chrome
parent3b00779a8511730abc3935e0f971b7cbdcbc0408 (diff)
downloadchromium_src-5775257334a0fc605d27312556ad3123d5909865.zip
chromium_src-5775257334a0fc605d27312556ad3123d5909865.tar.gz
chromium_src-5775257334a0fc605d27312556ad3123d5909865.tar.bz2
Removes the following deprecated functions:
file_util::InsertBeforeExtension(wstring*, wstring&) file_util::PathComponents(wstring&, vector<wstring>*) file_util::ReplaceExtension(wstring*, wstring&) BUG=none TEST=manual test for importing IE bookmarks with some sub-directories. Original patch by tkent@google.com. See http://codereview.chromium.org/118109 r=ojan,estade git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/importer/ie_importer.cc34
-rw-r--r--chrome/test/reliability/page_load_test.cc17
2 files changed, 29 insertions, 22 deletions
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc
index fe27b12..4ccfdf8 100644
--- a/chrome/browser/importer/ie_importer.cc
+++ b/chrome/browser/importer/ie_importer.cc
@@ -475,21 +475,23 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info,
std::wstring ie_folder = l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_IE);
BookmarkVector toolbar_bookmarks;
FilePath file;
- std::vector<std::wstring> file_list;
+ std::vector<FilePath::StringType> file_list;
+ FilePath favorites_path(info.path);
+ // Favorites path length. Make sure it doesn't include the trailing \.
+ size_t favorites_path_len =
+ favorites_path.StripTrailingSeparators().value().size();
file_util::FileEnumerator file_enumerator(
- FilePath::FromWStringHack(info.path), true,
- file_util::FileEnumerator::FILES);
+ favorites_path, true, file_util::FileEnumerator::FILES);
while (!(file = file_enumerator.Next()).value().empty() && !cancelled())
- file_list.push_back(file.ToWStringHack());
+ file_list.push_back(file.value());
// Keep the bookmarks in alphabetical order.
std::sort(file_list.begin(), file_list.end());
- for (std::vector<std::wstring>::iterator it = file_list.begin();
+ for (std::vector<FilePath::StringType>::iterator it = file_list.begin();
it != file_list.end(); ++it) {
- std::wstring filename = file_util::GetFilenameFromPath(*it);
- std::wstring extension = file_util::GetFileExtensionFromPath(filename);
- if (!LowerCaseEqualsASCII(extension, "url"))
+ FilePath shortcut(*it);
+ if (!LowerCaseEqualsASCII(shortcut.Extension(), ".url"))
continue;
// Skip the bookmark with invalid URL.
@@ -497,13 +499,19 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info,
if (!url.is_valid())
continue;
- // Remove the dot and the file extension, and the directory path.
- std::wstring relative_path = it->substr(info.path.size(),
- it->size() - filename.size() - info.path.size());
- TrimString(relative_path, L"\\", &relative_path);
+ // Make the relative path from the Favorites folder, without the basename.
+ // ex. Suppose that the Favorites folder is C:\Users\Foo\Favorites.
+ // C:\Users\Foo\Favorites\Foo.url -> ""
+ // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar"
+ FilePath::StringType relative_string =
+ shortcut.DirName().value().substr(favorites_path_len);
+ if (relative_string.size() > 0 && FilePath::IsSeparator(relative_string[0]))
+ relative_string = relative_string.substr(1);
+ FilePath relative_path(relative_string);
ProfileWriter::BookmarkEntry entry;
- entry.title = filename.substr(0, filename.size() - (extension.size() + 1));
+ // Remove the dot, the file extension, and the directory path.
+ entry.title = shortcut.RemoveExtension().BaseName().value();
entry.url = url;
entry.creation_time = GetFileCreationTime(*it);
if (!relative_path.empty())
diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc
index 774b7f0..4a7b951 100644
--- a/chrome/test/reliability/page_load_test.cc
+++ b/chrome/test/reliability/page_load_test.cc
@@ -439,22 +439,21 @@ class PageLoadTest : public UITest {
}
}
- std::wstring ConstructSavedDebugLogPath(const std::wstring& debug_log_path,
- int index) {
- std::wstring saved_debug_log_path(debug_log_path);
+ FilePath ConstructSavedDebugLogPath(const FilePath& debug_log_path,
+ int index) {
std::wstring suffix(L"_");
suffix.append(IntToWString(index));
- file_util::InsertBeforeExtension(&saved_debug_log_path, suffix);
- return saved_debug_log_path;
+ return debug_log_path.InsertBeforeExtension(suffix);
}
void SaveDebugLog(const std::wstring& log_path, const std::wstring& log_id,
std::ofstream& log_file, int index) {
if (!log_path.empty()) {
- std::wstring saved_log_path =
- ConstructSavedDebugLogPath(log_path, index);
- if (file_util::Move(log_path, saved_log_path)) {
- log_file << " " << log_id << "=" << saved_log_path;
+ FilePath log_file_path(log_path);
+ FilePath saved_log_file_path =
+ ConstructSavedDebugLogPath(log_file_path, index);
+ if (file_util::Move(log_file_path, saved_log_file_path)) {
+ log_file << " " << log_id << "=" << saved_log_file_path.value();
}
}
}