diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-29 20:35:19 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-29 20:35:19 +0000 |
commit | ddd231eaa03153f6d04894cceb0b4480755e1277 (patch) | |
tree | faafed02945c1f8934e6e393ac0c6b094c303cdf /chrome/browser/autocomplete | |
parent | c5e30d8572ffae1e0d4fbb2fff765f9a8cbace77 (diff) | |
download | chromium_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/autocomplete')
7 files changed, 41 insertions, 34 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 1846e2d..e42ee92 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -598,8 +598,12 @@ void AutocompleteProvider::UpdateStarredStateOfMatches() { std::wstring AutocompleteProvider::StringForURLDisplay(const GURL& url, bool check_accept_lang, bool trim_http) const { - return net::FormatUrl(url, (check_accept_lang && profile_) ? - profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::wstring(), + std::wstring languages = (check_accept_lang && profile_) ? + UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) : + std::wstring(); + return net::FormatUrl( + url, + languages, net::kFormatUrlOmitAll & ~(trim_http ? 0 : net::kFormatUrlOmitHTTP), UnescapeRule::SPACES, NULL, NULL, NULL); } diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc index 35dbff5..e267f3c 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc @@ -192,7 +192,7 @@ class AutocompleteEditViewTest : public InProcessBrowserTest, ASSERT_TRUE(model->loaded()); TemplateURL* template_url = new TemplateURL(); - template_url->SetURL(UTF8ToWide(kSearchURL), 0, 0); + template_url->SetURL(kSearchURL, 0, 0); template_url->set_keyword(UTF8ToWide(kSearchKeyword)); template_url->set_short_name(UTF8ToWide(kSearchShortName)); diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index a4cbd28..f1bd7f9 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -663,8 +663,10 @@ void HistoryURLProvider::RunAutocompletePasses( // onto the |params_| member for later deletion below if we need to run pass // 2. std::wstring languages(languages_); - if (languages.empty() && profile_) - languages = profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); + if (languages.empty() && profile_) { + languages = + UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); + } scoped_ptr<HistoryURLProviderParams> params( new HistoryURLProviderParams(input, trim_http, languages)); diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index 1b7e2ae..756818c 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -260,7 +260,7 @@ void KeywordProvider::FillInURLAndContents( ACMatchClassification(0, ACMatchClassification::DIM)); } else { // Keyword that has no replacement text (aka a shorthand for a URL). - match->destination_url = GURL(WideToUTF8(element->url()->url())); + match->destination_url = GURL(element->url()->url()); match->contents.assign(element->short_name()); AutocompleteMatch::ClassifyLocationInString(0, match->contents.length(), match->contents.length(), ACMatchClassification::NONE, @@ -272,9 +272,9 @@ void KeywordProvider::FillInURLAndContents( // input, but we rely on later canonicalization functions to do more // fixup to make the URL valid if necessary. DCHECK(element->url()->SupportsReplacement()); - match->destination_url = GURL(WideToUTF8(element->url()->ReplaceSearchTerms( + match->destination_url = GURL(element->url()->ReplaceSearchTerms( *element, remaining_input, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, - std::wstring()))); + std::wstring())); std::vector<size_t> content_param_offsets; match->contents.assign(l10n_util::GetStringF(message_id, element->short_name(), diff --git a/chrome/browser/autocomplete/keyword_provider_unittest.cc b/chrome/browser/autocomplete/keyword_provider_unittest.cc index ed93c74..0578496 100644 --- a/chrome/browser/autocomplete/keyword_provider_unittest.cc +++ b/chrome/browser/autocomplete/keyword_provider_unittest.cc @@ -36,13 +36,13 @@ class KeywordProviderTest : public testing::Test { void KeywordProviderTest::SetUp() { static const TemplateURLModel::Initializer kTestKeywordData[] = { - { L"aa", L"aa.com?foo=%s", L"aa" }, - { L"aaaa", L"http://aaaa/?aaaa=1&b=%s&c", L"aaaa" }, - { L"aaaaa", L"%s", L"aaaaa" }, - { L"ab", L"bogus URL %s", L"ab" }, - { L"weasel", L"weasel%sweasel", L"weasel" }, - { L"www", L" +%2B?=%sfoo ", L"www" }, - { L"z", L"%s=z", L"z" }, + { L"aa", "aa.com?foo=%s", L"aa" }, + { L"aaaa", "http://aaaa/?aaaa=1&b=%s&c", L"aaaa" }, + { L"aaaaa", "%s", L"aaaaa" }, + { L"ab", "bogus URL %s", L"ab" }, + { L"weasel", "weasel%sweasel", L"weasel" }, + { L"www", " +%2B?=%sfoo ", L"www" }, + { L"z", "%s=z", L"z" }, }; model_.reset(new TemplateURLModel(kTestKeywordData, @@ -180,7 +180,7 @@ TEST_F(KeywordProviderTest, Description) { TEST_F(KeywordProviderTest, AddKeyword) { TemplateURL* template_url = new TemplateURL(); std::wstring keyword(L"foo"); - std::wstring url(L"http://www.google.com/foo?q={searchTerms}"); + std::string url("http://www.google.com/foo?q={searchTerms}"); template_url->SetURL(url, 0, 0); template_url->set_keyword(keyword); template_url->set_short_name(L"Test"); diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 87d0a68..08dc01c 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -368,9 +368,9 @@ URLFetcher* SearchProvider::CreateSuggestFetcher(int id, const TemplateURLRef* const suggestions_url = provider.suggestions_url(); DCHECK(suggestions_url->SupportsReplacement()); URLFetcher* fetcher = URLFetcher::Create(id, - GURL(WideToUTF8(suggestions_url->ReplaceSearchTerms( - provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, - std::wstring()))), + GURL(suggestions_url->ReplaceSearchTerms( + provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, + std::wstring())), URLFetcher::GET, this); fetcher->set_request_context(profile_->GetRequestContext()); fetcher->Start(); @@ -702,9 +702,10 @@ void SearchProvider::AddMatchToMap(const std::wstring& query_string, const TemplateURLRef* const search_url = provider.url(); DCHECK(search_url->SupportsReplacement()); match.destination_url = - GURL(WideToUTF8(search_url->ReplaceSearchTerms(provider, query_string, - accepted_suggestion, - input_text))); + GURL(search_url->ReplaceSearchTerms(provider, + query_string, + accepted_suggestion, + input_text)); // Search results don't look like URLs. match.transition = diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 1e489f2..b013db9 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -96,8 +96,8 @@ void SearchProviderTest::SetUp() { // Reset the default TemplateURL. default_t_url_ = new TemplateURL(); - default_t_url_->SetURL(L"http://defaultturl/{searchTerms}", 0, 0); - default_t_url_->SetSuggestionsURL(L"http://defaultturl2/{searchTerms}", 0, 0); + default_t_url_->SetURL("http://defaultturl/{searchTerms}", 0, 0); + default_t_url_->SetSuggestionsURL("http://defaultturl2/{searchTerms}", 0, 0); turl_model->Add(default_t_url_); turl_model->SetDefaultSearchProvider(default_t_url_); TemplateURL::IDType default_provider_id = default_t_url_->id(); @@ -106,8 +106,8 @@ void SearchProviderTest::SetUp() { // Add url1, with search term term1_. HistoryService* history = profile_.GetHistoryService(Profile::EXPLICIT_ACCESS); - term1_url_ = GURL(WideToUTF8(default_t_url_->url()->ReplaceSearchTerms( - *default_t_url_, UTF16ToWide(term1_), 0, std::wstring()))); + term1_url_ = GURL(default_t_url_->url()->ReplaceSearchTerms( + *default_t_url_, UTF16ToWide(term1_), 0, std::wstring())); history->AddPageWithDetails(term1_url_, string16(), 1, 1, base::Time::Now(), false); history->SetKeywordSearchTermsForURL(term1_url_, default_t_url_->id(), @@ -116,15 +116,15 @@ void SearchProviderTest::SetUp() { // Create another TemplateURL. keyword_t_url_ = new TemplateURL(); keyword_t_url_->set_keyword(L"k"); - keyword_t_url_->SetURL(L"http://keyword/{searchTerms}", 0, 0); - keyword_t_url_->SetSuggestionsURL(L"http://suggest_keyword/{searchTerms}", 0, + keyword_t_url_->SetURL("http://keyword/{searchTerms}", 0, 0); + keyword_t_url_->SetSuggestionsURL("http://suggest_keyword/{searchTerms}", 0, 0); profile_.GetTemplateURLModel()->Add(keyword_t_url_); ASSERT_NE(0, keyword_t_url_->id()); // Add a page and search term for keyword_t_url_. - keyword_url_ = GURL(WideToUTF8(keyword_t_url_->url()->ReplaceSearchTerms( - *keyword_t_url_, UTF16ToWide(keyword_term_), 0, std::wstring()))); + keyword_url_ = GURL(keyword_t_url_->url()->ReplaceSearchTerms( + *keyword_t_url_, UTF16ToWide(keyword_term_), 0, std::wstring())); history->AddPageWithDetails(keyword_url_, string16(), 1, 1, base::Time::Now(), false); history->SetKeywordSearchTermsForURL(keyword_url_, keyword_t_url_->id(), @@ -199,9 +199,9 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) { ASSERT_TRUE(fetcher); // And the URL matches what we expected. - GURL expected_url = GURL(WideToUTF8(default_t_url_->suggestions_url()-> + GURL expected_url = GURL(default_t_url_->suggestions_url()-> ReplaceSearchTerms(*default_t_url_, UTF16ToWide(term), - 0, std::wstring()))); + 0, std::wstring())); ASSERT_TRUE(fetcher->original_url() == expected_url); // Tell the SearchProvider the suggest query is done. @@ -243,9 +243,9 @@ TEST_F(SearchProviderTest, QueryKeywordProvider) { ASSERT_TRUE(keyword_fetcher); // And the URL matches what we expected. - GURL expected_url = GURL(WideToUTF8(keyword_t_url_->suggestions_url()-> + GURL expected_url = GURL(keyword_t_url_->suggestions_url()-> ReplaceSearchTerms(*keyword_t_url_, UTF16ToWide(term), 0, - std::wstring()))); + std::wstring())); ASSERT_TRUE(keyword_fetcher->original_url() == expected_url); // Tell the SearchProvider the keyword suggest query is done. |