summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-29 20:35:19 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-29 20:35:19 +0000
commitddd231eaa03153f6d04894cceb0b4480755e1277 (patch)
treefaafed02945c1f8934e6e393ac0c6b094c303cdf /chrome/browser/importer
parentc5e30d8572ffae1e0d4fbb2fff765f9a8cbace77 (diff)
downloadchromium_src-ddd231eaa03153f6d04894cceb0b4480755e1277.zip
chromium_src-ddd231eaa03153f6d04894cceb0b4480755e1277.tar.gz
chromium_src-ddd231eaa03153f6d04894cceb0b4480755e1277.tar.bz2
Change a bunch of string types.
Started out just trying to change PrefService::GetString and ::SetString. This snowballed a little bit. Had to change a bunch of url strings in search_engines/ from wstring to string (some of them may be better off as GURLs, but UTF-8 is a step in the right direction, since that's what GURL uses internally, as well as externally via its setters/getters). TODO (later patch): things that ask for accepted languages should use std::string, not std::wstring. BUG=none TEST=try bots Review URL: http://codereview.chromium.org/2854015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51157 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r--chrome/browser/importer/firefox_importer_utils.cc10
-rw-r--r--chrome/browser/importer/ie_importer.cc11
-rw-r--r--chrome/browser/importer/importer_messages.h2
-rw-r--r--chrome/browser/importer/importer_unittest.cc62
-rw-r--r--chrome/browser/importer/profile_writer.cc12
5 files changed, 49 insertions, 48 deletions
diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc
index 40693ef..b9a7a74 100644
--- a/chrome/browser/importer/firefox_importer_utils.cc
+++ b/chrome/browser/importer/firefox_importer_utils.cc
@@ -186,7 +186,7 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files,
std::vector<TemplateURL*>* search_engines) {
DCHECK(search_engines);
- std::map<std::wstring, TemplateURL*> search_engine_for_url;
+ std::map<std::string, TemplateURL*> search_engine_for_url;
std::string content;
// The first XML file represents the default search engine in Firefox 3, so we
// need to keep it on top of the list.
@@ -200,8 +200,8 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files,
reinterpret_cast<const unsigned char*>(content.data()),
content.length(), &param_filter, template_url) &&
template_url->url()) {
- std::wstring url = template_url->url()->url();
- std::map<std::wstring, TemplateURL*>::iterator iter =
+ std::string url = template_url->url()->url();
+ std::map<std::string, TemplateURL*>::iterator iter =
search_engine_for_url.find(url);
if (iter != search_engine_for_url.end()) {
// We have already found a search engine with the same URL. We give
@@ -213,7 +213,7 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files,
}
// Give this a keyword to facilitate tab-to-search, if possible.
template_url->set_keyword(
- TemplateURLModel::GenerateKeyword(GURL(WideToUTF8(url)), false));
+ TemplateURLModel::GenerateKeyword(GURL(url), false));
template_url->set_show_in_default_list(true);
search_engine_for_url[url] = template_url;
if (!default_turl)
@@ -225,7 +225,7 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files,
}
// Put the results in the |search_engines| vector.
- std::map<std::wstring, TemplateURL*>::iterator t_iter;
+ std::map<std::string, TemplateURL*>::iterator t_iter;
for (t_iter = search_engine_for_url.begin();
t_iter != search_engine_for_url.end(); ++t_iter) {
if (t_iter->second == default_turl)
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc
index f65bbdd..2824b40 100644
--- a/chrome/browser/importer/ie_importer.cc
+++ b/chrome/browser/importer/ie_importer.cc
@@ -346,15 +346,15 @@ void IEImporter::ImportSearchEngines() {
RegKey key(HKEY_CURRENT_USER, kSearchScopePath, KEY_READ);
std::wstring default_search_engine_name;
const TemplateURL* default_search_engine = NULL;
- std::map<std::wstring, TemplateURL*> search_engines_map;
+ std::map<std::string, TemplateURL*> search_engines_map;
key.ReadValue(L"DefaultScope", &default_search_engine_name);
RegistryKeyIterator key_iterator(HKEY_CURRENT_USER, kSearchScopePath);
while (key_iterator.Valid()) {
std::wstring sub_key_name = kSearchScopePath;
sub_key_name.append(L"\\").append(key_iterator.Name());
RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), KEY_READ);
- std::wstring url;
- if (!sub_key.ReadValue(L"URL", &url) || url.empty()) {
+ std::wstring wide_url;
+ if (!sub_key.ReadValue(L"URL", &wide_url) || wide_url.empty()) {
LOG(INFO) << "No URL for IE search engine at " << key_iterator.Name();
++key_iterator;
continue;
@@ -372,7 +372,8 @@ void IEImporter::ImportSearchEngines() {
}
}
- std::map<std::wstring, TemplateURL*>::iterator t_iter =
+ std::string url(WideToUTF8(wide_url));
+ std::map<std::string, TemplateURL*>::iterator t_iter =
search_engines_map.find(url);
TemplateURL* template_url =
(t_iter != search_engines_map.end()) ? t_iter->second : NULL;
@@ -395,7 +396,7 @@ void IEImporter::ImportSearchEngines() {
}
// ProfileWriter::AddKeywords() requires a vector and we have a map.
- std::map<std::wstring, TemplateURL*>::iterator t_iter;
+ std::map<std::string, TemplateURL*>::iterator t_iter;
std::vector<TemplateURL*> search_engines;
int default_search_engine_index = -1;
for (t_iter = search_engines_map.begin(); t_iter != search_engines_map.end();
diff --git a/chrome/browser/importer/importer_messages.h b/chrome/browser/importer/importer_messages.h
index 3feca84..4bbba62 100644
--- a/chrome/browser/importer/importer_messages.h
+++ b/chrome/browser/importer/importer_messages.h
@@ -195,7 +195,7 @@ struct ParamTraits<TemplateURLRef> {
WriteParam(m, p.page_offset());
}
static bool Read(const Message* m, void** iter, param_type* p) {
- std::wstring url;
+ std::string url;
int index_offset;
int page_offset;
if (!ReadParam(m, iter, &url) ||
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index 8a9f50c..7c3a45c 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -511,35 +511,35 @@ static const PasswordList kFirefox2Passwords[] = {
typedef struct {
const wchar_t* keyword;
- const wchar_t* url;
+ const char* url;
} KeywordList;
static const KeywordList kFirefox2Keywords[] = {
// Searh plugins
{ L"amazon.com",
- L"http://www.amazon.com/exec/obidos/external-search/?field-keywords="
- L"{searchTerms}&mode=blended" },
+ "http://www.amazon.com/exec/obidos/external-search/?field-keywords="
+ "{searchTerms}&mode=blended" },
{ L"answers.com",
- L"http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" },
+ "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" },
{ L"search.creativecommons.org",
- L"http://search.creativecommons.org/?q={searchTerms}" },
+ "http://search.creativecommons.org/?q={searchTerms}" },
{ L"search.ebay.com",
- L"http://search.ebay.com/search/search.dll?query={searchTerms}&"
- L"MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&"
- L"maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort" },
+ "http://search.ebay.com/search/search.dll?query={searchTerms}&"
+ "MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&"
+ "maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort" },
{ L"google.com",
- L"http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" },
+ "http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" },
{ L"search.yahoo.com",
- L"http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8" },
+ "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8" },
{ L"flickr.com",
- L"http://www.flickr.com/photos/tags/?q={searchTerms}" },
+ "http://www.flickr.com/photos/tags/?q={searchTerms}" },
{ L"imdb.com",
- L"http://www.imdb.com/find?q={searchTerms}" },
+ "http://www.imdb.com/find?q={searchTerms}" },
{ L"webster.com",
- L"http://www.webster.com/cgi-bin/dictionary?va={searchTerms}" },
+ "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}" },
// Search keywords.
- { L"google", L"http://www.google.com/" },
- { L"< > & \" ' \\ /", L"http://g.cn/"},
+ { L"google", "http://www.google.com/" },
+ { L"< > & \" ' \\ /", "http://g.cn/"},
};
static const int kDefaultFirefox2KeywordIndex = 8;
@@ -650,7 +650,7 @@ class FirefoxObserver : public ProfileWriter,
int password_count_;
int keyword_count_;
std::wstring default_keyword_;
- std::wstring default_keyword_url_;
+ std::string default_keyword_url_;
};
TEST_F(ImporterTest, Firefox2Importer) {
@@ -708,30 +708,30 @@ static const PasswordList kFirefox3Passwords[] = {
static const KeywordList kFirefox3Keywords[] = {
{ L"amazon.com",
- L"http://www.amazon.com/exec/obidos/external-search/?field-keywords="
- L"{searchTerms}&mode=blended" },
+ "http://www.amazon.com/exec/obidos/external-search/?field-keywords="
+ "{searchTerms}&mode=blended" },
{ L"answers.com",
- L"http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" },
+ "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" },
{ L"search.creativecommons.org",
- L"http://search.creativecommons.org/?q={searchTerms}" },
+ "http://search.creativecommons.org/?q={searchTerms}" },
{ L"search.ebay.com",
- L"http://search.ebay.com/search/search.dll?query={searchTerms}&"
- L"MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&"
- L"maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort" },
+ "http://search.ebay.com/search/search.dll?query={searchTerms}&"
+ "MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&"
+ "maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort" },
{ L"google.com",
- L"http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" },
+ "http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" },
{ L"en.wikipedia.org",
- L"http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}" },
+ "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}" },
{ L"search.yahoo.com",
- L"http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8" },
+ "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8" },
{ L"flickr.com",
- L"http://www.flickr.com/photos/tags/?q={searchTerms}" },
+ "http://www.flickr.com/photos/tags/?q={searchTerms}" },
{ L"imdb.com",
- L"http://www.imdb.com/find?q={searchTerms}" },
+ "http://www.imdb.com/find?q={searchTerms}" },
{ L"webster.com",
- L"http://www.webster.com/cgi-bin/dictionary?va={searchTerms}" },
+ "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}" },
// Search keywords.
- { L"\x4E2D\x6587", L"http://www.google.com/" },
+ { L"\x4E2D\x6587", "http://www.google.com/" },
};
static const int kDefaultFirefox3KeywordIndex = 8;
@@ -854,7 +854,7 @@ class Firefox3Observer : public ProfileWriter,
int keyword_count_;
bool import_search_engines_;
std::wstring default_keyword_;
- std::wstring default_keyword_url_;
+ std::string default_keyword_url_;
};
TEST_F(ImporterTest, Firefox30Importer) {
diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc
index 6217408..f3b469f 100644
--- a/chrome/browser/importer/profile_writer.cc
+++ b/chrome/browser/importer/profile_writer.cc
@@ -47,7 +47,7 @@ void ProfileWriter::AddHomepage(const GURL& home_page) {
// NOTE: We set the kHomePage value, but keep the NewTab page as the homepage.
const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage);
if (pref && !pref->IsManaged()) {
- prefs->SetString(prefs::kHomePage, ASCIIToWide(home_page.spec()));
+ prefs->SetString(prefs::kHomePage, home_page.spec());
prefs->ScheduleSavePersistentPrefs();
}
}
@@ -166,13 +166,13 @@ static std::string BuildHostPathKey(const TemplateURL* t_url,
bool try_url_if_invalid) {
if (t_url->url()) {
if (try_url_if_invalid && !t_url->url()->IsValid())
- return HostPathKeyForURL(GURL(WideToUTF8(t_url->url()->url())));
+ return HostPathKeyForURL(GURL(t_url->url()->url()));
if (t_url->url()->SupportsReplacement()) {
- return HostPathKeyForURL(
- GURL(WideToUTF8(t_url->url()->ReplaceSearchTerms(
- *t_url, L"random string",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()))));
+ return HostPathKeyForURL(GURL(
+ t_url->url()->ReplaceSearchTerms(
+ *t_url, L"random string",
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())));
}
}
return std::string();