summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer/firefox2_importer.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-24 20:05:40 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-24 20:05:40 +0000
commit6d1088541356d73c51858d055e5b86e2a2663dc9 (patch)
tree6a83cb50dd3064533533999e8cc222ed65038b81 /chrome/browser/importer/firefox2_importer.cc
parentf4b51f0bc5f28e94febcc0574d19dbb6510a9721 (diff)
downloadchromium_src-6d1088541356d73c51858d055e5b86e2a2663dc9.zip
chromium_src-6d1088541356d73c51858d055e5b86e2a2663dc9.tar.gz
chromium_src-6d1088541356d73c51858d055e5b86e2a2663dc9.tar.bz2
importer: Remove instances of wstring from ProfileWriter.
(Note: This was a TODO for mirandac). BUG=23581,43460 TEST=None R=avi@chromium.org,mirandac@chromium.org Review URL: http://codereview.chromium.org/6729001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer/firefox2_importer.cc')
-rw-r--r--chrome/browser/importer/firefox2_importer.cc81
1 files changed, 39 insertions, 42 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc
index c20e5a7..41d2b288 100644
--- a/chrome/browser/importer/firefox2_importer.cc
+++ b/chrome/browser/importer/firefox2_importer.cc
@@ -111,11 +111,11 @@ void Firefox2Importer::LoadDefaultBookmarks(const FilePath& app_path,
continue;
// Get the bookmark.
- std::wstring title;
+ string16 title;
GURL url, favicon;
- std::wstring shortcut;
+ string16 shortcut;
base::Time add_date;
- std::wstring post_data;
+ string16 post_data;
if (ParseBookmarkFromLine(line, charset, &title, &url,
&favicon, &shortcut, &add_date,
&post_data))
@@ -124,8 +124,8 @@ void Firefox2Importer::LoadDefaultBookmarks(const FilePath& app_path,
}
// static
-TemplateURL* Firefox2Importer::CreateTemplateURL(const std::wstring& title,
- const std::wstring& keyword,
+TemplateURL* Firefox2Importer::CreateTemplateURL(const string16& title,
+ const string16& keyword,
const GURL& url) {
// Skip if the keyword or url is invalid.
if (keyword.empty() && url.is_valid())
@@ -134,8 +134,8 @@ TemplateURL* Firefox2Importer::CreateTemplateURL(const std::wstring& title,
TemplateURL* t_url = new TemplateURL();
// We set short name by using the title if it exists.
// Otherwise, we use the shortcut.
- t_url->set_short_name(WideToUTF16Hack(!title.empty() ? title : keyword));
- t_url->set_keyword(WideToUTF16Hack(keyword));
+ t_url->set_short_name(!title.empty() ? title : keyword);
+ t_url->set_keyword(keyword);
t_url->SetURL(TemplateURLRef::DisplayURLToURLRef(UTF8ToUTF16(url.spec())),
0, 0);
return t_url;
@@ -157,11 +157,11 @@ void Firefox2Importer::ImportBookmarksFile(
base::SplitString(content, '\n', &lines);
std::vector<ProfileWriter::BookmarkEntry> toolbar_bookmarks;
- std::wstring last_folder = first_folder_name;
+ string16 last_folder = WideToUTF16Hack(first_folder_name);
bool last_folder_on_toolbar = false;
bool last_folder_is_empty = true;
base::Time last_folder_add_date;
- std::vector<std::wstring> path;
+ std::vector<string16> path;
size_t toolbar_folder = 0;
std::string charset;
for (size_t i = 0; i < lines.size() && (!importer || !importer->cancelled());
@@ -180,10 +180,11 @@ void Firefox2Importer::ImportBookmarksFile(
continue;
// Get the bookmark entry.
- std::wstring title, shortcut;
+ string16 title;
+ string16 shortcut;
GURL url, favicon;
base::Time add_date;
- std::wstring post_data;
+ string16 post_data;
bool is_bookmark;
// TODO(jcampan): http://b/issue?id=1196285 we do not support POST based
// keywords yet.
@@ -251,7 +252,7 @@ void Firefox2Importer::ImportBookmarksFile(
if (path.empty())
break; // Mismatch <DL>.
- std::wstring folder_title = path.back();
+ string16 folder_title = path.back();
path.pop_back();
if (last_folder_is_empty) {
@@ -413,7 +414,7 @@ bool Firefox2Importer::ParseCharsetFromLine(const std::string& line,
// static
bool Firefox2Importer::ParseFolderNameFromLine(const std::string& line,
const std::string& charset,
- std::wstring* folder_name,
+ string16* folder_name,
bool* is_toolbar_folder,
base::Time* add_date) {
const char kFolderOpen[] = "<DT><H3";
@@ -430,8 +431,8 @@ bool Firefox2Importer::ParseFolderNameFromLine(const std::string& line,
if (end == std::string::npos || tag_end < arraysize(kFolderOpen))
return false;
- base::CodepageToWide(line.substr(tag_end, end - tag_end), charset.c_str(),
- base::OnStringConversionError::SKIP, folder_name);
+ base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
+ base::OnStringConversionError::SKIP, folder_name);
HTMLUnescape(folder_name);
std::string attribute_list = line.substr(arraysize(kFolderOpen),
@@ -459,12 +460,12 @@ bool Firefox2Importer::ParseFolderNameFromLine(const std::string& line,
// static
bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line,
const std::string& charset,
- std::wstring* title,
+ string16* title,
GURL* url,
GURL* favicon,
- std::wstring* shortcut,
+ string16* shortcut,
base::Time* add_date,
- std::wstring* post_data) {
+ string16* post_data) {
title->clear();
*url = GURL();
*favicon = GURL();
@@ -491,18 +492,16 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line,
return false;
// Title
- base::CodepageToWide(line.substr(tag_end, end - tag_end), charset.c_str(),
- base::OnStringConversionError::SKIP, title);
+ base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
+ base::OnStringConversionError::SKIP, title);
HTMLUnescape(title);
// URL
if (GetAttribute(attribute_list, kHrefAttribute, &value)) {
- std::wstring w_url;
- base::CodepageToWide(value, charset.c_str(),
- base::OnStringConversionError::SKIP, &w_url);
- HTMLUnescape(&w_url);
-
- string16 url16 = WideToUTF16Hack(w_url);
+ string16 url16;
+ base::CodepageToUTF16(value, charset.c_str(),
+ base::OnStringConversionError::SKIP, &url16);
+ HTMLUnescape(&url16);
*url = GURL(url16);
}
@@ -513,8 +512,8 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line,
// Keyword
if (GetAttribute(attribute_list, kShortcutURLAttribute, &value)) {
- base::CodepageToWide(value, charset.c_str(),
- base::OnStringConversionError::SKIP, shortcut);
+ base::CodepageToUTF16(value, charset.c_str(),
+ base::OnStringConversionError::SKIP, shortcut);
HTMLUnescape(shortcut);
}
@@ -529,8 +528,8 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line,
// Post data.
if (GetAttribute(attribute_list, kPostDataAttribute, &value)) {
- base::CodepageToWide(value, charset.c_str(),
- base::OnStringConversionError::SKIP, post_data);
+ base::CodepageToUTF16(value, charset.c_str(),
+ base::OnStringConversionError::SKIP, post_data);
HTMLUnescape(post_data);
}
@@ -540,7 +539,7 @@ bool Firefox2Importer::ParseBookmarkFromLine(const std::string& line,
// static
bool Firefox2Importer::ParseMinimumBookmarkFromLine(const std::string& line,
const std::string& charset,
- std::wstring* title,
+ string16* title,
GURL* url) {
const char kItemOpen[] = "<DT><A";
const char kItemClose[] = "</";
@@ -564,8 +563,8 @@ bool Firefox2Importer::ParseMinimumBookmarkFromLine(const std::string& line,
tag_end - arraysize(kItemOpen) - 1);
// Title
- base::CodepageToWide(line.substr(tag_end, end - tag_end), charset.c_str(),
- base::OnStringConversionError::SKIP, title);
+ base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
+ base::OnStringConversionError::SKIP, title);
HTMLUnescape(title);
// URL
@@ -573,12 +572,10 @@ bool Firefox2Importer::ParseMinimumBookmarkFromLine(const std::string& line,
if (GetAttribute(attribute_list, kHrefAttributeUpper, &value) ||
GetAttribute(attribute_list, kHrefAttributeLower, &value)) {
if (charset.length() != 0) {
- std::wstring w_url;
- base::CodepageToWide(value, charset.c_str(),
- base::OnStringConversionError::SKIP, &w_url);
- HTMLUnescape(&w_url);
-
- string16 url16 = WideToUTF16Hack(w_url);
+ string16 url16;
+ base::CodepageToUTF16(value, charset.c_str(),
+ base::OnStringConversionError::SKIP, &url16);
+ HTMLUnescape(&url16);
*url = GURL(url16);
} else {
@@ -618,8 +615,8 @@ bool Firefox2Importer::GetAttribute(const std::string& attribute_list,
}
// static
-void Firefox2Importer::HTMLUnescape(std::wstring *text) {
- string16 text16 = WideToUTF16Hack(*text);
+void Firefox2Importer::HTMLUnescape(string16* text) {
+ string16 text16 = *text;
ReplaceSubstringsAfterOffset(
&text16, 0, ASCIIToUTF16("&lt;"), ASCIIToUTF16("<"));
ReplaceSubstringsAfterOffset(
@@ -630,7 +627,7 @@ void Firefox2Importer::HTMLUnescape(std::wstring *text) {
&text16, 0, ASCIIToUTF16("&quot;"), ASCIIToUTF16("\""));
ReplaceSubstringsAfterOffset(
&text16, 0, ASCIIToUTF16("&#39;"), ASCIIToUTF16("\'"));
- text->assign(UTF16ToWideHack(text16));
+ text->assign(text16);
}
// static