summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-19 18:32:30 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-19 18:32:30 +0000
commit400b133f204e817bb87e357cf2cb02056f8eb0a4 (patch)
tree7e7165352b123dc93482562e04c37131f84ae3f8
parent3705f8e68cb154810dba9f9e05b3f9fb2a9155b5 (diff)
downloadchromium_src-400b133f204e817bb87e357cf2cb02056f8eb0a4.zip
chromium_src-400b133f204e817bb87e357cf2cb02056f8eb0a4.tar.gz
chromium_src-400b133f204e817bb87e357cf2cb02056f8eb0a4.tar.bz2
Remove wstring from TemplateURL and friends.
Re-landing r71485 (which was reverted in r71500). BUG=23581 TEST=no visible changes; all tests pass Review URL: http://codereview.chromium.org/6278007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71814 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc6
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc11
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc6
-rw-r--r--chrome/browser/autocomplete/keyword_provider.cc48
-rw-r--r--chrome/browser/autocomplete/keyword_provider_unittest.cc27
-rw-r--r--chrome/browser/autocomplete/search_provider.cc15
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc25
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc16
-rw-r--r--chrome/browser/dom_ui/options/browser_options_handler.cc4
-rw-r--r--chrome/browser/dom_ui/options/search_engine_manager_handler.cc4
-rw-r--r--chrome/browser/extensions/extension_omnibox_apitest.cc4
-rw-r--r--chrome/browser/importer/firefox2_importer.cc8
-rw-r--r--chrome/browser/importer/firefox_importer_utils.cc4
-rw-r--r--chrome/browser/importer/importer_messages.h16
-rw-r--r--chrome/browser/importer/importer_unittest.cc14
-rw-r--r--chrome/browser/importer/profile_writer.cc6
-rw-r--r--chrome/browser/instant/instant_browsertest.cc6
-rw-r--r--chrome/browser/instant/instant_loader.cc4
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store.cc4
-rw-r--r--chrome/browser/search_engines/edit_search_engine_controller.cc18
-rw-r--r--chrome/browser/search_engines/keyword_editor_controller.cc10
-rw-r--r--chrome/browser/search_engines/keyword_editor_controller_unittest.cc26
-rw-r--r--chrome/browser/search_engines/search_provider_install_data.cc6
-rw-r--r--chrome/browser/search_engines/search_provider_install_data_unittest.cc19
-rw-r--r--chrome/browser/search_engines/search_terms_data.cc10
-rw-r--r--chrome/browser/search_engines/search_terms_data.h7
-rw-r--r--chrome/browser/search_engines/template_url.cc80
-rw-r--r--chrome/browser/search_engines/template_url.h50
-rw-r--r--chrome/browser/search_engines/template_url_fetcher.cc18
-rw-r--r--chrome/browser/search_engines/template_url_fetcher.h5
-rw-r--r--chrome/browser/search_engines/template_url_fetcher_unittest.cc46
-rw-r--r--chrome/browser/search_engines/template_url_model.cc85
-rw-r--r--chrome/browser/search_engines/template_url_model.h33
-rw-r--r--chrome/browser/search_engines/template_url_model_test_util.cc12
-rw-r--r--chrome/browser/search_engines/template_url_model_test_util.h5
-rw-r--r--chrome/browser/search_engines/template_url_model_unittest.cc255
-rw-r--r--chrome/browser/search_engines/template_url_parser.cc35
-rw-r--r--chrome/browser/search_engines/template_url_parser_unittest.cc17
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc6
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc7
-rw-r--r--chrome/browser/search_engines/template_url_table_model.cc9
-rw-r--r--chrome/browser/search_engines/template_url_unittest.cc127
-rw-r--r--chrome/browser/search_engines/util.cc5
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc4
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/ui/browser_init.cc6
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm14
-rw-r--r--chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller.mm6
-rw-r--r--chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller_unittest.mm9
-rw-r--r--chrome/browser/ui/cocoa/options/keyword_editor_cocoa_controller_unittest.mm19
-rw-r--r--chrome/browser/ui/cocoa/options/search_engine_list_model.mm2
-rw-r--r--chrome/browser/ui/cocoa/options/search_engine_list_model_unittest.mm31
-rw-r--r--chrome/browser/ui/cocoa/search_engine_dialog_controller.mm6
-rw-r--r--chrome/browser/ui/gtk/edit_search_engine_dialog.cc6
-rw-r--r--chrome/browser/ui/gtk/first_run_dialog.cc2
-rw-r--r--chrome/browser/ui/gtk/keyword_editor_view_unittest.cc4
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc18
-rw-r--r--chrome/browser/ui/gtk/options/general_page_gtk.cc2
-rw-r--r--chrome/browser/ui/omnibox/location_bar_util.cc7
-rw-r--r--chrome/browser/ui/views/location_bar/keyword_hint_view.cc6
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc3
-rw-r--r--chrome/browser/ui/views/location_bar/selected_keyword_view.cc4
-rw-r--r--chrome/browser/webdata/web_database.cc16
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc16
-rw-r--r--net/base/escape.cc8
-rw-r--r--net/base/escape.h6
-rw-r--r--net/base/escape_unittest.cc14
68 files changed, 687 insertions, 647 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index 5bf0c21..9b03855 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -400,7 +400,7 @@ void AutocompleteEditModel::OpenURL(const GURL& url,
TemplateURLModel* template_url_model = profile_->GetTemplateURLModel();
if (template_url_model && !keyword.empty()) {
const TemplateURL* const template_url =
- template_url_model->GetTemplateURLForKeyword(keyword);
+ template_url_model->GetTemplateURLForKeyword(WideToUTF16Hack(keyword));
// Special case for extension keywords. Don't increment usage count for
// these.
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
index a4e1638..539760a 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -224,8 +224,8 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
TemplateURL* template_url = new TemplateURL();
template_url->SetURL(kSearchURL, 0, 0);
- template_url->set_keyword(UTF8ToWide(kSearchKeyword));
- template_url->set_short_name(UTF8ToWide(kSearchShortName));
+ template_url->set_keyword(UTF8ToUTF16(kSearchKeyword));
+ template_url->set_short_name(UTF8ToUTF16(kSearchShortName));
model->Add(template_url);
model->SetDefaultSearchProvider(template_url);
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index 8af3572..beb80c3 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,7 @@
#include "unicode/ubidi.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
@@ -207,7 +208,7 @@ bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
// If the current match is a keyword, return that as the selected keyword.
if (TemplateURL::SupportsReplacement(match.template_url)) {
- keyword->assign(match.template_url->keyword());
+ keyword->assign(UTF16ToWideHack(match.template_url->keyword()));
return false;
}
@@ -215,8 +216,8 @@ bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
if (!profile_->GetTemplateURLModel())
return false;
profile_->GetTemplateURLModel()->Load();
- const std::wstring keyword_hint(
- TemplateURLModel::CleanUserInputKeyword(match.fill_into_edit));
+ const string16 keyword_hint(TemplateURLModel::CleanUserInputKeyword(
+ WideToUTF16Hack(match.fill_into_edit)));
if (keyword_hint.empty())
return false;
@@ -236,7 +237,7 @@ bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
return false;
}
- keyword->assign(keyword_hint);
+ keyword->assign(UTF16ToWideHack(keyword_hint));
return true;
}
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index fc6c402..f40fb4d 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -177,8 +177,8 @@ void AutocompleteProviderTest::
// Create another TemplateURL for KeywordProvider.
TemplateURL* keyword_t_url = new TemplateURL();
- keyword_t_url->set_short_name(L"k");
- keyword_t_url->set_keyword(L"k");
+ keyword_t_url->set_short_name(ASCIIToUTF16("k"));
+ keyword_t_url->set_keyword(ASCIIToUTF16("k"));
keyword_t_url->SetURL("http://keyword/{searchTerms}", 0, 0);
profile_.GetTemplateURLModel()->Add(keyword_t_url);
ASSERT_NE(0, keyword_t_url->id());
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index a1be35a..2225456 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -91,8 +91,8 @@ class CompareQuality {
// probably better rankings than the fraction of the keyword typed. We should
// always put any exact matches first no matter what, since the code in
// Start() assumes this (and it makes sense).
- bool operator()(const std::wstring& keyword1,
- const std::wstring& keyword2) const {
+ bool operator()(const string16& keyword1,
+ const string16& keyword2) const {
return keyword1.length() < keyword2.length();
}
};
@@ -121,7 +121,8 @@ const TemplateURL* KeywordProvider::GetSubstitutingTemplateURLForInput(
DCHECK(model);
model->Load();
- const TemplateURL* template_url = model->GetTemplateURLForKeyword(keyword);
+ const TemplateURL* template_url =
+ model->GetTemplateURLForKeyword(WideToUTF16Hack(keyword));
return TemplateURL::SupportsReplacement(template_url) ? template_url : NULL;
}
@@ -174,13 +175,14 @@ void KeywordProvider::Start(const AutocompleteInput& input,
// TODO(pkasting): http://b/893701 We should remember the user's use of a
// search query both from the autocomplete popup and from web pages
// themselves.
- std::vector<std::wstring> keyword_matches;
- model->FindMatchingKeywords(keyword, !remaining_input.empty(),
+ std::vector<string16> keyword_matches;
+ model->FindMatchingKeywords(WideToUTF16Hack(keyword),
+ !remaining_input.empty(),
&keyword_matches);
// Prune any extension keywords that are disallowed in incognito mode (if
// we're incognito), or disabled.
- for (std::vector<std::wstring>::iterator i(keyword_matches.begin());
+ for (std::vector<string16>::iterator i(keyword_matches.begin());
i != keyword_matches.end(); ) {
const TemplateURL* template_url(model->GetTemplateURLForKeyword(*i));
if (profile_ &&
@@ -205,8 +207,9 @@ void KeywordProvider::Start(const AutocompleteInput& input,
// in the autocomplete popup.
// Any exact match is going to be the highest quality match, and thus at the
// front of our vector.
- if (keyword_matches.front() == keyword) {
- const TemplateURL* template_url(model->GetTemplateURLForKeyword(keyword));
+ if (keyword_matches.front() == WideToUTF16Hack(keyword)) {
+ const TemplateURL* template_url(
+ model->GetTemplateURLForKeyword(WideToUTF16Hack(keyword)));
// TODO(pkasting): We should probably check that if the user explicitly
// typed a scheme, that scheme matches the one in |template_url|.
matches_.push_back(CreateAutocompleteMatch(model, keyword, input,
@@ -252,10 +255,10 @@ void KeywordProvider::Start(const AutocompleteInput& input,
keyword_matches.erase(keyword_matches.begin() + kMaxMatches,
keyword_matches.end());
}
- for (std::vector<std::wstring>::const_iterator i(keyword_matches.begin());
+ for (std::vector<string16>::const_iterator i(keyword_matches.begin());
i != keyword_matches.end(); ++i) {
- matches_.push_back(CreateAutocompleteMatch(model, *i, input,
- keyword.length(),
+ matches_.push_back(CreateAutocompleteMatch(model, UTF16ToWideHack(*i),
+ input, keyword.length(),
remaining_input, -1));
}
}
@@ -276,8 +279,9 @@ bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
(input.type() == AutocompleteInput::FORCED_QUERY))
return false;
- *keyword = TemplateURLModel::CleanUserInputKeyword(
- SplitKeywordFromInput(input.text(), true, remaining_input));
+ *keyword =
+ UTF16ToWideHack(TemplateURLModel::CleanUserInputKeyword(WideToUTF16Hack(
+ SplitKeywordFromInput(input.text(), true, remaining_input))));
return !keyword->empty();
}
@@ -324,14 +328,14 @@ void KeywordProvider::FillInURLAndContents(
// No query input; return a generic, no-destination placeholder.
match->contents.assign(UTF16ToWideHack(
l10n_util::GetStringFUTF16(message_id,
- WideToUTF16Hack(element->AdjustedShortNameForLocaleDirection()),
+ element->AdjustedShortNameForLocaleDirection(),
l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE))));
match->contents_class.push_back(
ACMatchClassification(0, ACMatchClassification::DIM));
} else {
// Keyword that has no replacement text (aka a shorthand for a URL).
match->destination_url = GURL(element->url()->url());
- match->contents.assign(element->short_name());
+ match->contents.assign(UTF16ToWideHack(element->short_name()));
AutocompleteMatch::ClassifyLocationInString(0, match->contents.length(),
match->contents.length(), ACMatchClassification::NONE,
&match->contents_class);
@@ -343,12 +347,12 @@ void KeywordProvider::FillInURLAndContents(
// fixup to make the URL valid if necessary.
DCHECK(element->url()->SupportsReplacement());
match->destination_url = GURL(element->url()->ReplaceSearchTerms(
- *element, remaining_input, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
- std::wstring()));
+ *element, WideToUTF16Hack(remaining_input),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
std::vector<size_t> content_param_offsets;
match->contents.assign(UTF16ToWideHack(
l10n_util::GetStringFUTF16(message_id,
- WideToUTF16Hack(element->short_name()),
+ element->short_name(),
WideToUTF16Hack(remaining_input),
&content_param_offsets)));
if (content_param_offsets.size() == 2) {
@@ -385,7 +389,8 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
int relevance) {
DCHECK(model);
// Get keyword data from data store.
- const TemplateURL* element(model->GetTemplateURLForKeyword(keyword));
+ const TemplateURL* element(
+ model->GetTemplateURLForKeyword(WideToUTF16Hack(keyword)));
DCHECK(element && element->url());
const bool supports_replacement = element->url()->SupportsReplacement();
@@ -462,7 +467,8 @@ void KeywordProvider::Observe(NotificationType type,
!ExtractKeywordFromInput(input, &keyword, &remaining_input))
return;
- const TemplateURL* template_url(model->GetTemplateURLForKeyword(keyword));
+ const TemplateURL* template_url(
+ model->GetTemplateURLForKeyword(WideToUTF16Hack(keyword)));
ApplyDefaultSuggestionForExtensionKeyword(profile_, template_url,
WideToUTF16(remaining_input),
&matches_[0]);
diff --git a/chrome/browser/autocomplete/keyword_provider_unittest.cc b/chrome/browser/autocomplete/keyword_provider_unittest.cc
index 165662e..9feee61 100644
--- a/chrome/browser/autocomplete/keyword_provider_unittest.cc
+++ b/chrome/browser/autocomplete/keyword_provider_unittest.cc
@@ -1,8 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/message_loop.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/keyword_provider.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -37,13 +38,13 @@ class KeywordProviderTest : public testing::Test {
void KeywordProviderTest::SetUp() {
static const TemplateURLModel::Initializer kTestKeywordData[] = {
- { 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" },
+ { "aa", "aa.com?foo=%s", "aa" },
+ { "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" },
+ { "aaaaa", "%s", "aaaaa" },
+ { "ab", "bogus URL %s", "ab" },
+ { "weasel", "weasel%sweasel", "weasel" },
+ { "www", " +%2B?=%sfoo ", "www" },
+ { "z", "%s=z", "z" },
};
model_.reset(new TemplateURLModel(kTestKeywordData,
@@ -184,17 +185,17 @@ TEST_F(KeywordProviderTest, Description) {
TEST_F(KeywordProviderTest, AddKeyword) {
TemplateURL* template_url = new TemplateURL();
- std::wstring keyword(L"foo");
+ string16 keyword(ASCIIToUTF16("foo"));
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");
+ template_url->set_short_name(ASCIIToUTF16("Test"));
model_->Add(template_url);
ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword));
}
TEST_F(KeywordProviderTest, RemoveKeyword) {
- std::wstring url(L"http://aaaa/?aaaa=1&b={searchTerms}&c");
- model_->Remove(model_->GetTemplateURLForKeyword(L"aaaa"));
- ASSERT_TRUE(model_->GetTemplateURLForKeyword(L"aaaa") == NULL);
+ string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c"));
+ model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")));
+ ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL);
}
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 2b308a3..fa162d3 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -417,8 +417,8 @@ URLFetcher* SearchProvider::CreateSuggestFetcher(int id,
DCHECK(suggestions_url->SupportsReplacement());
URLFetcher* fetcher = URLFetcher::Create(id,
GURL(suggestions_url->ReplaceSearchTerms(
- provider, text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
- std::wstring())),
+ provider, WideToUTF16Hack(text),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())),
URLFetcher::GET, this);
fetcher->set_request_context(profile_->GetRequestContext());
fetcher->Start();
@@ -778,7 +778,8 @@ void SearchProvider::AddMatchToMap(const std::wstring& query_string,
++search_start;
}
if (is_keyword) {
- match.fill_into_edit.append(providers_.keyword_provider().keyword() + L" ");
+ match.fill_into_edit.append(UTF16ToWideHack(
+ providers_.keyword_provider().keyword() + char16(' ')));
match.template_url = &providers_.keyword_provider();
}
match.fill_into_edit.append(query_string);
@@ -792,9 +793,9 @@ void SearchProvider::AddMatchToMap(const std::wstring& query_string,
DCHECK(search_url->SupportsReplacement());
match.destination_url =
GURL(search_url->ReplaceSearchTerms(provider,
- query_string,
+ WideToUTF16Hack(query_string),
accepted_suggestion,
- input_text));
+ WideToUTF16Hack(input_text)));
// Search results don't look like URLs.
match.transition =
@@ -872,8 +873,8 @@ void SearchProvider::UpdateFirstSearchMatchDescription() {
match.description.assign(
UTF16ToWideHack(l10n_util::GetStringFUTF16(
IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION,
- WideToUTF16Hack(providers_.default_provider().
- AdjustedShortNameForLocaleDirection()))));
+ providers_.default_provider().
+ AdjustedShortNameForLocaleDirection())));
match.description_class.push_back(
ACMatchClassification(0, ACMatchClassification::DIM));
// Only the first search match gets a description.
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index bf74e5f..0e7ac57 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -116,7 +116,7 @@ void SearchProviderTest::SetUp() {
HistoryService* history =
profile_.GetHistoryService(Profile::EXPLICIT_ACCESS);
term1_url_ = GURL(default_t_url_->url()->ReplaceSearchTerms(
- *default_t_url_, UTF16ToWide(term1_), 0, std::wstring()));
+ *default_t_url_, term1_, 0, string16()));
history->AddPageWithDetails(term1_url_, string16(), 1, 1,
base::Time::Now(), false,
history::SOURCE_BROWSED);
@@ -125,7 +125,7 @@ void SearchProviderTest::SetUp() {
// Create another TemplateURL.
keyword_t_url_ = new TemplateURL();
- keyword_t_url_->set_keyword(L"k");
+ keyword_t_url_->set_keyword(ASCIIToUTF16("k"));
keyword_t_url_->SetURL("http://keyword/{searchTerms}", 0, 0);
keyword_t_url_->SetSuggestionsURL("http://suggest_keyword/{searchTerms}", 0,
0);
@@ -134,7 +134,7 @@ void SearchProviderTest::SetUp() {
// Add a page and search term for keyword_t_url_.
keyword_url_ = GURL(keyword_t_url_->url()->ReplaceSearchTerms(
- *keyword_t_url_, UTF16ToWide(keyword_term_), 0, std::wstring()));
+ *keyword_t_url_, keyword_term_, 0, string16()));
history->AddPageWithDetails(keyword_url_, string16(), 1, 1,
base::Time::Now(), false,
history::SOURCE_BROWSED);
@@ -227,8 +227,7 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) {
// And the URL matches what we expected.
GURL expected_url = GURL(default_t_url_->suggestions_url()->
- ReplaceSearchTerms(*default_t_url_, UTF16ToWide(term),
- 0, std::wstring()));
+ ReplaceSearchTerms(*default_t_url_, term, 0, string16()));
ASSERT_TRUE(fetcher->original_url() == expected_url);
// Tell the SearchProvider the suggest query is done.
@@ -248,7 +247,7 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) {
EXPECT_FALSE(term1_match.description.empty());
GURL what_you_typed_url = GURL(default_t_url_->url()->ReplaceSearchTerms(
- *default_t_url_, UTF16ToWide(term), 0, std::wstring()));
+ *default_t_url_, term, 0, string16()));
AutocompleteMatch what_you_typed_match =
FindMatchWithDestination(what_you_typed_url);
EXPECT_TRUE(!what_you_typed_match.destination_url.is_empty());
@@ -271,7 +270,7 @@ TEST_F(SearchProviderTest, HonorPreventInlineAutocomplete) {
// is queried as well as URLFetchers getting created.
TEST_F(SearchProviderTest, QueryKeywordProvider) {
string16 term = keyword_term_.substr(0, keyword_term_.size() - 1);
- QueryForInput(WideToUTF16(keyword_t_url_->keyword()) +
+ QueryForInput(keyword_t_url_->keyword() +
UTF8ToUTF16(" ") + term, false);
// Make sure the default providers suggest service was queried.
@@ -292,8 +291,7 @@ TEST_F(SearchProviderTest, QueryKeywordProvider) {
// And the URL matches what we expected.
GURL expected_url = GURL(keyword_t_url_->suggestions_url()->
- ReplaceSearchTerms(*keyword_t_url_, UTF16ToWide(term), 0,
- std::wstring()));
+ ReplaceSearchTerms(*keyword_t_url_, term, 0, string16()));
ASSERT_TRUE(keyword_fetcher->original_url() == expected_url);
// Tell the SearchProvider the keyword suggest query is done.
@@ -314,7 +312,8 @@ TEST_F(SearchProviderTest, QueryKeywordProvider) {
EXPECT_TRUE(match.template_url);
// The fill into edit should contain the keyword.
- EXPECT_EQ(keyword_t_url_->keyword() + L" " + UTF16ToWide(keyword_term_),
+ EXPECT_EQ(UTF16ToWideHack(keyword_t_url_->keyword()) +
+ L" " + UTF16ToWide(keyword_term_),
match.fill_into_edit);
}
@@ -370,7 +369,7 @@ TEST_F(SearchProviderTest, FinalizeInstantQuery) {
// 'foobar'.
EXPECT_EQ(2u, provider_->matches().size());
GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms(
- *default_t_url_, L"foobar", 0, std::wstring()));
+ *default_t_url_, ASCIIToUTF16("foobar"), 0, string16()));
AutocompleteMatch instant_match = FindMatchWithDestination(instant_url);
EXPECT_TRUE(!instant_match.destination_url.is_empty());
@@ -379,7 +378,7 @@ TEST_F(SearchProviderTest, FinalizeInstantQuery) {
// Make sure the what you typed match has no description.
GURL what_you_typed_url = GURL(default_t_url_->url()->ReplaceSearchTerms(
- *default_t_url_, L"foo", 0, std::wstring()));
+ *default_t_url_, ASCIIToUTF16("foo"), 0, string16()));
AutocompleteMatch what_you_typed_match =
FindMatchWithDestination(what_you_typed_url);
EXPECT_TRUE(!what_you_typed_match.destination_url.is_empty());
@@ -404,7 +403,7 @@ TEST_F(SearchProviderTest, RememberInstantQuery) {
// 'foobar'.
EXPECT_EQ(2u, provider_->matches().size());
GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms(
- *default_t_url_, L"foobar", 0, std::wstring()));
+ *default_t_url_, ASCIIToUTF16("foobar"), 0, string16()));
AutocompleteMatch instant_match = FindMatchWithDestination(instant_url);
EXPECT_FALSE(instant_match.destination_url.is_empty());
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 4b2f0aa..e67bb35 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -2687,9 +2687,9 @@ void TestingAutomationProvider::GetSearchEngineInfo(
for (std::vector<const TemplateURL*>::const_iterator it =
template_urls.begin(); it != template_urls.end(); ++it) {
DictionaryValue* search_engine = new DictionaryValue;
- search_engine->SetString("short_name", WideToUTF8((*it)->short_name()));
- search_engine->SetString("description", WideToUTF8((*it)->description()));
- search_engine->SetString("keyword", WideToUTF8((*it)->keyword()));
+ search_engine->SetString("short_name", UTF16ToUTF8((*it)->short_name()));
+ search_engine->SetString("description", UTF16ToUTF8((*it)->description()));
+ search_engine->SetString("keyword", UTF16ToUTF8((*it)->keyword()));
search_engine->SetBoolean("in_default_list", (*it)->ShowInDefaultList());
search_engine->SetBoolean("is_default",
(*it) == url_model->GetDefaultSearchProvider());
@@ -2700,7 +2700,7 @@ void TestingAutomationProvider::GetSearchEngineInfo(
search_engine->SetString("host", (*it)->url()->GetHost());
search_engine->SetString("path", (*it)->url()->GetPath());
search_engine->SetString("display_url",
- WideToUTF8((*it)->url()->DisplayURL()));
+ UTF16ToUTF8((*it)->url()->DisplayURL()));
search_engines->Append(search_engine);
}
return_value->Set("search_engines", search_engines);
@@ -2726,11 +2726,11 @@ void TestingAutomationProvider::AddOrEditSearchEngine(
return;
}
std::string new_ref_url = TemplateURLRef::DisplayURLToURLRef(
- UTF8ToWide(new_url));
+ UTF8ToUTF16(new_url));
scoped_ptr<KeywordEditorController> controller(
new KeywordEditorController(profile_));
if (args->GetString("keyword", &keyword)) {
- template_url = url_model->GetTemplateURLForKeyword(UTF8ToWide(keyword));
+ template_url = url_model->GetTemplateURLForKeyword(UTF8ToUTF16(keyword));
if (template_url == NULL) {
AutomationJSONReply(this, reply_message).SendError(
StringPrintf("No match for keyword: %s", keyword.c_str()));
@@ -2763,7 +2763,7 @@ void TestingAutomationProvider::PerformActionOnSearchEngine(
return;
}
const TemplateURL* template_url(
- url_model->GetTemplateURLForKeyword(UTF8ToWide(keyword)));
+ url_model->GetTemplateURLForKeyword(UTF8ToUTF16(keyword)));
if (template_url == NULL) {
AutomationJSONReply(this, reply_message).SendError(
StringPrintf("No match for keyword: %s", keyword.c_str()));
diff --git a/chrome/browser/dom_ui/options/browser_options_handler.cc b/chrome/browser/dom_ui/options/browser_options_handler.cc
index e83b408..1f227ff 100644
--- a/chrome/browser/dom_ui/options/browser_options_handler.cc
+++ b/chrome/browser/dom_ui/options/browser_options_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -229,7 +229,7 @@ void BrowserOptionsHandler::OnTemplateURLModelChanged() {
continue;
DictionaryValue* entry = new DictionaryValue();
- entry->SetString("name", WideToUTF16Hack(model_urls[i]->short_name()));
+ entry->SetString("name", model_urls[i]->short_name());
entry->SetInteger("index", i);
search_engines.Append(entry);
if (model_urls[i] == default_url)
diff --git a/chrome/browser/dom_ui/options/search_engine_manager_handler.cc b/chrome/browser/dom_ui/options/search_engine_manager_handler.cc
index 5291c37..de4856c 100644
--- a/chrome/browser/dom_ui/options/search_engine_manager_handler.cc
+++ b/chrome/browser/dom_ui/options/search_engine_manager_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -158,7 +158,7 @@ DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine(
dict->SetString("keyword", table_model->GetText(
index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN));
const TemplateURL* template_url = list_controller_->GetTemplateURL(index);
- dict->SetString("url", WideToUTF16Hack(template_url->url()->DisplayURL()));
+ dict->SetString("url", template_url->url()->DisplayURL());
dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0);
GURL icon_url = template_url->GetFavIconURL();
if (icon_url.is_valid())
diff --git a/chrome/browser/extensions/extension_omnibox_apitest.cc b/chrome/browser/extensions/extension_omnibox_apitest.cc
index 7778a8c..f2a4ce2 100644
--- a/chrome/browser/extensions/extension_omnibox_apitest.cc
+++ b/chrome/browser/extensions/extension_omnibox_apitest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -108,7 +108,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) {
match = result.match_at(1);
ASSERT_TRUE(match.template_url);
EXPECT_TRUE(match.template_url->IsExtensionKeyword());
- EXPECT_EQ(L"keyword", match.template_url->keyword());
+ EXPECT_EQ(ASCIIToUTF16("keyword"), match.template_url->keyword());
}
// Test that our extension can send suggestions back to us.
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc
index 7783a7c..59f9ff2 100644
--- a/chrome/browser/importer/firefox2_importer.cc
+++ b/chrome/browser/importer/firefox2_importer.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -140,9 +140,9 @@ 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(!title.empty() ? title : keyword);
- t_url->set_keyword(keyword);
- t_url->SetURL(TemplateURLRef::DisplayURLToURLRef(UTF8ToWide(url.spec())),
+ t_url->set_short_name(WideToUTF16Hack(!title.empty() ? title : keyword));
+ t_url->set_keyword(WideToUTF16Hack(keyword));
+ t_url->SetURL(TemplateURLRef::DisplayURLToURLRef(UTF8ToUTF16(url.spec())),
0, 0);
return t_url;
}
diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc
index be606ff..3ff88f2 100644
--- a/chrome/browser/importer/firefox_importer_utils.cc
+++ b/chrome/browser/importer/firefox_importer_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -312,7 +312,7 @@ int GetFirefoxDefaultSearchEngineIndex(
int default_se_index = -1;
for (std::vector<TemplateURL*>::const_iterator iter = search_engines.begin();
iter != search_engines.end(); ++iter) {
- if (default_se_name == WideToUTF8((*iter)->short_name())) {
+ if (default_se_name == UTF16ToUTF8((*iter)->short_name())) {
default_se_index = static_cast<int>(iter - search_engines.begin());
break;
}
diff --git a/chrome/browser/importer/importer_messages.h b/chrome/browser/importer/importer_messages.h
index e05aac8..ac63526 100644
--- a/chrome/browser/importer/importer_messages.h
+++ b/chrome/browser/importer/importer_messages.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -222,7 +222,7 @@ struct ParamTraits<TemplateURL::ImageRef> {
WriteParam(m, p.url);
}
static bool Read(const Message* m, void** iter, param_type* p) {
- std::wstring type;
+ std::string type;
int width;
int height;
GURL url;
@@ -275,17 +275,17 @@ struct ParamTraits<TemplateURL> {
WriteParam(m, p.prepopulate_id());
}
static bool Read(const Message* m, void** iter, param_type* p) {
- std::wstring short_name;
- std::wstring description;
+ string16 short_name;
+ string16 description;
bool includes_suggestions_url;
TemplateURLRef suggestions_url;
TemplateURLRef url;
GURL originating_url;
- std::wstring keyword;
+ string16 keyword;
bool autogenerate_keyword;
bool show_in_default_list;
bool safe_for_autoreplace;
- std::vector<std::wstring> languages;
+ std::vector<string16> languages;
std::vector<std::string> input_encodings;
base::Time date_created;
int usage_count;
@@ -314,7 +314,7 @@ struct ParamTraits<TemplateURL> {
*p = TemplateURL();
for (size_t i = 0; i < image_refs_size; ++i) {
- std::wstring type;
+ std::string type;
int width;
int height;
GURL url;
@@ -344,7 +344,7 @@ struct ParamTraits<TemplateURL> {
p->set_show_in_default_list(show_in_default_list);
p->set_safe_for_autoreplace(safe_for_autoreplace);
- std::vector<std::wstring>::const_iterator lang_iter;
+ std::vector<string16>::const_iterator lang_iter;
for (lang_iter = languages.begin();
lang_iter != languages.end();
++lang_iter) {
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index 595a3d7..2117619 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -637,9 +637,10 @@ class FirefoxObserver : public ProfileWriter,
// The order might not be deterministic, look in the expected list for
// that template URL.
bool found = false;
- std::wstring keyword = template_urls[i]->keyword();
+ string16 keyword = template_urls[i]->keyword();
for (size_t j = 0; j < arraysize(kFirefox2Keywords); ++j) {
- if (template_urls[i]->keyword() == kFirefox2Keywords[j].keyword) {
+ if (template_urls[i]->keyword() ==
+ WideToUTF16Hack(kFirefox2Keywords[j].keyword)) {
EXPECT_EQ(kFirefox2Keywords[j].url, template_urls[i]->url()->url());
found = true;
break;
@@ -652,7 +653,7 @@ class FirefoxObserver : public ProfileWriter,
if (default_keyword_index != -1) {
EXPECT_LT(default_keyword_index, static_cast<int>(template_urls.size()));
TemplateURL* default_turl = template_urls[default_keyword_index];
- default_keyword_ = default_turl->keyword();
+ default_keyword_ = UTF16ToWideHack(default_turl->keyword());
default_keyword_url_ = default_turl->url()->url();
}
@@ -844,9 +845,10 @@ class Firefox3Observer : public ProfileWriter,
// The order might not be deterministic, look in the expected list for
// that template URL.
bool found = false;
- std::wstring keyword = template_urls[i]->keyword();
+ string16 keyword = template_urls[i]->keyword();
for (size_t j = 0; j < arraysize(kFirefox3Keywords); ++j) {
- if (template_urls[i]->keyword() == kFirefox3Keywords[j].keyword) {
+ if (template_urls[i]->keyword() ==
+ WideToUTF16Hack(kFirefox3Keywords[j].keyword)) {
EXPECT_EQ(kFirefox3Keywords[j].url, template_urls[i]->url()->url());
found = true;
break;
@@ -859,7 +861,7 @@ class Firefox3Observer : public ProfileWriter,
if (default_keyword_index != -1) {
EXPECT_LT(default_keyword_index, static_cast<int>(template_urls.size()));
TemplateURL* default_turl = template_urls[default_keyword_index];
- default_keyword_ = default_turl->keyword();
+ default_keyword_ = UTF16ToWideHack(default_turl->keyword());
default_keyword_url_ = default_turl->url()->url();
}
diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc
index 00e8dcf..e6eefdf 100644
--- a/chrome/browser/importer/profile_writer.cc
+++ b/chrome/browser/importer/profile_writer.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -181,8 +181,8 @@ static std::string BuildHostPathKey(const TemplateURL* t_url,
if (t_url->url()->SupportsReplacement()) {
return HostPathKeyForURL(GURL(
t_url->url()->ReplaceSearchTerms(
- *t_url, L"random string",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())));
+ *t_url, ASCIIToUTF16("random string"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())));
}
}
return std::string();
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index 86c3e52..0f296c5 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -58,8 +58,8 @@ class InstantTest : public InProcessBrowserTest {
page.c_str());
template_url->SetURL(url, 0, 0);
template_url->SetInstantURL(url, 0, 0);
- template_url->set_keyword(UTF8ToWide("foo"));
- template_url->set_short_name(UTF8ToWide("foo"));
+ template_url->set_keyword(ASCIIToUTF16("foo"));
+ template_url->set_short_name(ASCIIToUTF16("foo"));
model->Add(template_url);
model->SetDefaultSearchProvider(template_url);
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index d337df5..e2223af 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -508,7 +508,7 @@ void InstantLoader::Update(TabContentsWrapper* tab_contents,
// TODO(sky): having to use a replaceable url is a bit of a hack here.
GURL instant_url(
template_url->instant_url()->ReplaceSearchTerms(
- *template_url, std::wstring(), -1, std::wstring()));
+ *template_url, string16(), -1, string16()));
CommandLine* cl = CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kInstantURL))
instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL));
diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc
index 80e0dea..2d4ab5f 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store.cc
@@ -426,8 +426,8 @@ class SearchTermsDataForValidation : public SearchTermsData {
return "en";
}
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- virtual std::wstring GetRlzParameterValue() const {
- return std::wstring();
+ virtual string16 GetRlzParameterValue() const {
+ return string16();
}
#endif
private:
diff --git a/chrome/browser/search_engines/edit_search_engine_controller.cc b/chrome/browser/search_engines/edit_search_engine_controller.cc
index b2b6a6d..10c02ef 100644
--- a/chrome/browser/search_engines/edit_search_engine_controller.cc
+++ b/chrome/browser/search_engines/edit_search_engine_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -51,8 +51,8 @@ bool EditSearchEngineController::IsURLValid(
// If the url has a search term, replace it with a random string and make
// sure the resulting URL is valid. We don't check the validity of the url
// with the search term as that is not necessarily valid.
- return GURL(template_ref.ReplaceSearchTerms(TemplateURL(), L"a",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())).is_valid();
+ return GURL(template_ref.ReplaceSearchTerms(TemplateURL(), ASCIIToUTF16("a"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())).is_valid();
}
bool EditSearchEngineController::IsKeywordValid(
@@ -62,7 +62,7 @@ bool EditSearchEngineController::IsKeywordValid(
return false; // Do not allow empty keyword.
const TemplateURL* turl_with_keyword =
profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
- UTF16ToWideHack(keyword_input_trimmed));
+ keyword_input_trimmed);
return (turl_with_keyword == NULL || turl_with_keyword == template_url_);
}
@@ -75,7 +75,7 @@ void EditSearchEngineController::AcceptAddOrEdit(
const TemplateURL* existing =
profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
- UTF16ToWideHack(keyword_input));
+ keyword_input);
if (existing &&
(!edit_keyword_delegate_ || existing != template_url_)) {
// An entry may have been added with the same keyword string while the
@@ -96,8 +96,8 @@ void EditSearchEngineController::AcceptAddOrEdit(
// does in a similar situation (updating an existing TemplateURL with
// data from a new one).
TemplateURL* modifiable_url = const_cast<TemplateURL*>(template_url_);
- modifiable_url->set_short_name(UTF16ToWideHack(title_input));
- modifiable_url->set_keyword(UTF16ToWideHack(keyword_input));
+ modifiable_url->set_short_name(title_input);
+ modifiable_url->set_keyword(keyword_input);
modifiable_url->SetURL(url_string, 0, 0);
// TemplateURLModel takes ownership of template_url_.
profile_->GetTemplateURLModel()->Add(modifiable_url);
@@ -124,7 +124,7 @@ void EditSearchEngineController::CleanUpCancelledAdd() {
std::string EditSearchEngineController::GetFixedUpURL(
const std::string& url_input) const {
std::string url;
- TrimWhitespace(TemplateURLRef::DisplayURLToURLRef(UTF8ToWide(url_input)),
+ TrimWhitespace(TemplateURLRef::DisplayURLToURLRef(UTF8ToUTF16(url_input)),
TRIM_ALL, &url);
if (url.empty())
return url;
@@ -135,7 +135,7 @@ std::string EditSearchEngineController::GetFixedUpURL(
TemplateURL t_url;
t_url.SetURL(url, 0, 0);
std::string expanded_url =
- t_url.url()->ReplaceSearchTerms(t_url, L"x", 0, std::wstring());
+ t_url.url()->ReplaceSearchTerms(t_url, ASCIIToUTF16("x"), 0, string16());
url_parse::Parsed parts;
std::string scheme(
URLFixerUpper::SegmentURL(expanded_url, &parts));
diff --git a/chrome/browser/search_engines/keyword_editor_controller.cc b/chrome/browser/search_engines/keyword_editor_controller.cc
index b7d2c5e..349d469 100644
--- a/chrome/browser/search_engines/keyword_editor_controller.cc
+++ b/chrome/browser/search_engines/keyword_editor_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -37,8 +37,8 @@ int KeywordEditorController::AddTemplateURL(const string16& title,
profile_);
TemplateURL* template_url = new TemplateURL();
- template_url->set_short_name(UTF16ToWideHack(title));
- template_url->set_keyword(UTF16ToWideHack(keyword));
+ template_url->set_short_name(title);
+ template_url->set_keyword(keyword);
template_url->SetURL(url, 0, 0);
// There's a bug (1090726) in TableView with groups enabled such that newly
@@ -64,8 +64,8 @@ void KeywordEditorController::ModifyTemplateURL(const TemplateURL* template_url,
}
// Don't do anything if the entry didn't change.
- if (template_url->short_name() == UTF16ToWideHack(title) &&
- template_url->keyword() == UTF16ToWideHack(keyword) &&
+ if (template_url->short_name() == title &&
+ template_url->keyword() == keyword &&
((url.empty() && !template_url->url()) ||
(!url.empty() && template_url->url() &&
template_url->url()->url() == url))) {
diff --git a/chrome/browser/search_engines/keyword_editor_controller_unittest.cc b/chrome/browser/search_engines/keyword_editor_controller_unittest.cc
index e59af22..9ea48ac 100644
--- a/chrome/browser/search_engines/keyword_editor_controller_unittest.cc
+++ b/chrome/browser/search_engines/keyword_editor_controller_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -137,8 +137,8 @@ TEST_F(KeywordEditorControllerTest, Add) {
// Verify the entry is what we added.
const TemplateURL* turl = model_->GetTemplateURLs()[0];
- EXPECT_EQ(L"a", turl->short_name());
- EXPECT_EQ(L"b", turl->keyword());
+ EXPECT_EQ(ASCIIToUTF16("a"), turl->short_name());
+ EXPECT_EQ(ASCIIToUTF16("b"), turl->keyword());
ASSERT_TRUE(turl->url() != NULL);
EXPECT_EQ("http://c", turl->url()->url());
}
@@ -154,8 +154,8 @@ TEST_F(KeywordEditorControllerTest, Modify) {
// Make sure it was updated appropriately.
VerifyChangeCount(0, 1, 0, 0);
- EXPECT_EQ(L"a1", turl->short_name());
- EXPECT_EQ(L"b1", turl->keyword());
+ EXPECT_EQ(ASCIIToUTF16("a1"), turl->short_name());
+ EXPECT_EQ(ASCIIToUTF16("b1"), turl->keyword());
ASSERT_TRUE(turl->url() != NULL);
EXPECT_EQ("http://c1", turl->url()->url());
}
@@ -186,9 +186,11 @@ TEST_F(KeywordEditorControllerTest, CannotSetDefaultWhileManaged) {
controller_->AddTemplateURL(kA1, kB1, "http://d{searchTerms}");
ClearChangeCount();
- const TemplateURL* turl1 = model_->GetTemplateURLForKeyword(L"b");
+ const TemplateURL* turl1 =
+ model_->GetTemplateURLForKeyword(ASCIIToUTF16("b"));
ASSERT_TRUE(turl1 != NULL);
- const TemplateURL* turl2 = model_->GetTemplateURLForKeyword(L"b1");
+ const TemplateURL* turl2 =
+ model_->GetTemplateURLForKeyword(ASCIIToUTF16("b1"));
ASSERT_TRUE(turl2 != NULL);
EXPECT_TRUE(controller_->CanMakeDefault(turl1));
@@ -208,9 +210,11 @@ TEST_F(KeywordEditorControllerTest, EditManagedDefault) {
controller_->AddTemplateURL(kA1, kB1, "http://d{searchTerms}");
ClearChangeCount();
- const TemplateURL* turl1 = model_->GetTemplateURLForKeyword(L"b");
+ const TemplateURL* turl1 =
+ model_->GetTemplateURLForKeyword(ASCIIToUTF16("b"));
ASSERT_TRUE(turl1 != NULL);
- const TemplateURL* turl2 = model_->GetTemplateURLForKeyword(L"b1");
+ const TemplateURL* turl2 =
+ model_->GetTemplateURLForKeyword(ASCIIToUTF16("b1"));
ASSERT_TRUE(turl2 != NULL);
EXPECT_TRUE(controller_->CanEdit(turl1));
@@ -241,8 +245,8 @@ TEST_F(KeywordEditorControllerTest, MakeDefaultNoWebData) {
// appropriately.
TEST_F(KeywordEditorControllerTest, MutateTemplateURLModel) {
TemplateURL* turl = new TemplateURL();
- turl->set_keyword(L"a");
- turl->set_short_name(L"b");
+ turl->set_keyword(ASCIIToUTF16("a"));
+ turl->set_short_name(ASCIIToUTF16("b"));
model_->Add(turl);
// Table model should have updated.
diff --git a/chrome/browser/search_engines/search_provider_install_data.cc b/chrome/browser/search_engines/search_provider_install_data.cc
index 2a32c92..f0ef037 100644
--- a/chrome/browser/search_engines/search_provider_install_data.cc
+++ b/chrome/browser/search_engines/search_provider_install_data.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -36,9 +36,9 @@ class IOThreadSearchTermsData : public SearchTermsData {
virtual std::string GoogleBaseURLValue() const;
virtual std::string GetApplicationLocale() const;
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- virtual std::wstring GetRlzParameterValue() const {
+ virtual string16 GetRlzParameterValue() const {
// This value doesn't matter for our purposes.
- return std::wstring();
+ return string16();
}
#endif
diff --git a/chrome/browser/search_engines/search_provider_install_data_unittest.cc b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
index 28bcd47..f132032 100644
--- a/chrome/browser/search_engines/search_provider_install_data_unittest.cc
+++ b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/task.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/search_engines/search_provider_install_data.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -23,11 +24,11 @@
// Create a TemplateURL. The caller owns the returned TemplateURL*.
static TemplateURL* CreateTemplateURL(const std::string& url,
- const std::wstring& keyword) {
+ const std::string& keyword) {
TemplateURL* t_url = new TemplateURL();
t_url->SetURL(url, 0, 0);
- t_url->set_keyword(keyword);
- t_url->set_short_name(keyword);
+ t_url->set_keyword(UTF8ToUTF16(keyword));
+ t_url->set_short_name(UTF8ToUTF16(keyword));
return t_url;
}
@@ -225,7 +226,7 @@ TEST_F(SearchProviderInstallDataTest, GetInstallState) {
util_.ChangeModelToLoadState();
std::string host = "www.unittest.com";
TemplateURL* t_url = CreateTemplateURL("http://" + host + "/path",
- L"unittest");
+ "unittest");
util_.model()->Add(t_url);
// Wait for the changes to be saved.
@@ -240,7 +241,7 @@ TEST_F(SearchProviderInstallDataTest, GetInstallState) {
// Set-up a default and try it all one more time.
std::string default_host = "www.mmm.com";
TemplateURL* default_url = CreateTemplateURL("http://" + default_host + "/",
- L"mmm");
+ "mmm");
util_.model()->Add(default_url);
util_.model()->SetDefaultSearchProvider(default_url);
test_get_install_state->set_default_search_provider_host(default_host);
@@ -253,7 +254,7 @@ TEST_F(SearchProviderInstallDataTest, ManagedDefaultSearch) {
util_.ChangeModelToLoadState();
std::string host = "www.unittest.com";
TemplateURL* t_url = CreateTemplateURL("http://" + host + "/path",
- L"unittest");
+ "unittest");
util_.model()->Add(t_url);
// Set a managed preference that establishes a default search provider.
@@ -287,10 +288,10 @@ TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
TemplateURLModelTestUtil::BlockTillIOThreadProcessesRequests();
TemplateURL* t_url = CreateTemplateURL("{google:baseURL}?q={searchTerms}",
- L"t");
+ "t");
util_.model()->Add(t_url);
TemplateURL* default_url = CreateTemplateURL("http://d.com/",
- L"d");
+ "d");
util_.model()->Add(default_url);
util_.model()->SetDefaultSearchProvider(default_url);
diff --git a/chrome/browser/search_engines/search_terms_data.cc b/chrome/browser/search_engines/search_terms_data.cc
index 7e5b9ff..7b09df2 100644
--- a/chrome/browser/search_engines/search_terms_data.cc
+++ b/chrome/browser/search_engines/search_terms_data.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -73,14 +73,14 @@ std::string UIThreadSearchTermsData::GetApplicationLocale() const {
}
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
-std::wstring UIThreadSearchTermsData::GetRlzParameterValue() const {
+string16 UIThreadSearchTermsData::GetRlzParameterValue() const {
DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI));
- std::wstring rlz_string;
+ string16 rlz_string;
// For organic brandcodes do not use rlz at all. Empty brandcode usually
// means a chromium install. This is ok.
- std::wstring brand;
- // See http://crbug.com/62337.
+ string16 brand;
+ // See http://crbug.com/62337 .
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (GoogleUpdateSettings::GetBrand(&brand) && !brand.empty() &&
!GoogleUpdateSettings::IsOrganic(brand))
diff --git a/chrome/browser/search_engines/search_terms_data.h b/chrome/browser/search_engines/search_terms_data.h
index 41807c3..a695a11 100644
--- a/chrome/browser/search_engines/search_terms_data.h
+++ b/chrome/browser/search_engines/search_terms_data.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string16.h"
// All data needed by TemplateURLRef::ReplaceSearchTerms which typically may
// only be accessed on the UI thread.
@@ -28,7 +29,7 @@ class SearchTermsData {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// Returns the value for the Chrome Omnibox rlz.
- virtual std::wstring GetRlzParameterValue() const = 0;
+ virtual string16 GetRlzParameterValue() const = 0;
#endif
private:
@@ -44,7 +45,7 @@ class UIThreadSearchTermsData : public SearchTermsData {
virtual std::string GoogleBaseURLValue() const;
virtual std::string GetApplicationLocale() const;
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- virtual std::wstring GetRlzParameterValue() const;
+ virtual string16 GetRlzParameterValue() const;
#endif
// Used by tests to set the value for the Google base url. This takes
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index c1ebf517..b9cbac8 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -262,9 +262,9 @@ void TemplateURLRef::SetGoogleBaseURL(std::string* google_base_url) {
std::string TemplateURLRef::ReplaceSearchTerms(
const TemplateURL& host,
- const std::wstring& terms,
+ const string16& terms,
int accepted_suggestion,
- const std::wstring& original_query_for_suggestion) const {
+ const string16& original_query_for_suggestion) const {
UIThreadSearchTermsData search_terms_data;
return ReplaceSearchTermsUsingTermsData(host,
terms,
@@ -275,9 +275,9 @@ std::string TemplateURLRef::ReplaceSearchTerms(
std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
const TemplateURL& host,
- const std::wstring& terms,
+ const string16& terms,
int accepted_suggestion,
- const std::wstring& original_query_for_suggestion,
+ const string16& original_query_for_suggestion,
const SearchTermsData& search_terms_data) const {
ParseIfNecessaryUsingTermsData(search_terms_data);
if (!valid_)
@@ -292,9 +292,9 @@ std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
for (Replacements::iterator i = replacements_.begin();
i != replacements_.end(); ++i) {
if (i->type == SEARCH_TERMS) {
- std::wstring::size_type query_start = parsed_url_.find('?');
- is_in_query = query_start != std::wstring::npos &&
- (static_cast<std::wstring::size_type>(i->index) > query_start);
+ string16::size_type query_start = parsed_url_.find('?');
+ is_in_query = query_start != string16::npos &&
+ (static_cast<string16::size_type>(i->index) > query_start);
break;
}
}
@@ -307,11 +307,11 @@ std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
// Encode the search terms so that we know the encoding.
const std::vector<std::string>& encodings = host.input_encodings();
for (size_t i = 0; i < encodings.size(); ++i) {
- if (EscapeQueryParamValue(WideToUTF16Hack(terms),
+ if (EscapeQueryParamValue(terms,
encodings[i].c_str(), true,
&encoded_terms)) {
if (!original_query_for_suggestion.empty()) {
- EscapeQueryParamValue(WideToUTF16Hack(original_query_for_suggestion),
+ EscapeQueryParamValue(original_query_for_suggestion,
encodings[i].c_str(),
true,
&encoded_original_query);
@@ -321,17 +321,15 @@ std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
}
}
if (input_encoding.empty()) {
- encoded_terms = WideToUTF16Hack(
- EscapeQueryParamValueUTF8(terms, true));
+ encoded_terms = EscapeQueryParamValueUTF8(terms, true);
if (!original_query_for_suggestion.empty()) {
encoded_original_query =
- WideToUTF16Hack(EscapeQueryParamValueUTF8(
- original_query_for_suggestion, true));
+ EscapeQueryParamValueUTF8(original_query_for_suggestion, true);
}
input_encoding = "UTF-8";
}
} else {
- encoded_terms = WideToUTF16Hack(UTF8ToWide(EscapePath(WideToUTF8(terms))));
+ encoded_terms = UTF8ToUTF16(EscapePath(UTF16ToUTF8(terms)));
input_encoding = "UTF-8";
}
@@ -373,10 +371,10 @@ std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
// empty string. (If we don't handle this case, we hit a
// NOTREACHED below.)
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- std::wstring rlz_string = search_terms_data.GetRlzParameterValue();
+ string16 rlz_string = search_terms_data.GetRlzParameterValue();
if (!rlz_string.empty()) {
rlz_string = L"rlz=" + rlz_string + L"&";
- url.insert(i->index, WideToUTF8(rlz_string));
+ url.insert(i->index, UTF16ToUTF8(rlz_string));
}
#endif
break;
@@ -384,9 +382,9 @@ std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
case GOOGLE_UNESCAPED_SEARCH_TERMS: {
std::string unescaped_terms;
- base::WideToCodepage(terms, input_encoding.c_str(),
- base::OnStringConversionError::SKIP,
- &unescaped_terms);
+ base::UTF16ToCodepage(terms, input_encoding.c_str(),
+ base::OnStringConversionError::SKIP,
+ &unescaped_terms);
url.insert(i->index, std::string(unescaped_terms.begin(),
unescaped_terms.end()));
break;
@@ -431,10 +429,10 @@ bool TemplateURLRef::IsValidUsingTermsData(
return valid_;
}
-std::wstring TemplateURLRef::DisplayURL() const {
+string16 TemplateURLRef::DisplayURL() const {
ParseIfNecessary();
if (!valid_ || replacements_.empty())
- return UTF8ToWide(url_);
+ return UTF8ToUTF16(url_);
string16 result = UTF8ToUTF16(url_);
ReplaceSubstringsAfterOffset(&result, 0,
@@ -446,13 +444,13 @@ std::wstring TemplateURLRef::DisplayURL() const {
ASCIIToUTF16(kGoogleUnescapedSearchTermsParameterFull),
ASCIIToUTF16(kDisplayUnescapedSearchTerms));
- return UTF16ToWideHack(result);
+ return result;
}
// static
std::string TemplateURLRef::DisplayURLToURLRef(
- const std::wstring& display_url) {
- string16 result = WideToUTF16Hack(display_url);
+ const string16& display_url) {
+ string16 result = display_url;
ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16(kDisplaySearchTerms),
ASCIIToUTF16(kSearchTermsParameterFull));
ReplaceSubstringsAfterOffset(
@@ -477,29 +475,29 @@ const std::string& TemplateURLRef::GetSearchTermKey() const {
return search_term_key_;
}
-std::wstring TemplateURLRef::SearchTermToWide(const TemplateURL& host,
+string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host,
const std::string& term) const {
const std::vector<std::string>& encodings = host.input_encodings();
- std::wstring result;
+ string16 result;
std::string unescaped =
UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE |
UnescapeRule::URL_SPECIAL_CHARS);
for (size_t i = 0; i < encodings.size(); ++i) {
- if (base::CodepageToWide(unescaped, encodings[i].c_str(),
- base::OnStringConversionError::FAIL, &result))
+ if (base::CodepageToUTF16(unescaped, encodings[i].c_str(),
+ base::OnStringConversionError::FAIL, &result))
return result;
}
// Always fall back on UTF-8 if it works.
- if (base::CodepageToWide(unescaped, base::kCodepageUTF8,
- base::OnStringConversionError::FAIL, &result))
+ if (base::CodepageToUTF16(unescaped, base::kCodepageUTF8,
+ base::OnStringConversionError::FAIL, &result))
return result;
// When nothing worked, just use the escaped text. We have no idea what the
// encoding is. We need to substitute spaces for pluses ourselves since we're
// not sending it through an unescaper.
- result = UTF8ToWide(term);
+ result = UTF8ToUTF16(term);
std::replace(result.begin(), result.end(), '+', ' ');
return result;
}
@@ -577,8 +575,8 @@ TemplateURL::TemplateURL()
TemplateURL::~TemplateURL() {
}
-std::wstring TemplateURL::AdjustedShortNameForLocaleDirection() const {
- std::wstring bidi_safe_short_name = short_name_;
+string16 TemplateURL::AdjustedShortNameForLocaleDirection() const {
+ string16 bidi_safe_short_name = short_name_;
base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name);
return bidi_safe_short_name;
}
@@ -601,14 +599,14 @@ void TemplateURL::SetInstantURL(const std::string& url,
instant_url_.Set(url, index_offset, page_offset);
}
-void TemplateURL::set_keyword(const std::wstring& keyword) {
+void TemplateURL::set_keyword(const string16& keyword) {
// Case sensitive keyword matching is confusing. As such, we force all
// keywords to be lower case.
- keyword_ = UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword)));
+ keyword_ = l10n_util::ToLower(keyword);
autogenerate_keyword_ = false;
}
-const std::wstring& TemplateURL::keyword() const {
+string16 TemplateURL::keyword() const {
EnsureKeyword();
return keyword_;
}
@@ -629,7 +627,7 @@ bool TemplateURL::ShowInDefaultList() const {
void TemplateURL::SetFavIconURL(const GURL& url) {
for (std::vector<ImageRef>::iterator i = image_refs_.begin();
i != image_refs_.end(); ++i) {
- if (i->type == L"image/x-icon" &&
+ if (i->type == "image/x-icon" &&
i->width == kFavIconSize && i->height == kFavIconSize) {
if (!url.is_valid())
image_refs_.erase(i);
@@ -641,15 +639,15 @@ void TemplateURL::SetFavIconURL(const GURL& url) {
// Don't have one yet, add it.
if (url.is_valid()) {
add_image_ref(
- TemplateURL::ImageRef(L"image/x-icon", kFavIconSize, kFavIconSize,
- url));
+ TemplateURL::ImageRef("image/x-icon", kFavIconSize,
+ kFavIconSize, url));
}
}
GURL TemplateURL::GetFavIconURL() const {
for (std::vector<ImageRef>::const_iterator i = image_refs_.begin();
i != image_refs_.end(); ++i) {
- if ((i->type == L"image/x-icon" || i->type == L"image/vnd.microsoft.icon")
+ if ((i->type == "image/x-icon" || i->type == "image/vnd.microsoft.icon")
&& i->width == kFavIconSize && i->height == kFavIconSize) {
return i->url;
}
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index ba2a96e..44cdeec 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -72,18 +72,18 @@ class TemplateURLRef {
// The TemplateURL is used to determine the input encoding for the term.
std::string ReplaceSearchTerms(
const TemplateURL& host,
- const std::wstring& terms,
+ const string16& terms,
int accepted_suggestion,
- const std::wstring& original_query_for_suggestion) const;
+ const string16& original_query_for_suggestion) const;
// Just like ReplaceSearchTerms except that it takes SearchTermsData to supply
// the data for some search terms. Most of the time ReplaceSearchTerms should
// be called.
std::string ReplaceSearchTermsUsingTermsData(
const TemplateURL& host,
- const std::wstring& terms,
+ const string16& terms,
int accepted_suggestion,
- const std::wstring& original_query_for_suggestion,
+ const string16& original_query_for_suggestion,
const SearchTermsData& search_terms_data) const;
// Returns the raw URL. None of the parameters will have been replaced.
@@ -104,11 +104,11 @@ class TemplateURLRef {
// Returns a string representation of this TemplateURLRef suitable for
// display. The display format is the same as the format used by Firefox.
- std::wstring DisplayURL() const;
+ string16 DisplayURL() const;
// Converts a string as returned by DisplayURL back into a string as
// understood by TemplateURLRef.
- static std::string DisplayURLToURLRef(const std::wstring& display_url);
+ static std::string DisplayURLToURLRef(const string16& display_url);
// If this TemplateURLRef is valid and contains one search term, this returns
// the host/path of the URL, otherwise this returns an empty string.
@@ -120,8 +120,8 @@ class TemplateURLRef {
const std::string& GetSearchTermKey() const;
// Converts the specified term in the encoding of the host TemplateURL to a
- // wide string.
- std::wstring SearchTermToWide(const TemplateURL& host,
+ // string16.
+ string16 SearchTermToString16(const TemplateURL& host,
const std::string& term) const;
// Returns true if this TemplateURLRef has a replacement term of
@@ -259,17 +259,17 @@ class TemplateURL {
// If a TemplateURL has no images, the favicon for the generated URL
// should be used.
struct ImageRef {
- ImageRef(const std::wstring& type, int width, int height)
+ ImageRef(const std::string& type, int width, int height)
: type(type), width(width), height(height) {
}
- ImageRef(const std::wstring& type, int width, int height, const GURL& url)
+ ImageRef(const std::string& type, int width, int height, const GURL& url)
: type(type), width(width), height(height), url(url) {
}
// Mime type for the image.
// ICO image will have the format: image/x-icon or image/vnd.microsoft.icon
- std::wstring type;
+ std::string type;
// Size of the image
int width;
@@ -297,20 +297,20 @@ class TemplateURL {
// A short description of the template. This is the name we show to the user
// in various places that use keywords. For example, the location bar shows
// this when the user selects the keyword.
- void set_short_name(const std::wstring& short_name) {
+ void set_short_name(const string16& short_name) {
short_name_ = short_name;
}
- const std::wstring& short_name() const { return short_name_; }
+ string16 short_name() const { return short_name_; }
// An accessor for the short_name, but adjusted so it can be appropriately
// displayed even if it is LTR and the UI is RTL.
- std::wstring AdjustedShortNameForLocaleDirection() const;
+ string16 AdjustedShortNameForLocaleDirection() const;
// A description of the template; this may be empty.
- void set_description(const std::wstring& description) {
+ void set_description(const string16& description) {
description_ = description;
}
- const std::wstring& description() const { return description_; }
+ string16 description() const { return description_; }
// URL providing JSON results. This is typically used to provide suggestions
// as your type. If NULL, this url does not support suggestions.
@@ -350,8 +350,8 @@ class TemplateURL {
const GURL& originating_url() const { return originating_url_; }
// The shortcut for this template url. May be empty.
- void set_keyword(const std::wstring& keyword);
- const std::wstring& keyword() const;
+ void set_keyword(const string16& keyword);
+ string16 keyword() const;
// Whether to autogenerate a keyword from the url() in GetKeyword(). Most
// consumers should not need this.
@@ -410,10 +410,10 @@ class TemplateURL {
GURL GetFavIconURL() const;
// Set of languages supported. This may be empty.
- void add_language(const std::wstring& language) {
+ void add_language(const string16& language) {
languages_.push_back(language);
}
- const std::vector<std::wstring>& languages() const { return languages_; }
+ std::vector<string16> languages() const { return languages_; }
// Date this keyword was created.
//
@@ -487,13 +487,13 @@ class TemplateURL {
// Unique identifier, used when archived to the database.
void set_id(TemplateURLID id) { id_ = id;}
- std::wstring short_name_;
- std::wstring description_;
+ string16 short_name_;
+ string16 description_;
TemplateURLRef suggestions_url_;
TemplateURLRef url_;
TemplateURLRef instant_url_;
GURL originating_url_;
- mutable std::wstring keyword_;
+ mutable string16 keyword_;
bool autogenerate_keyword_; // If this is set, |keyword_| holds the cached
// generated keyword if available.
mutable bool keyword_generated_; // True if the keyword was generated. This
@@ -502,7 +502,7 @@ class TemplateURL {
bool show_in_default_list_;
bool safe_for_autoreplace_;
std::vector<ImageRef> image_refs_;
- std::vector<std::wstring> languages_;
+ std::vector<string16> languages_;
// List of supported input encodings.
std::vector<std::string> input_encodings_;
TemplateURLID id_;
diff --git a/chrome/browser/search_engines/template_url_fetcher.cc b/chrome/browser/search_engines/template_url_fetcher.cc
index 293f59b..a86c5c1 100644
--- a/chrome/browser/search_engines/template_url_fetcher.cc
+++ b/chrome/browser/search_engines/template_url_fetcher.cc
@@ -26,7 +26,7 @@ class TemplateURLFetcher::RequestDelegate : public URLFetcher::Delegate,
public:
// Takes ownership of |callbacks|.
RequestDelegate(TemplateURLFetcher* fetcher,
- const std::wstring& keyword,
+ const string16& keyword,
const GURL& osdd_url,
const GURL& favicon_url,
TemplateURLFetcherCallbacks* callbacks,
@@ -48,10 +48,10 @@ class TemplateURLFetcher::RequestDelegate : public URLFetcher::Delegate,
const std::string& data);
// URL of the OSDD.
- const GURL& url() const { return osdd_url_; }
+ GURL url() const { return osdd_url_; }
// Keyword to use.
- const std::wstring keyword() const { return keyword_; }
+ string16 keyword() const { return keyword_; }
// The type of search provider being fetched.
ProviderType provider_type() const { return provider_type_; }
@@ -62,7 +62,7 @@ class TemplateURLFetcher::RequestDelegate : public URLFetcher::Delegate,
URLFetcher url_fetcher_;
TemplateURLFetcher* fetcher_;
scoped_ptr<TemplateURL> template_url_;
- std::wstring keyword_;
+ string16 keyword_;
const GURL osdd_url_;
const GURL favicon_url_;
const ProviderType provider_type_;
@@ -76,7 +76,7 @@ class TemplateURLFetcher::RequestDelegate : public URLFetcher::Delegate,
TemplateURLFetcher::RequestDelegate::RequestDelegate(
TemplateURLFetcher* fetcher,
- const std::wstring& keyword,
+ const string16& keyword,
const GURL& osdd_url,
const GURL& favicon_url,
TemplateURLFetcherCallbacks* callbacks,
@@ -160,7 +160,7 @@ void TemplateURLFetcher::RequestDelegate::AddSearchProvider() {
// it gives wrong result when OSDD is located on third party site that
// has nothing in common with search engine in OSDD.
GURL keyword_url(template_url_->url()->url());
- std::wstring new_keyword = TemplateURLModel::GenerateKeyword(
+ string16 new_keyword = TemplateURLModel::GenerateKeyword(
keyword_url, false);
if (!new_keyword.empty())
keyword_ = new_keyword;
@@ -183,13 +183,13 @@ void TemplateURLFetcher::RequestDelegate::AddSearchProvider() {
// provider. The keyword isn't as important in this case.
if (provider_type_ == EXPLICIT_DEFAULT_PROVIDER) {
// The loop numbers are arbitrary and are simply a strong effort.
- std::wstring new_keyword;
+ string16 new_keyword;
for (int i = 0; i < 100; ++i) {
// Concatenate a number at end of the keyword and try that.
new_keyword = keyword_;
// Try the keyword alone the first time
if (i > 0)
- new_keyword.append(UTF16ToWide(base::IntToString16(i)));
+ new_keyword.append(base::IntToString16(i));
if (!model->GetTemplateURLForKeyword(new_keyword) ||
model->CanReplaceKeyword(new_keyword,
GURL(template_url_->url()->url()),
@@ -268,7 +268,7 @@ TemplateURLFetcher::~TemplateURLFetcher() {
}
void TemplateURLFetcher::ScheduleDownload(
- const std::wstring& keyword,
+ const string16& keyword,
const GURL& osdd_url,
const GURL& favicon_url,
TemplateURLFetcherCallbacks* callbacks,
diff --git a/chrome/browser/search_engines/template_url_fetcher.h b/chrome/browser/search_engines/template_url_fetcher.h
index b1e15cc..444f396 100644
--- a/chrome/browser/search_engines/template_url_fetcher.h
+++ b/chrome/browser/search_engines/template_url_fetcher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,7 @@
#pragma once
#include "base/scoped_vector.h"
+#include "base/string16.h"
#include "gfx/native_widget_types.h"
class GURL;
@@ -33,7 +34,7 @@ class TemplateURLFetcher {
// If TemplateURLFetcher is not already downloading the OSDD for osdd_url,
// it is downloaded. If successful and the result can be parsed, a TemplateURL
// is added to the TemplateURLModel. Takes ownership of |callbacks|.
- void ScheduleDownload(const std::wstring& keyword,
+ void ScheduleDownload(const string16& keyword,
const GURL& osdd_url,
const GURL& favicon_url,
TemplateURLFetcherCallbacks* callbacks,
diff --git a/chrome/browser/search_engines/template_url_fetcher_unittest.cc b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
index 737a349..ec20c66 100644
--- a/chrome/browser/search_engines/template_url_fetcher_unittest.cc
+++ b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +6,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_fetcher_callbacks.h"
@@ -76,7 +77,7 @@ class TemplateURLFetcherTest : public testing::Test {
protected:
// Schedules the download of the url.
- void StartDownload(const std::wstring& keyword,
+ void StartDownload(const string16& keyword,
const std::string& osdd_file_name,
TemplateURLFetcher::ProviderType provider_type,
bool check_that_file_exists);
@@ -154,7 +155,7 @@ void TemplateURLFetcherTest::ConfirmAddSearchProvider(
}
void TemplateURLFetcherTest::StartDownload(
- const std::wstring& keyword,
+ const string16& keyword,
const std::string& osdd_file_name,
TemplateURLFetcher::ProviderType provider_type,
bool check_that_file_exists) {
@@ -183,7 +184,7 @@ void TemplateURLFetcherTest::WaitForDownloadToFinish() {
}
TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
test_util_.ChangeModelToLoadState();
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
@@ -203,13 +204,13 @@ TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) {
const TemplateURL* t_url = test_util_.model()->GetTemplateURLForKeyword(
keyword);
ASSERT_TRUE(t_url);
- EXPECT_STREQ(L"http://example.com/%s/other_stuff",
- t_url->url()->DisplayURL().c_str());
+ EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
+ t_url->url()->DisplayURL());
EXPECT_TRUE(t_url->safe_for_autoreplace());
}
TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
test_util_.ChangeModelToLoadState();
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
@@ -224,7 +225,7 @@ TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
struct {
std::string description;
std::string osdd_file_name;
- std::wstring keyword;
+ string16 keyword;
TemplateURLFetcher::ProviderType provider_type;
} test_cases[] = {
{ "Duplicate keyword and osdd url with autodetected provider.",
@@ -232,7 +233,8 @@ TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
{ "Duplicate keyword and osdd url with explicit provider.",
osdd_file_name, keyword, TemplateURLFetcher::EXPLICIT_PROVIDER },
{ "Duplicate osdd url with explicit provider.",
- osdd_file_name, keyword + L"1", TemplateURLFetcher::EXPLICIT_PROVIDER },
+ osdd_file_name, keyword + ASCIIToUTF16("1"),
+ TemplateURLFetcher::EXPLICIT_PROVIDER },
{ "Duplicate keyword with explicit provider.",
osdd_file_name + "1", keyword, TemplateURLFetcher::EXPLICIT_PROVIDER }
};
@@ -255,7 +257,7 @@ TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
}
TEST_F(TemplateURLFetcherTest, BasicExplicitTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
test_util_.ChangeModelToLoadState();
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
@@ -273,13 +275,13 @@ TEST_F(TemplateURLFetcherTest, BasicExplicitTest) {
ASSERT_EQ(1, callbacks_destroyed_);
ASSERT_TRUE(last_callback_template_url_.get());
- EXPECT_STREQ(L"http://example.com/%s/other_stuff",
- last_callback_template_url_->url()->DisplayURL().c_str());
+ EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
+ last_callback_template_url_->url()->DisplayURL());
EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
}
TEST_F(TemplateURLFetcherTest, BasicExplicitDefaultTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
test_util_.ChangeModelToLoadState();
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
@@ -297,13 +299,13 @@ TEST_F(TemplateURLFetcherTest, BasicExplicitDefaultTest) {
ASSERT_EQ(1, callbacks_destroyed_);
ASSERT_TRUE(last_callback_template_url_.get());
- EXPECT_STREQ(L"http://example.com/%s/other_stuff",
- last_callback_template_url_->url()->DisplayURL().c_str());
+ EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
+ last_callback_template_url_->url()->DisplayURL());
EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
}
TEST_F(TemplateURLFetcherTest, AutodetectedBeforeLoadTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
std::string osdd_file_name("simple_open_search.xml");
@@ -315,7 +317,7 @@ TEST_F(TemplateURLFetcherTest, AutodetectedBeforeLoadTest) {
}
TEST_F(TemplateURLFetcherTest, ExplicitBeforeLoadTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
std::string osdd_file_name("simple_open_search.xml");
@@ -327,7 +329,7 @@ TEST_F(TemplateURLFetcherTest, ExplicitBeforeLoadTest) {
}
TEST_F(TemplateURLFetcherTest, ExplicitDefaultBeforeLoadTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
std::string osdd_file_name("simple_open_search.xml");
@@ -343,13 +345,13 @@ TEST_F(TemplateURLFetcherTest, ExplicitDefaultBeforeLoadTest) {
ASSERT_EQ(1, callbacks_destroyed_);
ASSERT_TRUE(last_callback_template_url_.get());
- EXPECT_STREQ(L"http://example.com/%s/other_stuff",
- last_callback_template_url_->url()->DisplayURL().c_str());
+ EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
+ last_callback_template_url_->url()->DisplayURL());
EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
}
TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) {
- std::wstring keyword(L"test");
+ string16 keyword(ASCIIToUTF16("test"));
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://example.com/", 0, 0);
@@ -384,5 +386,5 @@ TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) {
ASSERT_EQ(0, add_provider_called_);
ASSERT_EQ(3, callbacks_destroyed_);
ASSERT_TRUE(last_callback_template_url_.get());
- ASSERT_STRNE(keyword.c_str(), last_callback_template_url_->keyword().c_str());
+ ASSERT_NE(keyword, last_callback_template_url_->keyword());
}
diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc
index 7372262..5894932 100644
--- a/chrome/browser/search_engines/template_url_model.cc
+++ b/chrome/browser/search_engines/template_url_model.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -46,7 +46,7 @@ static const char kTemplateParameter[] = "%s";
// Term used when generating a search url. Use something obscure so that on
// the rare case the term replaces the URL it's unlikely another keyword would
// have the same url.
-static const wchar_t kReplacementTerm[] = L"blah.blah.blah.blah.blah";
+static const char kReplacementTerm[] = "blah.blah.blah.blah.blah";
// Removes from the vector any template URL that was created because of
@@ -129,8 +129,8 @@ TemplateURLModel::~TemplateURLModel() {
}
// static
-std::wstring TemplateURLModel::GenerateKeyword(const GURL& url,
- bool autodetected) {
+string16 TemplateURLModel::GenerateKeyword(const GURL& url,
+ bool autodetected) {
// Don't autogenerate keywords for referrers that are the result of a form
// submission (TODO: right now we approximate this by checking for the URL
// having a query, but we should replace this with a call to WebCore to see if
@@ -143,44 +143,43 @@ std::wstring TemplateURLModel::GenerateKeyword(const GURL& url,
if (!url.is_valid() ||
(autodetected && (url.has_query() || !url.SchemeIs(chrome::kHttpScheme) ||
((url.path() != "") && (url.path() != "/")))))
- return std::wstring();
+ return string16();
// Strip "www." off the front of the keyword; otherwise the keyword won't work
// properly. See http://code.google.com/p/chromium/issues/detail?id=6984 .
- return UTF16ToWideHack(net::StripWWW(UTF8ToUTF16(url.host())));
+ return net::StripWWW(UTF8ToUTF16(url.host()));
}
// static
-std::wstring TemplateURLModel::CleanUserInputKeyword(
- const std::wstring& keyword) {
+string16 TemplateURLModel::CleanUserInputKeyword(const string16& keyword) {
// Remove the scheme.
- std::wstring result(UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword))));
+ string16 result(l10n_util::ToLower(keyword));
url_parse::Component scheme_component;
- if (url_parse::ExtractScheme(WideToUTF8(keyword).c_str(),
+ if (url_parse::ExtractScheme(UTF16ToUTF8(keyword).c_str(),
static_cast<int>(keyword.length()),
&scheme_component)) {
// If the scheme isn't "http" or "https", bail. The user isn't trying to
// type a web address, but rather an FTP, file:, or other scheme URL, or a
// search query with some sort of initial operator (e.g. "site:").
if (result.compare(0, scheme_component.end(),
- ASCIIToWide(chrome::kHttpScheme)) &&
+ ASCIIToUTF16(chrome::kHttpScheme)) &&
result.compare(0, scheme_component.end(),
- ASCIIToWide(chrome::kHttpsScheme)))
- return std::wstring();
+ ASCIIToUTF16(chrome::kHttpsScheme)))
+ return string16();
// Include trailing ':'.
result.erase(0, scheme_component.end() + 1);
// Many schemes usually have "//" after them, so strip it too.
- const std::wstring after_scheme(L"//");
+ const string16 after_scheme(ASCIIToUTF16("//"));
if (result.compare(0, after_scheme.length(), after_scheme) == 0)
result.erase(0, after_scheme.length());
}
// Remove leading "www.".
- result = UTF16ToWideHack(net::StripWWW(WideToUTF16(result)));
+ result = net::StripWWW(result);
// Remove trailing "/".
- return (result.length() > 0 && result[result.length() - 1] == L'/') ?
+ return (result.length() > 0 && result[result.length() - 1] == '/') ?
result.substr(0, result.length() - 1) : result;
}
@@ -206,12 +205,13 @@ GURL TemplateURLModel::GenerateSearchURLUsingTermsData(
return GURL(search_ref->url());
return GURL(search_ref->ReplaceSearchTermsUsingTermsData(
- *t_url, kReplacementTerm, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
- std::wstring(), search_terms_data));
+ *t_url, ASCIIToUTF16(kReplacementTerm),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
+ string16(), search_terms_data));
}
bool TemplateURLModel::CanReplaceKeyword(
- const std::wstring& keyword,
+ const string16& keyword,
const GURL& url,
const TemplateURL** template_url_to_replace) {
DCHECK(!keyword.empty()); // This should only be called for non-empty
@@ -237,9 +237,9 @@ bool TemplateURLModel::CanReplaceKeyword(
}
void TemplateURLModel::FindMatchingKeywords(
- const std::wstring& prefix,
+ const string16& prefix,
bool support_replacement_only,
- std::vector<std::wstring>* matches) const {
+ std::vector<string16>* matches) const {
// Sanity check args.
if (prefix.empty())
return;
@@ -265,7 +265,7 @@ void TemplateURLModel::FindMatchingKeywords(
}
const TemplateURL* TemplateURLModel::GetTemplateURLForKeyword(
- const std::wstring& keyword) const {
+ const string16& keyword) const {
KeywordToTemplateMap::const_iterator elem(
keyword_to_template_map_.find(keyword));
return (elem == keyword_to_template_map_.end()) ? NULL : elem->second;
@@ -320,10 +320,10 @@ void TemplateURLModel::RegisterExtensionKeyword(const Extension* extension) {
}
const TemplateURL* existing_url = GetTemplateURLForExtension(extension);
- std::wstring keyword = UTF8ToWide(extension->omnibox_keyword());
+ string16 keyword = UTF8ToUTF16(extension->omnibox_keyword());
scoped_ptr<TemplateURL> template_url(new TemplateURL);
- template_url->set_short_name(UTF8ToWide(extension->name()));
+ template_url->set_short_name(UTF8ToUTF16(extension->name()));
template_url->set_keyword(keyword);
// This URL is not actually used for navigation. It holds the extension's
// ID, as well as forcing the TemplateURL to be treated as a search keyword.
@@ -372,8 +372,8 @@ void TemplateURLModel::IncrementUsageCount(const TemplateURL* url) {
}
void TemplateURLModel::ResetTemplateURL(const TemplateURL* url,
- const std::wstring& title,
- const std::wstring& keyword,
+ const string16& title,
+ const string16& keyword,
const std::string& search_url) {
TemplateURL new_url(*url);
new_url.set_short_name(title);
@@ -538,8 +538,8 @@ void TemplateURLModel::OnWebDataServiceRequestDone(
NotifyLoaded();
}
-std::wstring TemplateURLModel::GetKeywordShortName(const std::wstring& keyword,
- bool* is_extension_keyword) {
+string16 TemplateURLModel::GetKeywordShortName(const string16& keyword,
+ bool* is_extension_keyword) {
const TemplateURL* template_url = GetTemplateURLForKeyword(keyword);
// TODO(sky): Once LocationBarView adds a listener to the TemplateURLModel
@@ -549,7 +549,7 @@ std::wstring TemplateURLModel::GetKeywordShortName(const std::wstring& keyword,
return template_url->AdjustedShortNameForLocaleDirection();
}
*is_extension_keyword = false;
- return std::wstring();
+ return string16();
}
void TemplateURLModel::Observe(NotificationType type,
@@ -602,12 +602,12 @@ void TemplateURLModel::RegisterUserPrefs(PrefService* prefs) {
void TemplateURLModel::SetKeywordSearchTermsForURL(const TemplateURL* t_url,
const GURL& url,
- const std::wstring& term) {
+ const string16& term) {
HistoryService* history = profile_ ?
profile_->GetHistoryService(Profile::EXPLICIT_ACCESS) : NULL;
if (!history)
return;
- history->SetKeywordSearchTermsForURL(url, t_url->id(), WideToUTF16Hack(term));
+ history->SetKeywordSearchTermsForURL(url, t_url->id(), term);
}
void TemplateURLModel::Init(const Initializer* initializers,
@@ -640,15 +640,15 @@ void TemplateURLModel::Init(const Initializer* initializers,
size_t template_position =
std::string(initializers[i].url).find(kTemplateParameter);
- DCHECK(template_position != std::wstring::npos);
+ DCHECK(template_position != std::string::npos);
std::string osd_url(initializers[i].url);
osd_url.replace(template_position, arraysize(kTemplateParameter) - 1,
kSearchTermParameter);
// TemplateURLModel ends up owning the TemplateURL, don't try and free it.
TemplateURL* template_url = new TemplateURL();
- template_url->set_keyword(initializers[i].keyword);
- template_url->set_short_name(initializers[i].content);
+ template_url->set_keyword(UTF8ToUTF16(initializers[i].keyword));
+ template_url->set_short_name(UTF8ToUTF16(initializers[i].content));
template_url->SetURL(osd_url, 0, 0);
AddNoNotify(template_url);
}
@@ -777,8 +777,8 @@ void TemplateURLModel::SaveDefaultSearchProviderToPrefs(
if (!icon_gurl.is_empty())
icon_url = icon_gurl.spec();
encodings = JoinString(t_url->input_encodings(), ';');
- short_name = WideToUTF8(t_url->short_name());
- keyword = WideToUTF8(t_url->keyword());
+ short_name = UTF16ToUTF8(t_url->short_name());
+ keyword = UTF16ToUTF8(t_url->keyword());
id_string = base::Int64ToString(t_url->id());
prepopulate_id = base::Int64ToString(t_url->prepopulate_id());
}
@@ -822,10 +822,10 @@ bool TemplateURLModel::LoadDefaultSearchProviderFromPrefs(
return true;
}
- std::wstring name =
- UTF8ToWide(prefs->GetString(prefs::kDefaultSearchProviderName));
- std::wstring keyword =
- UTF8ToWide(prefs->GetString(prefs::kDefaultSearchProviderKeyword));
+ string16 name =
+ UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderName));
+ string16 keyword =
+ UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderKeyword));
std::string icon_url =
prefs->GetString(prefs::kDefaultSearchProviderIconURL);
std::string encodings =
@@ -983,7 +983,7 @@ void TemplateURLModel::UpdateKeywordSearchTermsForURL(
if (terms_iterator != query_terms.end() &&
!terms_iterator->second.empty()) {
SetKeywordSearchTermsForURL(
- *i, row.url(), search_ref->SearchTermToWide(*(*i),
+ *i, row.url(), search_ref->SearchTermToString16(*(*i),
terms_iterator->second));
}
}
@@ -1006,7 +1006,8 @@ void TemplateURLModel::AddTabToSearchVisit(const TemplateURL& t_url) {
if (!history)
return;
- GURL url(URLFixerUpper::FixupURL(WideToUTF8(t_url.keyword()), std::string()));
+ GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(t_url.keyword()),
+ std::string()));
if (!url.is_valid())
return;
diff --git a/chrome/browser/search_engines/template_url_model.h b/chrome/browser/search_engines/template_url_model.h
index a16bad7..504e79f 100644
--- a/chrome/browser/search_engines/template_url_model.h
+++ b/chrome/browser/search_engines/template_url_model.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -45,7 +45,7 @@ struct URLVisitedDetails;
//
// There is a TemplateURLModel per Profile.
//
-// TemplateURLModel does not load the vector of TemplateURLs in it's
+// TemplateURLModel does not load the vector of TemplateURLs in its
// constructor (except for testing). Use the Load method to trigger a load.
// When TemplateURLModel has completed loading, observers are notified via
// OnTemplateURLModelChanged as well as the TEMPLATE_URL_MODEL_LOADED
@@ -63,9 +63,9 @@ class TemplateURLModel : public WebDataServiceConsumer,
// Struct used for initializing the data store with fake data.
// Each initializer is mapped to a TemplateURL.
struct Initializer {
- const wchar_t* const keyword;
+ const char* const keyword;
const char* const url;
- const wchar_t* const content;
+ const char* const content;
};
explicit TemplateURLModel(Profile* profile);
@@ -78,11 +78,11 @@ class TemplateURLModel : public WebDataServiceConsumer,
// don't generate keywords for a variety of situations where we would probably
// not want to auto-add keywords, such as keywords for searches on pages that
// themselves come from form submissions.
- static std::wstring GenerateKeyword(const GURL& url, bool autodetected);
+ static string16 GenerateKeyword(const GURL& url, bool autodetected);
// Removes any unnecessary characters from a user input keyword.
// This removes the leading scheme, "www." and any trailing slash.
- static std::wstring CleanUserInputKeyword(const std::wstring& keyword);
+ static string16 CleanUserInputKeyword(const string16& keyword);
// Returns the search url for t_url. Returns an empty GURL if t_url has no
// url().
@@ -102,23 +102,22 @@ class TemplateURLModel : public WebDataServiceConsumer,
//
// url gives the url of the search query. The url is used to avoid generating
// a TemplateURL for an existing TemplateURL that shares the same host.
- bool CanReplaceKeyword(const std::wstring& keyword,
+ bool CanReplaceKeyword(const string16& keyword,
const GURL& url,
const TemplateURL** template_url_to_replace);
// Returns (in |matches|) all keywords beginning with |prefix|, sorted
// shortest-first. If support_replacement_only is true, only keywords that
// support replacement are returned.
- void FindMatchingKeywords(const std::wstring& prefix,
+ void FindMatchingKeywords(const string16& prefix,
bool support_replacement_only,
- std::vector<std::wstring>* matches) const;
+ std::vector<string16>* matches) const;
// Looks up |keyword| and returns the element it maps to. Returns NULL if
// the keyword was not found.
// The caller should not try to delete the returned pointer; the data store
// retains ownership of it.
- const TemplateURL* GetTemplateURLForKeyword(
- const std::wstring& keyword) const;
+ const TemplateURL* GetTemplateURLForKeyword(const string16& keyword) const;
// Returns the first TemplateURL found with a URL using the specified |host|,
// or NULL if there are no such TemplateURLs
@@ -167,8 +166,8 @@ class TemplateURLModel : public WebDataServiceConsumer,
// Resets the title, keyword and search url of the specified TemplateURL.
// The TemplateURL is marked as not replaceable.
void ResetTemplateURL(const TemplateURL* url,
- const std::wstring& title,
- const std::wstring& keyword,
+ const string16& title,
+ const string16& keyword,
const std::string& search_url);
// Return true if the given |url| can be made the default.
@@ -211,8 +210,8 @@ class TemplateURLModel : public WebDataServiceConsumer,
// Returns the locale-direction-adjusted short name for the given keyword.
// Also sets the out param to indicate whether the keyword belongs to an
// extension.
- std::wstring GetKeywordShortName(const std::wstring& keyword,
- bool* is_extension_keyword);
+ string16 GetKeywordShortName(const string16& keyword,
+ bool* is_extension_keyword);
// NotificationObserver method. TemplateURLModel listens for three
// notification types:
@@ -245,7 +244,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
// This exists and is virtual for testing.
virtual void SetKeywordSearchTermsForURL(const TemplateURL* t_url,
const GURL& url,
- const std::wstring& term);
+ const string16& term);
private:
FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest, BuildQueryTerms);
@@ -258,7 +257,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest, MergeDeletesUnusedProviders);
friend class TemplateURLModelTestUtil;
- typedef std::map<std::wstring, const TemplateURL*> KeywordToTemplateMap;
+ typedef std::map<string16, const TemplateURL*> KeywordToTemplateMap;
typedef std::vector<const TemplateURL*> TemplateURLVector;
// Helper functor for FindMatchingKeywords(), for finding the range of
diff --git a/chrome/browser/search_engines/template_url_model_test_util.cc b/chrome/browser/search_engines/template_url_model_test_util.cc
index 7803b12..477999c 100644
--- a/chrome/browser/search_engines/template_url_model_test_util.cc
+++ b/chrome/browser/search_engines/template_url_model_test_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -85,8 +85,8 @@ class TestingTemplateURLModel : public TemplateURLModel {
: TemplateURLModel(profile) {
}
- std::wstring GetAndClearSearchTerm() {
- std::wstring search_term;
+ string16 GetAndClearSearchTerm() {
+ string16 search_term;
search_term.swap(search_term_);
return search_term;
}
@@ -94,12 +94,12 @@ class TestingTemplateURLModel : public TemplateURLModel {
protected:
virtual void SetKeywordSearchTermsForURL(const TemplateURL* t_url,
const GURL& url,
- const std::wstring& term) {
+ const string16& term) {
search_term_ = term;
}
private:
- std::wstring search_term_;
+ string16 search_term_;
DISALLOW_COPY_AND_ASSIGN(TestingTemplateURLModel);
};
@@ -210,7 +210,7 @@ void TemplateURLModelTestUtil::ResetModel(bool verify_load) {
VerifyLoad();
}
-std::wstring TemplateURLModelTestUtil::GetAndClearSearchTerm() {
+string16 TemplateURLModelTestUtil::GetAndClearSearchTerm() {
return
static_cast<TestingTemplateURLModel*>(model())->GetAndClearSearchTerm();
}
diff --git a/chrome/browser/search_engines/template_url_model_test_util.h b/chrome/browser/search_engines/template_url_model_test_util.h
index 058b64b..18cfb58 100644
--- a/chrome/browser/search_engines/template_url_model_test_util.h
+++ b/chrome/browser/search_engines/template_url_model_test_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,6 +12,7 @@
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "base/string16.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/search_engines/template_url_model_observer.h"
@@ -70,7 +71,7 @@ class TemplateURLModelTestUtil : public TemplateURLModelObserver {
// Returns the search term from the last invocation of
// TemplateURLModel::SetKeywordSearchTermsForURL and clears the search term.
- std::wstring GetAndClearSearchTerm();
+ string16 GetAndClearSearchTerm();
// Set the google base url.
void SetGoogleBaseURL(const std::string& base_url) const;
diff --git a/chrome/browser/search_engines/template_url_model_unittest.cc b/chrome/browser/search_engines/template_url_model_unittest.cc
index 9e5477c..ab64c2a 100644
--- a/chrome/browser/search_engines/template_url_model_unittest.cc
+++ b/chrome/browser/search_engines/template_url_model_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include "base/string_util.h"
#include "base/ref_counted.h"
#include "base/threading/thread.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_notifications.h"
@@ -77,8 +78,8 @@ class TestSearchTermsData : public SearchTermsData {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// Returns the value for the Chrome Omnibox rlz.
- virtual std::wstring GetRlzParameterValue() const {
- return std::wstring();
+ virtual string16 GetRlzParameterValue() const {
+ return string16();
}
#endif
@@ -93,8 +94,8 @@ class TestSearchTermsData : public SearchTermsData {
static TemplateURL* CreatePreloadedTemplateURL() {
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.unittest.com/", 0, 0);
- t_url->set_keyword(L"unittest");
- t_url->set_short_name(L"unittest");
+ t_url->set_keyword(ASCIIToUTF16("unittest"));
+ t_url->set_short_name(ASCIIToUTF16("unittest"));
t_url->set_safe_for_autoreplace(true);
GURL favicon_url("http://favicon.url");
t_url->SetFavIconURL(favicon_url);
@@ -115,22 +116,22 @@ class TemplateURLModelTest : public testing::Test {
test_util_.TearDown();
}
- TemplateURL* AddKeywordWithDate(const std::wstring& keyword,
+ TemplateURL* AddKeywordWithDate(const std::string& keyword,
bool autogenerate_keyword,
const std::string& url,
const std::string& suggest_url,
const std::string& fav_icon_url,
const std::string& encodings,
- const std::wstring& short_name,
+ const std::string& short_name,
bool safe_for_autoreplace,
Time created_date) {
TemplateURL* template_url = new TemplateURL();
template_url->SetURL(url, 0, 0);
template_url->SetSuggestionsURL(suggest_url, 0, 0);
template_url->SetFavIconURL(GURL(fav_icon_url));
- template_url->set_keyword(keyword);
+ template_url->set_keyword(UTF8ToUTF16(keyword));
template_url->set_autogenerate_keyword(autogenerate_keyword);
- template_url->set_short_name(short_name);
+ template_url->set_short_name(UTF8ToUTF16(short_name));
std::vector<std::string> encodings_vector;
base::SplitString(encodings, ';', &encodings_vector);
template_url->set_input_encodings(encodings_vector);
@@ -240,12 +241,12 @@ class TemplateURLModelTest : public testing::Test {
prefs::kDefaultSearchProviderPrepopulateID);
}
- // Creates a TemplateURL with the same prepopluated id as a real prepopulated
+ // Creates a TemplateURL with the same prepopulated id as a real prepopulated
// item. The input number determines which prepopulated item. The caller is
// responsible for owning the returned TemplateURL*.
TemplateURL* CreateReplaceablePreloadedTemplateURL(
size_t index_offset_from_default,
- std::wstring* prepopulated_display_url);
+ string16* prepopulated_display_url);
// Verifies the behavior of when a preloaded url later gets changed.
// Since the input is the offset from the default, when one passes in
@@ -269,7 +270,7 @@ class TemplateURLModelTest : public testing::Test {
void VerifyLoad() { test_util_.VerifyLoad(); }
void ChangeModelToLoadState() { test_util_.ChangeModelToLoadState(); }
void ResetModel(bool verify_load) { test_util_.ResetModel(verify_load); }
- std::wstring GetAndClearSearchTerm() {
+ string16 GetAndClearSearchTerm() {
return test_util_.GetAndClearSearchTerm();
}
void SetGoogleBaseURL(const std::string& base_url) const {
@@ -323,7 +324,7 @@ void TestGenerateSearchURL::RunTest() {
TemplateURL* TemplateURLModelTest::CreateReplaceablePreloadedTemplateURL(
size_t index_offset_from_default,
- std::wstring* prepopulated_display_url) {
+ string16* prepopulated_display_url) {
TemplateURL* t_url = CreatePreloadedTemplateURL();
ScopedVector<TemplateURL> prepopulated_urls;
size_t default_search_provider_index = 0;
@@ -344,39 +345,37 @@ TemplateURL* TemplateURLModelTest::CreateReplaceablePreloadedTemplateURL(
void TemplateURLModelTest::TestLoadUpdatingPreloadedURL(
size_t index_offset_from_default) {
- std::wstring prepopulated_url;
+ string16 prepopulated_url;
TemplateURL* t_url = CreateReplaceablePreloadedTemplateURL(
index_offset_from_default, &prepopulated_url);
t_url->set_safe_for_autoreplace(false);
- std::wstring original_url = t_url->url()->DisplayURL();
- ASSERT_STRNE(prepopulated_url.c_str(), original_url.c_str());
+ string16 original_url = t_url->url()->DisplayURL();
+ ASSERT_NE(prepopulated_url, original_url);
// Then add it to the model and save it all.
ChangeModelToLoadState();
model()->Add(t_url);
const TemplateURL* keyword_url =
- model()->GetTemplateURLForKeyword(L"unittest");
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_EQ(t_url, keyword_url);
- ASSERT_STREQ(original_url.c_str(), keyword_url->url()->DisplayURL().c_str());
+ ASSERT_EQ(original_url, keyword_url->url()->DisplayURL());
BlockTillServiceProcessesRequests();
// Now reload the model and verify that the merge updates the url.
ResetModel(true);
- keyword_url = model()->GetTemplateURLForKeyword(L"unittest");
+ keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(keyword_url != NULL);
- ASSERT_STREQ(prepopulated_url.c_str(),
- keyword_url->url()->DisplayURL().c_str());
+ ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL());
// Wait for any saves to finish.
BlockTillServiceProcessesRequests();
// Reload the model to verify that change was saved correctly.
ResetModel(true);
- keyword_url = model()->GetTemplateURLForKeyword(L"unittest");
+ keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(keyword_url != NULL);
- ASSERT_STREQ(prepopulated_url.c_str(),
- keyword_url->url()->DisplayURL().c_str());
+ ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL());
}
TEST_F(TemplateURLModelTest, MAYBE_Load) {
@@ -390,14 +389,15 @@ TEST_F(TemplateURLModelTest, AddUpdateRemove) {
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.google.com/foo/bar", 0, 0);
- t_url->set_keyword(L"keyword");
- t_url->set_short_name(L"google");
+ t_url->set_keyword(ASCIIToUTF16("keyword"));
+ t_url->set_short_name(ASCIIToUTF16("google"));
GURL favicon_url("http://favicon.url");
t_url->SetFavIconURL(favicon_url);
t_url->set_date_created(Time::FromTimeT(100));
t_url->set_safe_for_autoreplace(true);
model()->Add(t_url);
- ASSERT_TRUE(model()->CanReplaceKeyword(L"keyword", GURL(), NULL));
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"),
+ GURL(), NULL));
VerifyObserverCount(1);
BlockTillServiceProcessesRequests();
// We need to clone as model takes ownership of TemplateURL and will
@@ -410,24 +410,28 @@ TEST_F(TemplateURLModelTest, AddUpdateRemove) {
// Reload the model to verify it was actually saved to the database.
ResetModel(true);
ASSERT_EQ(1 + initial_count, model()->GetTemplateURLs().size());
- const TemplateURL* loaded_url = model()->GetTemplateURLForKeyword(L"keyword");
+ const TemplateURL* loaded_url =
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
ASSERT_TRUE(loaded_url != NULL);
AssertEquals(cloned_url, *loaded_url);
- ASSERT_TRUE(model()->CanReplaceKeyword(L"keyword", GURL(), NULL));
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"),
+ GURL(), NULL));
// Mutate an element and verify it succeeded.
- model()->ResetTemplateURL(loaded_url, L"a", L"b", "c");
- ASSERT_EQ(L"a", loaded_url->short_name());
- ASSERT_EQ(L"b", loaded_url->keyword());
+ model()->ResetTemplateURL(loaded_url, ASCIIToUTF16("a"),
+ ASCIIToUTF16("b"), "c");
+ ASSERT_EQ(ASCIIToUTF16("a"), loaded_url->short_name());
+ ASSERT_EQ(ASCIIToUTF16("b"), loaded_url->keyword());
ASSERT_EQ("c", loaded_url->url()->url());
ASSERT_FALSE(loaded_url->safe_for_autoreplace());
- ASSERT_TRUE(model()->CanReplaceKeyword(L"keyword", GURL(), NULL));
- ASSERT_FALSE(model()->CanReplaceKeyword(L"b", GURL(), NULL));
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"),
+ GURL(), NULL));
+ ASSERT_FALSE(model()->CanReplaceKeyword(ASCIIToUTF16("b"), GURL(), NULL));
cloned_url = *loaded_url;
BlockTillServiceProcessesRequests();
ResetModel(true);
ASSERT_EQ(1 + initial_count, model()->GetTemplateURLs().size());
- loaded_url = model()->GetTemplateURLForKeyword(L"b");
+ loaded_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("b"));
ASSERT_TRUE(loaded_url != NULL);
AssertEquals(cloned_url, *loaded_url);
@@ -436,28 +440,30 @@ TEST_F(TemplateURLModelTest, AddUpdateRemove) {
VerifyObserverCount(1);
ResetModel(true);
ASSERT_EQ(initial_count, model()->GetTemplateURLs().size());
- EXPECT_TRUE(model()->GetTemplateURLForKeyword(L"b") == NULL);
+ EXPECT_TRUE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("b")) == NULL);
}
TEST_F(TemplateURLModelTest, GenerateKeyword) {
- ASSERT_EQ(L"", TemplateURLModel::GenerateKeyword(GURL(), true));
+ ASSERT_EQ(string16(), TemplateURLModel::GenerateKeyword(GURL(), true));
// Shouldn't generate keywords for https.
- ASSERT_EQ(L"", TemplateURLModel::GenerateKeyword(GURL("https://blah"), true));
- ASSERT_EQ(L"foo", TemplateURLModel::GenerateKeyword(GURL("http://foo"),
- true));
+ ASSERT_EQ(string16(),
+ TemplateURLModel::GenerateKeyword(GURL("https://blah"), true));
+ ASSERT_EQ(ASCIIToUTF16("foo"),
+ TemplateURLModel::GenerateKeyword(GURL("http://foo"), true));
// www. should be stripped.
- ASSERT_EQ(L"foo", TemplateURLModel::GenerateKeyword(GURL("http://www.foo"),
- true));
+ ASSERT_EQ(ASCIIToUTF16("foo"),
+ TemplateURLModel::GenerateKeyword(GURL("http://www.foo"), true));
// Shouldn't generate keywords with paths, if autodetected.
- ASSERT_EQ(L"", TemplateURLModel::GenerateKeyword(GURL("http://blah/foo"),
- true));
- ASSERT_EQ(L"blah", TemplateURLModel::GenerateKeyword(GURL("http://blah/foo"),
- false));
+ ASSERT_EQ(string16(),
+ TemplateURLModel::GenerateKeyword(GURL("http://blah/foo"), true));
+ ASSERT_EQ(ASCIIToUTF16("blah"),
+ TemplateURLModel::GenerateKeyword(GURL("http://blah/foo"), false));
// FTP shouldn't generate a keyword.
- ASSERT_EQ(L"", TemplateURLModel::GenerateKeyword(GURL("ftp://blah/"), true));
+ ASSERT_EQ(string16(),
+ TemplateURLModel::GenerateKeyword(GURL("ftp://blah/"), true));
// Make sure we don't get a trailing /
- ASSERT_EQ(L"blah", TemplateURLModel::GenerateKeyword(GURL("http://blah/"),
- true));
+ ASSERT_EQ(ASCIIToUTF16("blah"),
+ TemplateURLModel::GenerateKeyword(GURL("http://blah/"), true));
}
TEST_F(TemplateURLModelTest, GenerateSearchURL) {
@@ -492,21 +498,21 @@ TEST_F(TemplateURLModelTest, ClearBrowsingData_Keywords) {
EXPECT_EQ(0U, model()->GetTemplateURLs().size());
// Create one with a 0 time.
- AddKeywordWithDate(L"key1", false, "http://foo1", "http://suggest1",
- "http://icon1", "UTF-8;UTF-16", L"name1", true, Time());
+ AddKeywordWithDate("key1", false, "http://foo1", "http://suggest1",
+ "http://icon1", "UTF-8;UTF-16", "name1", true, Time());
// Create one for now and +/- 1 day.
- AddKeywordWithDate(L"key2", false, "http://foo2", "http://suggest2",
- "http://icon2", "UTF-8;UTF-16", L"name2", true,
+ AddKeywordWithDate("key2", false, "http://foo2", "http://suggest2",
+ "http://icon2", "UTF-8;UTF-16", "name2", true,
now - one_day);
- AddKeywordWithDate(L"key3", false, "http://foo3", "", "", "", L"name3",
+ AddKeywordWithDate("key3", false, "http://foo3", "", "", "", "name3",
true, now);
- AddKeywordWithDate(L"key4", false, "http://foo4", "", "", "", L"name4",
+ AddKeywordWithDate("key4", false, "http://foo4", "", "", "", "name4",
true, now + one_day);
// Try the other three states.
- AddKeywordWithDate(L"key5", false, "http://foo5", "http://suggest5",
- "http://icon5", "UTF-8;UTF-16", L"name5", false, now);
- AddKeywordWithDate(L"key6", false, "http://foo6", "http://suggest6",
- "http://icon6", "UTF-8;UTF-16", L"name6", false,
+ AddKeywordWithDate("key5", false, "http://foo5", "http://suggest5",
+ "http://icon5", "UTF-8;UTF-16", "name5", false, now);
+ AddKeywordWithDate("key6", false, "http://foo6", "http://suggest6",
+ "http://icon6", "UTF-8;UTF-16", "name6", false,
month_ago);
// We just added a few items, validate them.
@@ -523,17 +529,17 @@ TEST_F(TemplateURLModelTest, ClearBrowsingData_Keywords) {
EXPECT_EQ(3U, model()->GetTemplateURLs().size());
// Make sure the right values remain.
- EXPECT_EQ(L"key1", model()->GetTemplateURLs()[0]->keyword());
+ EXPECT_EQ(ASCIIToUTF16("key1"), model()->GetTemplateURLs()[0]->keyword());
EXPECT_TRUE(model()->GetTemplateURLs()[0]->safe_for_autoreplace());
EXPECT_EQ(0U,
model()->GetTemplateURLs()[0]->date_created().ToInternalValue());
- EXPECT_EQ(L"key5", model()->GetTemplateURLs()[1]->keyword());
+ EXPECT_EQ(ASCIIToUTF16("key5"), model()->GetTemplateURLs()[1]->keyword());
EXPECT_FALSE(model()->GetTemplateURLs()[1]->safe_for_autoreplace());
EXPECT_EQ(now.ToInternalValue(),
model()->GetTemplateURLs()[1]->date_created().ToInternalValue());
- EXPECT_EQ(L"key6", model()->GetTemplateURLs()[2]->keyword());
+ EXPECT_EQ(ASCIIToUTF16("key6"), model()->GetTemplateURLs()[2]->keyword());
EXPECT_FALSE(model()->GetTemplateURLs()[2]->safe_for_autoreplace());
EXPECT_EQ(month_ago.ToInternalValue(),
model()->GetTemplateURLs()[2]->date_created().ToInternalValue());
@@ -549,8 +555,8 @@ TEST_F(TemplateURLModelTest, Reset) {
const size_t initial_count = model()->GetTemplateURLs().size();
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.google.com/foo/bar", 0, 0);
- t_url->set_keyword(L"keyword");
- t_url->set_short_name(L"google");
+ t_url->set_keyword(ASCIIToUTF16("keyword"));
+ t_url->set_short_name(ASCIIToUTF16("google"));
GURL favicon_url("http://favicon.url");
t_url->SetFavIconURL(favicon_url);
t_url->set_date_created(Time::FromTimeT(100));
@@ -560,8 +566,8 @@ TEST_F(TemplateURLModelTest, Reset) {
BlockTillServiceProcessesRequests();
// Reset the short name, keyword, url and make sure it takes.
- const std::wstring new_short_name(L"a");
- const std::wstring new_keyword(L"b");
+ const string16 new_short_name(ASCIIToUTF16("a"));
+ const string16 new_keyword(ASCIIToUTF16("b"));
const std::string new_url("c");
model()->ResetTemplateURL(t_url, new_short_name, new_keyword, new_url);
ASSERT_EQ(new_short_name, t_url->short_name());
@@ -570,7 +576,8 @@ TEST_F(TemplateURLModelTest, Reset) {
// Make sure the mappings in the model were updated.
ASSERT_TRUE(model()->GetTemplateURLForKeyword(new_keyword) == t_url);
- ASSERT_TRUE(model()->GetTemplateURLForKeyword(L"keyword") == NULL);
+ ASSERT_TRUE(
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")) == NULL);
TemplateURL last_url = *t_url;
@@ -587,8 +594,8 @@ TEST_F(TemplateURLModelTest, DefaultSearchProvider) {
// Add a new TemplateURL.
VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
- TemplateURL* t_url = AddKeywordWithDate(L"key1", false, "http://foo1",
- "http://sugg1", "http://icon1", "UTF-8;UTF-16", L"name1", true, Time());
+ TemplateURL* t_url = AddKeywordWithDate("key1", false, "http://foo1",
+ "http://sugg1", "http://icon1", "UTF-8;UTF-16", "name1", true, Time());
test_util_.ResetObserverCount();
model()->SetDefaultSearchProvider(t_url);
@@ -619,8 +626,8 @@ TEST_F(TemplateURLModelTest, TemplateURLWithNoKeyword) {
const size_t initial_count = model()->GetTemplateURLs().size();
- AddKeywordWithDate(std::wstring(), false, "http://foo1", "http://sugg1",
- "http://icon1", "UTF-8;UTF-16", L"name1", true, Time());
+ AddKeywordWithDate("", false, "http://foo1", "http://sugg1",
+ "http://icon1", "UTF-8;UTF-16", "name1", true, Time());
// We just added a few items, validate them.
ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
@@ -642,36 +649,40 @@ TEST_F(TemplateURLModelTest, TemplateURLWithNoKeyword) {
TEST_F(TemplateURLModelTest, CantReplaceWithSameKeyword) {
ChangeModelToLoadState();
- ASSERT_TRUE(model()->CanReplaceKeyword(L"foo", GURL(), NULL));
- TemplateURL* t_url = AddKeywordWithDate(L"foo", false, "http://foo1",
- "http://sugg1", "http://icon1", "UTF-8;UTF-16", L"name1", true, Time());
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"), GURL(), NULL));
+ TemplateURL* t_url = AddKeywordWithDate("foo", false, "http://foo1",
+ "http://sugg1", "http://icon1", "UTF-8;UTF-16", "name1", true, Time());
// Can still replace, newly added template url is marked safe to replace.
- ASSERT_TRUE(model()->CanReplaceKeyword(L"foo", GURL("http://foo2"), NULL));
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"),
+ GURL("http://foo2"), NULL));
// ResetTemplateURL marks the TemplateURL as unsafe to replace, so it should
// no longer be replaceable.
model()->ResetTemplateURL(t_url, t_url->short_name(), t_url->keyword(),
t_url->url()->url());
- ASSERT_FALSE(model()->CanReplaceKeyword(L"foo", GURL("http://foo2"), NULL));
+ ASSERT_FALSE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"),
+ GURL("http://foo2"), NULL));
}
TEST_F(TemplateURLModelTest, CantReplaceWithSameHosts) {
ChangeModelToLoadState();
- ASSERT_TRUE(model()->CanReplaceKeyword(L"foo", GURL("http://foo.com"), NULL));
- TemplateURL* t_url = AddKeywordWithDate(L"foo", false, "http://foo.com",
- "http://sugg1", "http://icon1", "UTF-8;UTF-16", L"name1", true, Time());
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"),
+ GURL("http://foo.com"), NULL));
+ TemplateURL* t_url = AddKeywordWithDate("foo", false, "http://foo.com",
+ "http://sugg1", "http://icon1", "UTF-8;UTF-16", "name1", true, Time());
// Can still replace, newly added template url is marked safe to replace.
- ASSERT_TRUE(model()->CanReplaceKeyword(L"bar", GURL("http://foo.com"), NULL));
+ ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("bar"),
+ GURL("http://foo.com"), NULL));
// ResetTemplateURL marks the TemplateURL as unsafe to replace, so it should
// no longer be replaceable.
model()->ResetTemplateURL(t_url, t_url->short_name(), t_url->keyword(),
t_url->url()->url());
- ASSERT_FALSE(model()->CanReplaceKeyword(L"bar",
+ ASSERT_FALSE(model()->CanReplaceKeyword(ASCIIToUTF16("bar"),
GURL("http://foo.com"), NULL));
}
@@ -692,7 +703,7 @@ TEST_F(TemplateURLModelTest, DefaultSearchProviderLoadedFromPrefs) {
template_url->SetURL("http://url", 0, 0);
template_url->SetSuggestionsURL("http://url2", 0, 0);
template_url->SetInstantURL("http://instant", 0, 0);
- template_url->set_short_name(L"a");
+ template_url->set_short_name(ASCIIToUTF16("a"));
template_url->set_safe_for_autoreplace(true);
template_url->set_date_created(Time::FromTimeT(100));
@@ -722,7 +733,7 @@ TEST_F(TemplateURLModelTest, DefaultSearchProviderLoadedFromPrefs) {
ASSERT_EQ("http://url2", default_turl->suggestions_url()->url());
ASSERT_TRUE(default_turl->instant_url());
EXPECT_EQ("http://instant", default_turl->instant_url()->url());
- ASSERT_EQ(L"a", default_turl->short_name());
+ ASSERT_EQ(ASCIIToUTF16("a"), default_turl->short_name());
ASSERT_EQ(id, default_turl->id());
// Now do a load and make sure the default search provider really takes.
@@ -782,20 +793,20 @@ TEST_F(TemplateURLModelTest, BuildQueryTerms) {
TEST_F(TemplateURLModelTest, UpdateKeywordSearchTermsForURL) {
struct TestData {
const std::string url;
- const std::wstring term;
+ const string16 term;
} data[] = {
- { "http://foo/", L"" },
- { "http://foo/foo?q=xx", L"" },
- { "http://x/bar?q=xx", L"" },
- { "http://x/foo?y=xx", L"" },
- { "http://x/foo?q=xx", L"xx" },
- { "http://x/foo?a=b&q=xx", L"xx" },
- { "http://x/foo?q=b&q=xx", L"" },
+ { "http://foo/", string16() },
+ { "http://foo/foo?q=xx", string16() },
+ { "http://x/bar?q=xx", string16() },
+ { "http://x/foo?y=xx", string16() },
+ { "http://x/foo?q=xx", ASCIIToUTF16("xx") },
+ { "http://x/foo?a=b&q=xx", ASCIIToUTF16("xx") },
+ { "http://x/foo?q=b&q=xx", string16() },
};
ChangeModelToLoadState();
- AddKeywordWithDate(L"x", false, "http://x/foo?q={searchTerms}",
- "http://sugg1", "http://icon1", "UTF-8;UTF-16", L"name", false, Time());
+ AddKeywordWithDate("x", false, "http://x/foo?q={searchTerms}",
+ "http://sugg1", "http://icon1", "UTF-8;UTF-16", "name", false, Time());
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
history::URLVisitedDetails details;
@@ -816,15 +827,15 @@ TEST_F(TemplateURLModelTest, DontUpdateKeywordSearchForNonReplaceable) {
};
ChangeModelToLoadState();
- AddKeywordWithDate(L"x", false, "http://x/foo", "http://sugg1",
- "http://icon1", "UTF-8;UTF-16", L"name", false, Time());
+ AddKeywordWithDate("x", false, "http://x/foo", "http://sugg1",
+ "http://icon1", "UTF-8;UTF-16", "name", false, Time());
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
history::URLVisitedDetails details;
details.row = history::URLRow(GURL(data[i].url));
details.transition = 0;
model()->UpdateKeywordSearchTermsForURL(details);
- ASSERT_EQ(std::wstring(), GetAndClearSearchTerm());
+ ASSERT_EQ(string16(), GetAndClearSearchTerm());
}
}
@@ -834,12 +845,12 @@ TEST_F(TemplateURLModelTest, ChangeGoogleBaseValue) {
// test.
ChangeModelToLoadState();
SetGoogleBaseURL("http://google.com/");
- const TemplateURL* t_url = AddKeywordWithDate(std::wstring(), true,
+ const TemplateURL* t_url = AddKeywordWithDate("", true,
"{google:baseURL}?q={searchTerms}", "http://sugg1", "http://icon1",
- "UTF-8;UTF-16", L"name", false, Time());
+ "UTF-8;UTF-16", "name", false, Time());
ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.com"));
EXPECT_EQ("google.com", t_url->url()->GetHost());
- EXPECT_EQ(L"google.com", t_url->keyword());
+ EXPECT_EQ(ASCIIToUTF16("google.com"), t_url->keyword());
// Change the Google base url.
test_util_.ResetObserverCount();
@@ -850,9 +861,9 @@ TEST_F(TemplateURLModelTest, ChangeGoogleBaseValue) {
ASSERT_EQ(t_url, model()->GetTemplateURLForHost("foo.com"));
EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL);
EXPECT_EQ("foo.com", t_url->url()->GetHost());
- EXPECT_EQ(L"foo.com", t_url->keyword());
+ EXPECT_EQ(ASCIIToUTF16("foo.com"), t_url->keyword());
EXPECT_EQ("http://foo.com/?q=x", t_url->url()->ReplaceSearchTerms(*t_url,
- L"x", TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ ASCIIToUTF16("x"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
}
struct QueryHistoryCallbackImpl {
@@ -881,16 +892,16 @@ TEST_F(TemplateURLModelTest, GenerateVisitOnKeyword) {
// Create a keyword.
TemplateURL* t_url = AddKeywordWithDate(
- L"keyword", false, "http://foo.com/foo?query={searchTerms}",
- "http://sugg1", "http://icon1", "UTF-8;UTF-16", L"keyword", true,
- base::Time::Now());
+ "keyword", false, "http://foo.com/foo?query={searchTerms}",
+ "http://sugg1", "http://icon1", "UTF-8;UTF-16", "keyword",
+ true, base::Time::Now());
// Add a visit that matches the url of the keyword.
HistoryService* history =
profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
history->AddPage(
- GURL(t_url->url()->ReplaceSearchTerms(*t_url, L"blah", 0,
- std::wstring())),
+ GURL(t_url->url()->ReplaceSearchTerms(*t_url, ASCIIToUTF16("blah"), 0,
+ string16())),
NULL, 0, GURL(), PageTransition::KEYWORD, history::RedirectList(),
history::SOURCE_BROWSED, false);
@@ -922,12 +933,14 @@ TEST_F(TemplateURLModelTest, LoadDeletesUnusedProvider) {
TemplateURL* t_url = CreatePreloadedTemplateURL();
ChangeModelToLoadState();
model()->Add(t_url);
- ASSERT_TRUE(model()->GetTemplateURLForKeyword(L"unittest") != NULL);
+ ASSERT_TRUE(
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")) != NULL);
BlockTillServiceProcessesRequests();
// Ensure that merging clears this engine.
ResetModel(true);
- ASSERT_TRUE(model()->GetTemplateURLForKeyword(L"unittest") == NULL);
+ ASSERT_TRUE(
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")) == NULL);
// Wait for any saves to finish.
BlockTillServiceProcessesRequests();
@@ -935,7 +948,8 @@ TEST_F(TemplateURLModelTest, LoadDeletesUnusedProvider) {
// Reload the model to verify that the database was updated as a result of the
// merge.
ResetModel(true);
- ASSERT_TRUE(model()->GetTemplateURLForKeyword(L"unittest") == NULL);
+ ASSERT_TRUE(
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")) == NULL);
}
// Make sure that load routine doesn't delete prepopulated engines that no
@@ -949,7 +963,7 @@ TEST_F(TemplateURLModelTest, LoadRetainsModifiedProvider) {
// Do the copy after t_url is added so that the id is set.
TemplateURL copy_t_url = *t_url;
- ASSERT_EQ(t_url, model()->GetTemplateURLForKeyword(L"unittest"));
+ ASSERT_EQ(t_url, model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")));
// Wait for any saves to finish.
BlockTillServiceProcessesRequests();
@@ -957,7 +971,7 @@ TEST_F(TemplateURLModelTest, LoadRetainsModifiedProvider) {
// Ensure that merging won't clear it if the user has edited it.
ResetModel(true);
const TemplateURL* url_for_unittest =
- model()->GetTemplateURLForKeyword(L"unittest");
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(url_for_unittest != NULL);
AssertEquals(copy_t_url, *url_for_unittest);
@@ -966,7 +980,8 @@ TEST_F(TemplateURLModelTest, LoadRetainsModifiedProvider) {
// Reload the model to verify that save/reload retains the item.
ResetModel(true);
- ASSERT_TRUE(model()->GetTemplateURLForKeyword(L"unittest") != NULL);
+ ASSERT_TRUE(
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")) != NULL);
}
// Make sure that load routine doesn't delete
@@ -1003,7 +1018,7 @@ TEST_F(TemplateURLModelTest, LoadRetainsDefaultProvider) {
// internal state is correct.
TemplateURL copy_t_url = *t_url;
- ASSERT_EQ(t_url, model()->GetTemplateURLForKeyword(L"unittest"));
+ ASSERT_EQ(t_url, model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")));
ASSERT_EQ(t_url, model()->GetDefaultSearchProvider());
BlockTillServiceProcessesRequests();
@@ -1012,7 +1027,7 @@ TEST_F(TemplateURLModelTest, LoadRetainsDefaultProvider) {
ResetModel(true);
{
const TemplateURL* keyword_url =
- model()->GetTemplateURLForKeyword(L"unittest");
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(keyword_url != NULL);
AssertEquals(copy_t_url, *keyword_url);
ASSERT_EQ(keyword_url, model()->GetDefaultSearchProvider());
@@ -1025,7 +1040,7 @@ TEST_F(TemplateURLModelTest, LoadRetainsDefaultProvider) {
ResetModel(true);
{
const TemplateURL* keyword_url =
- model()->GetTemplateURLForKeyword(L"unittest");
+ model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(keyword_url != NULL);
AssertEquals(copy_t_url, *keyword_url);
ASSERT_EQ(keyword_url, model()->GetDefaultSearchProvider());
@@ -1048,7 +1063,7 @@ TEST_F(TemplateURLModelTest, LoadUpdatesSearchURL) {
// This test basically verifies that no asserts or crashes occur
// during this operation.
TEST_F(TemplateURLModelTest, LoadDoesAutoKeywordUpdate) {
- std::wstring prepopulated_url;
+ string16 prepopulated_url;
TemplateURL* t_url = CreateReplaceablePreloadedTemplateURL(
0, &prepopulated_url);
t_url->set_safe_for_autoreplace(false);
@@ -1092,8 +1107,8 @@ TEST_F(TemplateURLModelTest, TestManagedDefaultSearch) {
test_util_.ResetObserverCount();
// Set a regular default search provider.
- TemplateURL* regular_default = AddKeywordWithDate(L"key1", false,
- "http://foo1", "http://sugg1", "http://icon1", "UTF-8;UTF-16", L"name1",
+ TemplateURL* regular_default = AddKeywordWithDate("key1", false,
+ "http://foo1", "http://sugg1", "http://icon1", "UTF-8;UTF-16", "name1",
true, Time());
VerifyObserverCount(1);
model()->SetDefaultSearchProvider(regular_default);
@@ -1118,7 +1133,7 @@ TEST_F(TemplateURLModelTest, TestManagedDefaultSearch) {
scoped_ptr<TemplateURL> expected_managed_default1(new TemplateURL());
expected_managed_default1->SetURL(kSearchURL, 0, 0);
expected_managed_default1->SetFavIconURL(GURL(kIconURL));
- expected_managed_default1->set_short_name(L"test1");
+ expected_managed_default1->set_short_name(ASCIIToUTF16("test1"));
std::vector<std::string> encodings_vector;
base::SplitString(kEncodings, ';', &encodings_vector);
expected_managed_default1->set_input_encodings(encodings_vector);
@@ -1142,7 +1157,7 @@ TEST_F(TemplateURLModelTest, TestManagedDefaultSearch) {
scoped_ptr<TemplateURL> expected_managed_default2(new TemplateURL());
expected_managed_default2->SetURL(kNewSearchURL, 0, 0);
expected_managed_default2->SetSuggestionsURL(kNewSuggestURL, 0, 0);
- expected_managed_default2->set_short_name(L"test2");
+ expected_managed_default2->set_short_name(ASCIIToUTF16("test2"));
expected_managed_default2->set_show_in_default_list(true);
actual_managed_default = model()->GetDefaultSearchProvider();
ExpectSimilar(actual_managed_default, expected_managed_default2.get());
diff --git a/chrome/browser/search_engines/template_url_parser.cc b/chrome/browser/search_engines/template_url_parser.cc
index 245ca3f..e671d63 100644
--- a/chrome/browser/search_engines/template_url_parser.cc
+++ b/chrome/browser/search_engines/template_url_parser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -138,7 +138,7 @@ class ParsingContext {
TemplateURL* template_url() { return url_; }
- void AddImageRef(const std::wstring& type, int width, int height) {
+ void AddImageRef(const std::string& type, int width, int height) {
if (width > 0 && height > 0)
current_image_.reset(new TemplateURL::ImageRef(type, width, height));
}
@@ -147,9 +147,9 @@ class ParsingContext {
current_image_.reset();
}
- void SetImageURL(const std::wstring& url) {
+ void SetImageURL(const GURL& url) {
if (current_image_.get()) {
- current_image_->url = GURL(WideToUTF8(url));
+ current_image_->url = url;
url_->add_image_ref(*current_image_);
current_image_.reset();
}
@@ -159,11 +159,11 @@ class ParsingContext {
string_.clear();
}
- void AppendString(const std::wstring& string) {
+ void AppendString(const string16& string) {
string_ += string;
}
- const std::wstring& GetString() {
+ const string16& GetString() {
return string_;
}
@@ -233,7 +233,7 @@ class ParsingContext {
scoped_ptr<TemplateURL::ImageRef> current_image_;
// Character content for the current element.
- std::wstring string_;
+ string16 string_;
TemplateURLParser::ParameterFilter* parameter_filter_;
@@ -259,12 +259,8 @@ class ParsingContext {
std::map<std::string, ParsingContext::ElementType>*
ParsingContext::kElementNameToElementTypeMap = NULL;
-std::wstring XMLCharToWide(const xmlChar* value) {
- return UTF8ToWide(std::string((const char*)value));
-}
-
-std::wstring XMLCharToWide(const xmlChar* value, int length) {
- return UTF8ToWide(std::string((const char*)value, length));
+string16 XMLCharToUTF16(const xmlChar* value, int length) {
+ return UTF8ToUTF16(std::string((const char*)value, length));
}
std::string XMLCharToString(const xmlChar* value) {
@@ -344,12 +340,12 @@ void ParseImage(const xmlChar** atts, ParsingContext* context) {
const xmlChar** attributes = atts;
int width = 0;
int height = 0;
- std::wstring type;
+ std::string type;
while (*attributes) {
std::string name(XMLCharToString(*attributes));
const xmlChar* value = attributes[1];
if (name == kImageTypeAttribute) {
- type = XMLCharToWide(value);
+ type = XMLCharToString(value);
} else if (name == kImageWidthAttribute) {
base::StringToInt(XMLCharToString(value), &width);
} else if (name == kImageHeightAttribute) {
@@ -368,7 +364,6 @@ void ParseParam(const xmlChar** atts, ParsingContext* context) {
return;
const xmlChar** attributes = atts;
- std::wstring type;
std::string key, value;
while (*attributes) {
std::string name(XMLCharToString(*attributes));
@@ -487,14 +482,14 @@ void EndElementImpl(void *ctx, const xmlChar *name) {
context->template_url()->set_description(context->GetString());
break;
case ParsingContext::IMAGE: {
- GURL image_url(WideToUTF8(context->GetString()));
+ GURL image_url(UTF16ToUTF8(context->GetString()));
if (image_url.SchemeIs(chrome::kDataScheme)) {
// TODO (jcampan): bug 1169256: when dealing with data URL, we need to
// decode the data URL in the renderer. For now, we'll just point to the
// fav icon from the URL.
context->set_derive_image_from_url(true);
} else {
- context->SetImageURL(context->GetString());
+ context->SetImageURL(image_url);
}
context->EndImage();
break;
@@ -503,7 +498,7 @@ void EndElementImpl(void *ctx, const xmlChar *name) {
context->template_url()->add_language(context->GetString());
break;
case ParsingContext::INPUT_ENCODING: {
- std::string input_encoding = WideToASCII(context->GetString());
+ std::string input_encoding = UTF16ToASCII(context->GetString());
if (IsValidEncodingString(input_encoding))
context->template_url()->add_input_encoding(input_encoding);
break;
@@ -520,7 +515,7 @@ void EndElementImpl(void *ctx, const xmlChar *name) {
void CharactersImpl(void *ctx, const xmlChar *ch, int len) {
ParsingContext* context = reinterpret_cast<ParsingContext*>(ctx);
- context->AppendString(XMLCharToWide(ch, len));
+ context->AppendString(XMLCharToUTF16(ch, len));
}
// Returns true if the ref is null, or the url wrapped by ref is
diff --git a/chrome/browser/search_engines/template_url_parser_unittest.cc b/chrome/browser/search_engines/template_url_parser_unittest.cc
index 14d6203..c339092 100644
--- a/chrome/browser/search_engines/template_url_parser_unittest.cc
+++ b/chrome/browser/search_engines/template_url_parser_unittest.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_parser.h"
#include "chrome/common/chrome_paths.h"
@@ -84,7 +85,7 @@ TEST_F(TemplateURLParserTest, TestDictionary) {
return;
ParseFile("dictionary.xml", NULL);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"Dictionary.com", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("Dictionary.com"), template_url_.short_name());
EXPECT_TRUE(template_url_.GetFavIconURL() ==
GURL("http://cache.lexico.com/g/d/favicon.ico"));
EXPECT_TRUE(template_url_.url() != NULL);
@@ -98,7 +99,7 @@ TEST_F(TemplateURLParserTest, TestMSDN) {
return;
ParseFile("msdn.xml", NULL);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"Search \" MSDN", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("Search \" MSDN"), template_url_.short_name());
EXPECT_TRUE(template_url_.GetFavIconURL() ==
GURL("http://search.msdn.microsoft.com/search/favicon.ico"));
EXPECT_TRUE(template_url_.url() != NULL);
@@ -112,7 +113,7 @@ TEST_F(TemplateURLParserTest, TestWikipedia) {
return;
ParseFile("wikipedia.xml", NULL);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"Wikipedia (English)", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("Wikipedia (English)"), template_url_.short_name());
EXPECT_TRUE(template_url_.GetFavIconURL() ==
GURL("http://en.wikipedia.org/favicon.ico"));
EXPECT_TRUE(template_url_.url() != NULL);
@@ -163,7 +164,7 @@ TEST_F(TemplateURLParserTest, TestFirefoxEbay) {
ParamFilterImpl filter("ebay", "ebay");
ParseFile("firefox_ebay.xml", &filter);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"eBay", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("eBay"), template_url_.short_name());
EXPECT_TRUE(template_url_.url() != NULL);
EXPECT_TRUE(template_url_.url()->SupportsReplacement());
std::string exp_url =
@@ -184,7 +185,7 @@ TEST_F(TemplateURLParserTest, TestFirefoxWebster) {
ParamFilterImpl filter("", "Mozilla");
ParseFile("firefox_webster.xml", &filter);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"Webster", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("Webster"), template_url_.short_name());
EXPECT_TRUE(template_url_.url() != NULL);
EXPECT_TRUE(template_url_.url()->SupportsReplacement());
EXPECT_EQ("http://www.webster.com/cgi-bin/dictionary?va={searchTerms}",
@@ -202,7 +203,7 @@ TEST_F(TemplateURLParserTest, TestFirefoxYahoo) {
ParamFilterImpl filter("", "Mozilla");
ParseFile("firefox_yahoo.xml", &filter);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"Yahoo", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("Yahoo"), template_url_.short_name());
EXPECT_TRUE(template_url_.url() != NULL);
EXPECT_TRUE(template_url_.url()->SupportsReplacement());
EXPECT_EQ("http://ff.search.yahoo.com/gossip?"
@@ -225,7 +226,7 @@ TEST_F(TemplateURLParserTest, TestPostSuggestion) {
ParamFilterImpl filter("", "Mozilla");
ParseFile("post_suggestion.xml", &filter);
ASSERT_TRUE(parse_result_);
- EXPECT_EQ(L"Yahoo", template_url_.short_name());
+ EXPECT_EQ(ASCIIToUTF16("Yahoo"), template_url_.short_name());
EXPECT_TRUE(template_url_.url() != NULL);
EXPECT_TRUE(template_url_.url()->SupportsReplacement());
EXPECT_TRUE(template_url_.suggestions_url() == NULL);
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index fbd89b4..6cb64bd 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -3379,11 +3379,11 @@ TemplateURL* MakePrepopulatedTemplateURL(const wchar_t* name,
new_turl->SetSuggestionsURL(WideToUTF8(suggest_url), 0, 0);
if (instant_url)
new_turl->SetInstantURL(WideToUTF8(instant_url), 0, 0);
- new_turl->set_short_name(name);
+ new_turl->set_short_name(WideToUTF16Hack(name));
if (keyword == NULL)
new_turl->set_autogenerate_keyword(true);
else
- new_turl->set_keyword(keyword);
+ new_turl->set_keyword(WideToUTF16Hack(keyword));
new_turl->set_show_in_default_list(true);
new_turl->set_safe_for_autoreplace(true);
new_turl->set_date_created(Time());
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
index f79f6b6..1261915 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/file_util.h"
#include "base/scoped_temp_dir.h"
#include "base/scoped_vector.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/search_engine_type.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -119,8 +120,8 @@ TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
&prefs, &(t_urls.get()), &default_index);
ASSERT_EQ(1u, t_urls.size());
- EXPECT_EQ(L"foo", t_urls[0]->short_name());
- EXPECT_EQ(L"fook", t_urls[0]->keyword());
+ EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name());
+ EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword());
EXPECT_EQ("foo.com", t_urls[0]->url()->GetHost());
EXPECT_EQ("foi.com", t_urls[0]->GetFavIconURL().host());
EXPECT_EQ(1u, t_urls[0]->input_encodings().size());
diff --git a/chrome/browser/search_engines/template_url_table_model.cc b/chrome/browser/search_engines/template_url_table_model.cc
index 453b98d..18c239d 100644
--- a/chrome/browser/search_engines/template_url_table_model.cc
+++ b/chrome/browser/search_engines/template_url_table_model.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -180,7 +180,7 @@ string16 TemplateURLTableModel::GetText(int row, int col_id) {
switch (col_id) {
case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: {
- string16 url_short_name = WideToUTF16Hack(url.short_name());
+ string16 url_short_name = url.short_name();
// TODO(xji): Consider adding a special case if the short name is a URL,
// since those should always be displayed LTR. Please refer to
// http://crbug.com/6726 for more information.
@@ -195,7 +195,7 @@ string16 TemplateURLTableModel::GetText(int row, int col_id) {
case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: {
// Keyword should be domain name. Force it to have LTR directionality.
- string16 keyword = WideToUTF16(url.keyword());
+ string16 keyword = url.keyword();
keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword);
return keyword;
}
@@ -279,8 +279,7 @@ void TemplateURLTableModel::ModifyTemplateURL(int index,
DCHECK(index >= 0 && index <= RowCount());
const TemplateURL* template_url = &GetTemplateURL(index);
template_url_model_->RemoveObserver(this);
- template_url_model_->ResetTemplateURL(template_url, UTF16ToWideHack(title),
- UTF16ToWideHack(keyword), url);
+ template_url_model_->ResetTemplateURL(template_url, title, keyword, url);
if (template_url_model_->GetDefaultSearchProvider() == template_url &&
!TemplateURL::SupportsReplacement(template_url)) {
// The entry was the default search provider, but the url has been modified
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index 3faa2aa..819164c 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -28,8 +28,8 @@ class TestSearchTermsData : public SearchTermsData {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
// Returns the value for the Chrome Omnibox rlz.
- virtual std::wstring GetRlzParameterValue() const {
- return L"";
+ virtual string16 GetRlzParameterValue() const {
+ return string16();
}
#endif
@@ -68,15 +68,16 @@ TEST_F(TemplateURLTest, TestValidWithComplete) {
TEST_F(TemplateURLTest, URLRefTestSearchTerms) {
struct SearchTermsCase {
const char* url;
- const wchar_t* terms;
+ const string16 terms;
const char* output;
} search_term_cases[] = {
- { "http://foo{searchTerms}", L"sea rch/bar", "http://foosea%20rch/bar" },
- { "http://foo{searchTerms}?boo=abc", L"sea rch/bar",
+ { "http://foo{searchTerms}", ASCIIToUTF16("sea rch/bar"),
+ "http://foosea%20rch/bar" },
+ { "http://foo{searchTerms}?boo=abc", ASCIIToUTF16("sea rch/bar"),
"http://foosea%20rch/bar?boo=abc" },
- { "http://foo/?boo={searchTerms}", L"sea rch/bar",
+ { "http://foo/?boo={searchTerms}", ASCIIToUTF16("sea rch/bar"),
"http://foo/?boo=sea+rch%2Fbar" },
- { "http://en.wikipedia.org/{searchTerms}", L"wiki/?",
+ { "http://en.wikipedia.org/{searchTerms}", ASCIIToUTF16("wiki/?"),
"http://en.wikipedia.org/wiki/%3F" }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(search_term_cases); ++i) {
@@ -87,7 +88,7 @@ TEST_F(TemplateURLTest, URLRefTestSearchTerms) {
ASSERT_TRUE(ref.SupportsReplacement());
GURL result = GURL(ref.ReplaceSearchTerms(t_url, value.terms,
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ(value.output, result.spec());
}
@@ -98,8 +99,8 @@ TEST_F(TemplateURLTest, URLRefTestCount) {
TemplateURLRef ref("http://foo{searchTerms}{count?}", 0, 0);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://foox/", result.spec());
}
@@ -109,8 +110,8 @@ TEST_F(TemplateURLTest, URLRefTestCount2) {
TemplateURLRef ref("http://foo{searchTerms}{count}", 0, 0);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://foox10/", result.spec());
}
@@ -121,8 +122,8 @@ TEST_F(TemplateURLTest, URLRefTestIndices) {
1, 2);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://fooxxy/", result.spec());
}
@@ -132,8 +133,8 @@ TEST_F(TemplateURLTest, URLRefTestIndices2) {
TemplateURLRef ref("http://foo{searchTerms}x{startIndex}y{startPage}", 1, 2);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://fooxx1y2/", result.spec());
}
@@ -144,8 +145,8 @@ TEST_F(TemplateURLTest, URLRefTestEncoding) {
"http://foo{searchTerms}x{inputEncoding?}y{outputEncoding?}a", 1, 2);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://fooxxutf-8ya/", result.spec());
}
@@ -156,8 +157,8 @@ TEST_F(TemplateURLTest, InputEncodingBeforeSearchTerm) {
"http://foox{inputEncoding?}a{searchTerms}y{outputEncoding?}b", 1, 2);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://fooxutf-8axyb/", result.spec());
}
@@ -168,8 +169,8 @@ TEST_F(TemplateURLTest, URLRefTestEncoding2) {
"http://foo{searchTerms}x{inputEncoding}y{outputEncoding}a", 1, 2);
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
- GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ("http://fooxxutf-8yutf-8a/", result.spec());
}
@@ -177,12 +178,12 @@ TEST_F(TemplateURLTest, URLRefTestEncoding2) {
TEST_F(TemplateURLTest, URLRefTestSearchTermsUsingTermsData) {
struct SearchTermsCase {
const char* url;
- const wchar_t* terms;
+ const string16 terms;
const char* output;
} search_term_cases[] = {
- { "{google:baseURL}{language}{searchTerms}", L"",
+ { "{google:baseURL}{language}{searchTerms}", string16(),
"http://example.com/e/yy" },
- { "{google:baseSuggestURL}{searchTerms}", L"",
+ { "{google:baseSuggestURL}{searchTerms}", string16(),
"http://clients1.example.com/complete/" }
};
@@ -196,7 +197,7 @@ TEST_F(TemplateURLTest, URLRefTestSearchTermsUsingTermsData) {
ASSERT_TRUE(ref.SupportsReplacement());
GURL result = GURL(ref.ReplaceSearchTermsUsingTermsData(
t_url, value.terms,
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring(),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16(),
search_terms_data));
ASSERT_TRUE(result.is_valid());
ASSERT_EQ(value.output, result.spec());
@@ -206,21 +207,21 @@ TEST_F(TemplateURLTest, URLRefTestSearchTermsUsingTermsData) {
TEST_F(TemplateURLTest, URLRefTermToWide) {
struct ToWideCase {
const char* encoded_search_term;
- const wchar_t* expected_decoded_term;
+ const string16 expected_decoded_term;
} to_wide_cases[] = {
- {"hello+world", L"hello world"},
+ {"hello+world", ASCIIToUTF16("hello world")},
// Test some big-5 input.
- {"%a7A%A6%6e+to+you", L"\x4f60\x597d to you"},
+ {"%a7A%A6%6e+to+you", WideToUTF16(L"\x4f60\x597d to you")},
// Test some UTF-8 input. We should fall back to this when the encoding
// doesn't look like big-5. We have a '5' in the middle, which is an invalid
// Big-5 trailing byte.
- {"%e4%bd%a05%e5%a5%bd+to+you", L"\x4f60\x35\x597d to you"},
+ {"%e4%bd%a05%e5%a5%bd+to+you", WideToUTF16(L"\x4f60\x35\x597d to you")},
// Undecodable input should stay escaped.
- {"%91%01+abcd", L"%91%01 abcd"},
+ {"%91%01+abcd", WideToUTF16(L"%91%01 abcd")},
// Make sure we convert %2B to +.
- {"C%2B%2B", L"C++"},
+ {"C%2B%2B", ASCIIToUTF16("C++")},
// C%2B is escaped as C%252B, make sure we unescape it properly.
- {"C%252B", L"C%2B"},
+ {"C%252B", ASCIIToUTF16("C%2B")},
};
TemplateURL t_url;
@@ -235,10 +236,10 @@ TEST_F(TemplateURLTest, URLRefTermToWide) {
ASSERT_TRUE(ref.SupportsReplacement());
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(to_wide_cases); i++) {
- std::wstring result = ref.SearchTermToWide(t_url,
+ string16 result = ref.SearchTermToString16(t_url,
to_wide_cases[i].encoded_search_term);
- EXPECT_EQ(std::wstring(to_wide_cases[i].expected_decoded_term), result);
+ EXPECT_EQ(to_wide_cases[i].expected_decoded_term, result);
}
}
@@ -258,16 +259,16 @@ TEST_F(TemplateURLTest, SetFavIcon) {
TEST_F(TemplateURLTest, DisplayURLToURLRef) {
struct TestData {
const std::string url;
- const std::wstring expected_result;
+ const string16 expected_result;
} data[] = {
{ "http://foo{searchTerms}x{inputEncoding}y{outputEncoding}a",
- L"http://foo%sx{inputEncoding}y{outputEncoding}a" },
+ ASCIIToUTF16("http://foo%sx{inputEncoding}y{outputEncoding}a") },
{ "http://X",
- L"http://X" },
+ ASCIIToUTF16("http://X") },
{ "http://foo{searchTerms",
- L"http://foo{searchTerms" },
+ ASCIIToUTF16("http://foo{searchTerms") },
{ "http://foo{searchTerms}{language}",
- L"http://foo%s{language}" },
+ ASCIIToUTF16("http://foo%s{language}") },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
TemplateURLRef ref(data[i].url, 1, 2);
@@ -316,8 +317,8 @@ TEST_F(TemplateURLTest, ReplaceSearchTerms) {
std::string expected_result = data[i].expected_result;
ReplaceSubstringsAfterOffset(&expected_result, 0, "{language}",
g_browser_process->GetApplicationLocale());
- GURL result = GURL(ref.ReplaceSearchTerms(turl, L"X",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ GURL result = GURL(ref.ReplaceSearchTerms(turl, ASCIIToUTF16("X"),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
EXPECT_TRUE(result.is_valid());
EXPECT_EQ(expected_result, result.spec());
}
@@ -329,13 +330,15 @@ TEST_F(TemplateURLTest, ReplaceSearchTerms) {
TEST_F(TemplateURLTest, ReplaceArbitrarySearchTerms) {
struct TestData {
const std::string encoding;
- const std::wstring search_term;
+ const string16 search_term;
const std::string url;
const std::string expected_result;
} data[] = {
- { "BIG5", L"\x60BD", "http://foo/?{searchTerms}{inputEncoding}",
+ { "BIG5", WideToUTF16(L"\x60BD"),
+ "http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%B1~BIG5" },
- { "UTF-8", L"blah", "http://foo/?{searchTerms}{inputEncoding}",
+ { "UTF-8", ASCIIToUTF16("blah"),
+ "http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?blahUTF-8" },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
@@ -344,7 +347,7 @@ TEST_F(TemplateURLTest, ReplaceArbitrarySearchTerms) {
TemplateURLRef ref(data[i].url, 1, 2);
GURL result = GURL(ref.ReplaceSearchTerms(turl,
data[i].search_term, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
- std::wstring()));
+ string16()));
EXPECT_TRUE(result.is_valid());
EXPECT_EQ(data[i].expected_result, result.spec());
}
@@ -353,19 +356,19 @@ TEST_F(TemplateURLTest, ReplaceArbitrarySearchTerms) {
TEST_F(TemplateURLTest, Suggestions) {
struct TestData {
const int accepted_suggestion;
- const std::wstring original_query_for_suggestion;
+ const string16 original_query_for_suggestion;
const std::string expected_result;
} data[] = {
- { TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring(),
+ { TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16(),
"http://bar/foo?q=foobar" },
- { TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, L"foo",
+ { TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, ASCIIToUTF16("foo"),
"http://bar/foo?q=foobar" },
- { TemplateURLRef::NO_SUGGESTION_CHOSEN, std::wstring(),
+ { TemplateURLRef::NO_SUGGESTION_CHOSEN, string16(),
"http://bar/foo?aq=f&q=foobar" },
- { TemplateURLRef::NO_SUGGESTION_CHOSEN, L"foo",
+ { TemplateURLRef::NO_SUGGESTION_CHOSEN, ASCIIToUTF16("foo"),
"http://bar/foo?aq=f&q=foobar" },
- { 0, std::wstring(), "http://bar/foo?aq=0&oq=&q=foobar" },
- { 1, L"foo", "http://bar/foo?aq=1&oq=foo&q=foobar" },
+ { 0, string16(), "http://bar/foo?aq=0&oq=&q=foobar" },
+ { 1, ASCIIToUTF16("foo"), "http://bar/foo?aq=1&oq=foo&q=foobar" },
};
TemplateURL turl;
turl.add_input_encoding("UTF-8");
@@ -374,7 +377,7 @@ TEST_F(TemplateURLTest, Suggestions) {
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
- GURL result = GURL(ref.ReplaceSearchTerms(turl, L"foobar",
+ GURL result = GURL(ref.ReplaceSearchTerms(turl, ASCIIToUTF16("foobar"),
data[i].accepted_suggestion, data[i].original_query_for_suggestion));
EXPECT_TRUE(result.is_valid());
EXPECT_EQ(data[i].expected_result, result.spec());
@@ -383,7 +386,7 @@ TEST_F(TemplateURLTest, Suggestions) {
#if defined(OS_WIN)
TEST_F(TemplateURLTest, RLZ) {
- std::wstring rlz_string;
+ string16 rlz_string;
#if defined(GOOGLE_CHROME_BUILD)
RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string);
#endif
@@ -393,7 +396,7 @@ TEST_F(TemplateURLTest, RLZ) {
ASSERT_TRUE(ref.IsValid());
ASSERT_TRUE(ref.SupportsReplacement());
GURL result(ref.ReplaceSearchTerms(t_url, L"x",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()));
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
ASSERT_TRUE(result.is_valid());
std::string expected_url = "http://bar/?";
if (!rlz_string.empty()) {
@@ -461,14 +464,14 @@ TEST_F(TemplateURLTest, Keyword) {
TemplateURL t_url;
t_url.SetURL("http://www.google.com/search", 0, 0);
EXPECT_FALSE(t_url.autogenerate_keyword());
- t_url.set_keyword(L"foo");
- EXPECT_EQ(L"foo", t_url.keyword());
+ t_url.set_keyword(ASCIIToUTF16("foo"));
+ EXPECT_EQ(ASCIIToUTF16("foo"), t_url.keyword());
t_url.set_autogenerate_keyword(true);
EXPECT_TRUE(t_url.autogenerate_keyword());
- EXPECT_EQ(L"google.com", t_url.keyword());
- t_url.set_keyword(L"foo");
+ EXPECT_EQ(ASCIIToUTF16("google.com"), t_url.keyword());
+ t_url.set_keyword(ASCIIToUTF16("foo"));
EXPECT_FALSE(t_url.autogenerate_keyword());
- EXPECT_EQ(L"foo", t_url.keyword());
+ EXPECT_EQ(ASCIIToUTF16("foo"), t_url.keyword());
}
TEST_F(TemplateURLTest, ParseParameterKnown) {
diff --git a/chrome/browser/search_engines/util.cc b/chrome/browser/search_engines/util.cc
index 94b46d6..203042d 100644
--- a/chrome/browser/search_engines/util.cc
+++ b/chrome/browser/search_engines/util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,7 +8,6 @@
#include <vector>
#include "base/logging.h"
-#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
@@ -29,7 +28,7 @@ string16 GetDefaultSearchEngineName(Profile* profile) {
// http://code.google.com/p/chromium/issues/detail?id=2573
return string16();
}
- return WideToUTF16(default_provider->short_name());
+ return default_provider->short_name();
}
// Removes (and deletes) TemplateURLs from |urls| that have duplicate
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 547bf27..a8b4a94 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -620,7 +620,7 @@ void RenderViewContextMenu::AppendSearchProvider() {
menu_model_.AddItem(
IDC_CONTENT_CONTEXT_SEARCHWEBFOR,
l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFOR,
- WideToUTF16(default_provider->short_name()),
+ default_provider->short_name(),
printable_selection_text));
}
}
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 5c838f3..522adc9 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2175,7 +2175,7 @@ void TabContents::GenerateKeywordIfNecessary(
GURL keyword_url = previous_entry->user_typed_url().is_valid() ?
previous_entry->user_typed_url() : previous_entry->url();
- std::wstring keyword =
+ string16 keyword =
TemplateURLModel::GenerateKeyword(keyword_url, true); // autodetected
if (keyword.empty())
return;
@@ -2996,7 +2996,7 @@ void TabContents::PageHasOSDD(
if (!keyword_url.is_valid())
return;
- std::wstring keyword = TemplateURLModel::GenerateKeyword(
+ string16 keyword = TemplateURLModel::GenerateKeyword(
keyword_url,
provider_type == TemplateURLFetcher::AUTODETECTED_PROVIDER);
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 6977552..cc3ba35 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -886,8 +886,8 @@ std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
DCHECK(search_url->SupportsReplacement());
std::wstring search_term = param.ToWStringHack().substr(2);
urls.push_back(GURL(search_url->ReplaceSearchTerms(
- *default_provider, search_term,
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())));
+ *default_provider, WideToUTF16Hack(search_term),
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())));
} else {
// This will create a file URL or a regular URL.
// This call can (in rare circumstances) block the UI thread.
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index 84b3518..f69951f 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -527,7 +527,8 @@ NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) {
const TemplateURL* template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
+ WideToUTF16Hack(keyword));
if (template_url && template_url->IsExtensionKeyword()) {
const SkBitmap& bitmap = profile_->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
@@ -656,11 +657,11 @@ void LocationBarViewMac::Layout() {
// Get the keyword to use for keyword-search and hinting.
const std::wstring keyword(edit_view_->model()->keyword());
- std::wstring short_name;
+ string16 short_name;
bool is_extension_keyword = false;
if (!keyword.empty()) {
short_name = profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword);
+ GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
}
const bool is_keyword_hint = edit_view_->model()->is_keyword_hint();
@@ -669,7 +670,8 @@ void LocationBarViewMac::Layout() {
// Switch from location icon to keyword mode.
location_icon_decoration_->SetVisible(false);
selected_keyword_decoration_->SetVisible(true);
- selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword);
+ selected_keyword_decoration_->SetKeyword(UTF16ToWideHack(short_name),
+ is_extension_keyword);
selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
} else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
// Switch from location icon to show the EV bubble instead.
@@ -679,7 +681,7 @@ void LocationBarViewMac::Layout() {
std::wstring label(toolbar_model_->GetEVCertName());
ev_bubble_decoration_->SetFullLabel(base::SysWideToNSString(label));
} else if (!keyword.empty() && is_keyword_hint) {
- keyword_hint_decoration_->SetKeyword(WideToUTF16Hack(short_name),
+ keyword_hint_decoration_->SetKeyword(short_name,
is_extension_keyword);
keyword_hint_decoration_->SetVisible(true);
}
diff --git a/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller.mm b/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller.mm
index 9d5d317..2a93f13 100644
--- a/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller.mm
@@ -87,11 +87,11 @@ void ShiftOriginY(NSView* view, CGFloat amount) {
[window setTitle:l10n_util::GetNSString(
IDS_SEARCH_ENGINES_EDITOR_EDIT_WINDOW_TITLE)];
[nameField_ setStringValue:
- base::SysWideToNSString(templateURL_->short_name())];
+ base::SysUTF16ToNSString(templateURL_->short_name())];
[keywordField_ setStringValue:
- base::SysWideToNSString(templateURL_->keyword())];
+ base::SysUTF16ToNSString(templateURL_->keyword())];
[urlField_ setStringValue:
- base::SysWideToNSString(templateURL_->url()->DisplayURL())];
+ base::SysUTF16ToNSString(templateURL_->url()->DisplayURL())];
[urlField_ setEnabled:(templateURL_->prepopulate_id() == 0)];
}
// When creating a new keyword, this will mark the fields as "invalid" and
diff --git a/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller_unittest.mm b/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller_unittest.mm
index 5241ed6..93ed9f8 100644
--- a/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller_unittest.mm
@@ -1,9 +1,10 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/l10n_util_mac.h"
#include "base/scoped_nsobject.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/ui/cocoa/browser_test_helper.h"
#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
@@ -205,10 +206,10 @@ TEST_F(EditSearchEngineControllerTest, ValidateFields) {
// Tests editing an existing TemplateURL.
TEST_F(EditSearchEngineControllerTest, EditTemplateURL) {
TemplateURL url;
- url.set_short_name(L"Foobar");
- url.set_keyword(L"keyword");
+ url.set_short_name(ASCIIToUTF16("Foobar"));
+ url.set_keyword(ASCIIToUTF16("keyword"));
std::string urlString = TemplateURLRef::DisplayURLToURLRef(
- L"http://foo-bar.com");
+ ASCIIToUTF16("http://foo-bar.com"));
url.SetURL(urlString, 0, 1);
TestingProfile* profile = browser_helper_.profile();
FakeEditSearchEngineController *controller =
diff --git a/chrome/browser/ui/cocoa/options/keyword_editor_cocoa_controller_unittest.mm b/chrome/browser/ui/cocoa/options/keyword_editor_cocoa_controller_unittest.mm
index b07d304..8810992 100644
--- a/chrome/browser/ui/cocoa/options/keyword_editor_cocoa_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/options/keyword_editor_cocoa_controller_unittest.mm
@@ -1,9 +1,10 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/scoped_nsobject.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/ui/cocoa/browser_test_helper.h"
@@ -150,16 +151,16 @@ TEST_F(KeywordEditorCocoaControllerTest, IndexInModelForRowMixed) {
// Add a default engine.
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://test1/{searchTerms}", 0, 0);
- t_url->set_keyword(L"test1");
- t_url->set_short_name(L"Test1");
+ t_url->set_keyword(ASCIIToUTF16("test1"));
+ t_url->set_short_name(ASCIIToUTF16("Test1"));
t_url->set_show_in_default_list(true);
template_model->Add(t_url);
// Add a non-default engine.
t_url = new TemplateURL();
t_url->SetURL("http://test2/{searchTerms}", 0, 0);
- t_url->set_keyword(L"test2");
- t_url->set_short_name(L"Test2");
+ t_url->set_keyword(ASCIIToUTF16("test2"));
+ t_url->set_short_name(ASCIIToUTF16("Test2"));
t_url->set_show_in_default_list(false);
template_model->Add(t_url);
@@ -193,15 +194,15 @@ TEST_F(KeywordEditorCocoaControllerTest, IndexInModelForDefault) {
// Add 2 default engines.
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://test1/{searchTerms}", 0, 0);
- t_url->set_keyword(L"test1");
- t_url->set_short_name(L"Test1");
+ t_url->set_keyword(ASCIIToUTF16("test1"));
+ t_url->set_short_name(ASCIIToUTF16("Test1"));
t_url->set_show_in_default_list(true);
template_model->Add(t_url);
t_url = new TemplateURL();
t_url->SetURL("http://test2/{searchTerms}", 0, 0);
- t_url->set_keyword(L"test2");
- t_url->set_short_name(L"Test2");
+ t_url->set_keyword(ASCIIToUTF16("test2"));
+ t_url->set_short_name(ASCIIToUTF16("Test2"));
t_url->set_show_in_default_list(true);
template_model->Add(t_url);
diff --git a/chrome/browser/ui/cocoa/options/search_engine_list_model.mm b/chrome/browser/ui/cocoa/options/search_engine_list_model.mm
index e6a41e4..b46e571bc 100644
--- a/chrome/browser/ui/cocoa/options/search_engine_list_model.mm
+++ b/chrome/browser/ui/cocoa/options/search_engine_list_model.mm
@@ -79,7 +79,7 @@ class SearchEngineObserver : public TemplateURLModelObserver {
TemplateURLs modelURLs = model_->GetTemplateURLs();
for (size_t i = 0; i < modelURLs.size(); ++i) {
if (modelURLs[i]->ShowInDefaultList())
- [engines addObject:base::SysWideToNSString(modelURLs[i]->short_name())];
+ [engines addObject:base::SysUTF16ToNSString(modelURLs[i]->short_name())];
}
[self setSearchEngines:engines.get()];
diff --git a/chrome/browser/ui/cocoa/options/search_engine_list_model_unittest.mm b/chrome/browser/ui/cocoa/options/search_engine_list_model_unittest.mm
index 2869de2..b82f095 100644
--- a/chrome/browser/ui/cocoa/options/search_engine_list_model_unittest.mm
+++ b/chrome/browser/ui/cocoa/options/search_engine_list_model_unittest.mm
@@ -1,8 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/scoped_nsobject.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
@@ -32,14 +33,14 @@ class SearchEngineListModelTest : public PlatformTest {
template_model_.reset(new TemplateURLModel(helper_.profile()));
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.google.com/?q={searchTerms}", 0, 0);
- t_url->set_keyword(L"keyword");
- t_url->set_short_name(L"google");
+ t_url->set_keyword(ASCIIToUTF16("keyword"));
+ t_url->set_short_name(ASCIIToUTF16("google"));
t_url->set_show_in_default_list(true);
template_model_->Add(t_url);
t_url = new TemplateURL();
t_url->SetURL("http://www.google2.com/?q={searchTerms}", 0, 0);
- t_url->set_keyword(L"keyword2");
- t_url->set_short_name(L"google2");
+ t_url->set_keyword(ASCIIToUTF16("keyword2"));
+ t_url->set_short_name(ASCIIToUTF16("google2"));
t_url->set_show_in_default_list(true);
template_model_->Add(t_url);
EXPECT_EQ(template_model_->GetTemplateURLs().size(), 2U);
@@ -83,14 +84,14 @@ TEST_F(SearchEngineListModelTest, Default) {
// Add two more URLs, neither of which are shown in the default list.
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.google3.com/?q={searchTerms}", 0, 0);
- t_url->set_keyword(L"keyword3");
- t_url->set_short_name(L"google3 not eligible");
+ t_url->set_keyword(ASCIIToUTF16("keyword3"));
+ t_url->set_short_name(ASCIIToUTF16("google3 not eligible"));
t_url->set_show_in_default_list(false);
template_model_->Add(t_url);
t_url = new TemplateURL();
t_url->SetURL("http://www.google4.com/?q={searchTerms}", 0, 0);
- t_url->set_keyword(L"keyword4");
- t_url->set_short_name(L"google4");
+ t_url->set_keyword(ASCIIToUTF16("keyword4"));
+ t_url->set_short_name(ASCIIToUTF16("google4"));
t_url->set_show_in_default_list(false);
template_model_->Add(t_url);
@@ -116,14 +117,14 @@ TEST_F(SearchEngineListModelTest, DefaultChosenFromUI) {
// Add two more URLs, the first one not shown in the default list.
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.google3.com/?q={searchTerms}", 0, 0);
- t_url->set_keyword(L"keyword3");
- t_url->set_short_name(L"google3 not eligible");
+ t_url->set_keyword(ASCIIToUTF16("keyword3"));
+ t_url->set_short_name(ASCIIToUTF16("google3 not eligible"));
t_url->set_show_in_default_list(false);
template_model_->Add(t_url);
t_url = new TemplateURL();
t_url->SetURL("http://www.google4.com/?q={searchTerms}", 0, 0);
- t_url->set_keyword(L"keyword4");
- t_url->set_short_name(L"google4");
+ t_url->set_keyword(ASCIIToUTF16("keyword4"));
+ t_url->set_short_name(ASCIIToUTF16("google4"));
t_url->set_show_in_default_list(true);
template_model_->Add(t_url);
@@ -143,8 +144,8 @@ TEST_F(SearchEngineListModelTest, Notification) {
// Add one more item to force a notification.
TemplateURL* t_url = new TemplateURL();
t_url->SetURL("http://www.google3.com/foo/bar", 0, 0);
- t_url->set_keyword(L"keyword3");
- t_url->set_short_name(L"google3");
+ t_url->set_keyword(ASCIIToUTF16("keyword3"));
+ t_url->set_short_name(ASCIIToUTF16("google3"));
t_url->set_show_in_default_list(true);
template_model_->Add(t_url);
diff --git a/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm b/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm
index fa53295..699f342 100644
--- a/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm
+++ b/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -205,7 +205,7 @@ void SearchEngineDialogControllerBridge::OnTemplateURLModelChanged() {
[logoView setEditable:NO];
// Tooltip text provides accessibility.
- [logoView setToolTip:base::SysWideToNSString(engine->short_name())];
+ [logoView setToolTip:base::SysUTF16ToNSString(engine->short_name())];
engineIdentifier = logoView;
} else {
// No logo -- we must show a text label.
@@ -224,7 +224,7 @@ void SearchEngineDialogControllerBridge::OnTemplateURLModelChanged() {
paragraphStyle.get(), NSParagraphStyleAttributeName,
nil];
- NSString* value = base::SysWideToNSString(engine->short_name());
+ NSString* value = base::SysUTF16ToNSString(engine->short_name());
scoped_nsobject<NSAttributedString> attrValue(
[[NSAttributedString alloc] initWithString:value
attributes:attrs]);
diff --git a/chrome/browser/ui/gtk/edit_search_engine_dialog.cc b/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
index 0903040..f2fd6e9 100644
--- a/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
+++ b/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
@@ -26,7 +26,7 @@
namespace {
std::string GetDisplayURL(const TemplateURL& turl) {
- return turl.url() ? WideToUTF8(turl.url()->DisplayURL()) : std::string();
+ return turl.url() ? UTF16ToUTF8(turl.url()->DisplayURL()) : std::string();
}
// Forces text to lowercase when connected to an editable's "insert-text"
@@ -158,10 +158,10 @@ void EditSearchEngineDialog::Init(GtkWindow* parent_window, Profile* profile) {
if (controller_->template_url()) {
gtk_entry_set_text(
GTK_ENTRY(title_entry_),
- WideToUTF8(controller_->template_url()->short_name()).c_str());
+ UTF16ToUTF8(controller_->template_url()->short_name()).c_str());
gtk_entry_set_text(
GTK_ENTRY(keyword_entry_),
- WideToUTF8(controller_->template_url()->keyword()).c_str());
+ UTF16ToUTF8(controller_->template_url()->keyword()).c_str());
gtk_entry_set_text(
GTK_ENTRY(url_entry_),
GetDisplayURL(*controller_->template_url()).c_str());
diff --git a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc
index 5994a84..eee9a13 100644
--- a/chrome/browser/ui/gtk/first_run_dialog.cc
+++ b/chrome/browser/ui/gtk/first_run_dialog.cc
@@ -342,7 +342,7 @@ void FirstRunDialog::OnTemplateURLModelChanged() {
GtkWidget* logo_label = gtk_label_new(NULL);
char* markup = g_markup_printf_escaped(
"<span weight='bold' size='x-large' color='black'>%s</span>",
- WideToUTF8((*search_engine_iter)->short_name()).c_str());
+ UTF16ToUTF8((*search_engine_iter)->short_name()).c_str());
gtk_label_set_markup(GTK_LABEL(logo_label), markup);
g_free(markup);
gtk_widget_set_size_request(logo_label, -1,
diff --git a/chrome/browser/ui/gtk/keyword_editor_view_unittest.cc b/chrome/browser/ui/gtk/keyword_editor_view_unittest.cc
index 5f4043a..acc4e07 100644
--- a/chrome/browser/ui/gtk/keyword_editor_view_unittest.cc
+++ b/chrome/browser/ui/gtk/keyword_editor_view_unittest.cc
@@ -30,8 +30,8 @@ class KeywordEditorViewTest : public testing::Test {
const std::string& keyword,
bool make_default) {
TemplateURL* template_url = new TemplateURL();
- template_url->set_short_name(UTF8ToWide(name));
- template_url->set_keyword(UTF8ToWide(keyword));
+ template_url->set_short_name(UTF8ToUTF16(name));
+ template_url->set_keyword(UTF8ToUTF16(keyword));
template_url->SetURL("http://example.com/{searchTerms}", 0, 0);
profile_->GetTemplateURLModel()->Add(template_url);
if (make_default)
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 97f0c23..bd870c83 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -985,15 +985,16 @@ void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) {
return;
bool is_extension_keyword;
- const std::wstring short_name = profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword);
+ const string16 short_name = profile_->GetTemplateURLModel()->
+ GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT;
string16 full_name = l10n_util::GetStringFUTF16(message_id,
- WideToUTF16Hack(short_name));
+ short_name);
string16 partial_name = l10n_util::GetStringFUTF16(
message_id,
- WideToUTF16Hack(location_bar_util::CalculateMinString(short_name)));
+ WideToUTF16Hack(
+ location_bar_util::CalculateMinString(UTF16ToWideHack(short_name))));
gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_),
UTF16ToUTF8(full_name).c_str());
gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_),
@@ -1004,7 +1005,8 @@ void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) {
if (is_extension_keyword) {
const TemplateURL* template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
+ WideToUTF16Hack(keyword));
const SkBitmap& bitmap = profile_->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap);
@@ -1027,15 +1029,15 @@ void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) {
return;
bool is_extension_keyword;
- const std::wstring short_name = profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword);
+ const string16 short_name = profile_->GetTemplateURLModel()->
+ GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT;
std::vector<size_t> content_param_offsets;
const string16 keyword_hint = l10n_util::GetStringFUTF16(
message_id,
string16(),
- WideToUTF16Hack(short_name),
+ short_name,
&content_param_offsets);
if (content_param_offsets.size() != 2) {
// See comments on an identical NOTREACHED() in search_provider.cc.
diff --git a/chrome/browser/ui/gtk/options/general_page_gtk.cc b/chrome/browser/ui/gtk/options/general_page_gtk.cc
index 6f773a6..aa6ae80 100644
--- a/chrome/browser/ui/gtk/options/general_page_gtk.cc
+++ b/chrome/browser/ui/gtk/options/general_page_gtk.cc
@@ -686,7 +686,7 @@ void GeneralPageGtk::OnTemplateURLModelChanged() {
default_search_engines_model_, &iter,
SEARCH_ENGINES_COL_INDEX, i,
SEARCH_ENGINES_COL_TITLE,
- WideToUTF8(model_urls[i]->short_name()).c_str(),
+ UTF16ToUTF8(model_urls[i]->short_name()).c_str(),
-1);
if (model_urls[i] == default_search_provider) {
gtk_combo_box_set_active_iter(
diff --git a/chrome/browser/ui/omnibox/location_bar_util.cc b/chrome/browser/ui/omnibox/location_bar_util.cc
index a5e9404..efb9a3c 100644
--- a/chrome/browser/ui/omnibox/location_bar_util.cc
+++ b/chrome/browser/ui/omnibox/location_bar_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,9 +18,10 @@ std::wstring GetKeywordName(Profile* profile, const std::wstring& keyword) {
// TODO(sky): Once LocationBarView adds a listener to the TemplateURLModel
// to track changes to the model, this should become a DCHECK.
const TemplateURL* template_url =
- profile->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ profile->GetTemplateURLModel()->GetTemplateURLForKeyword(
+ WideToUTF16Hack(keyword));
if (template_url)
- return template_url->AdjustedShortNameForLocaleDirection();
+ return UTF16ToWideHack(template_url->AdjustedShortNameForLocaleDirection());
return std::wstring();
}
diff --git a/chrome/browser/ui/views/location_bar/keyword_hint_view.cc b/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
index 305279c..4b1d1496 100644
--- a/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
+++ b/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
@@ -58,15 +58,15 @@ void KeywordHintView::SetKeyword(const std::wstring& keyword) {
std::vector<size_t> content_param_offsets;
bool is_extension_keyword;
- std::wstring short_name = profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword);
+ string16 short_name = profile_->GetTemplateURLModel()->
+ GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT;
const std::wstring keyword_hint =
UTF16ToWide(l10n_util::GetStringFUTF16(
message_id,
string16(),
- WideToUTF16(short_name),
+ short_name,
&content_param_offsets));
if (content_param_offsets.size() == 2) {
leading_label_->SetText(
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 8a40202..4d2723b 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -516,7 +516,8 @@ void LocationBarView::Layout() {
if (selected_keyword_view_->keyword() != keyword) {
selected_keyword_view_->SetKeyword(keyword);
const TemplateURL* template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
+ WideToUTF16Hack(keyword));
if (template_url && template_url->IsExtensionKeyword()) {
const SkBitmap& bitmap = profile_->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
diff --git a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
index 7ca3b03c..408c436 100644
--- a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
+++ b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
@@ -59,8 +59,8 @@ void SelectedKeywordView::SetKeyword(const std::wstring& keyword) {
return;
bool is_extension_keyword;
- const string16 short_name = WideToUTF16(profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword));
+ const string16 short_name = profile_->GetTemplateURLModel()->
+ GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT;
full_label_.SetText(UTF16ToWide(
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 2400c04..6e4a3fb 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -179,8 +179,8 @@ const char* kBuiltinKeywordVersion = "Builtin Keyword Version";
const size_t kMaxDataLength = 1024;
void BindURLToStatement(const TemplateURL& url, sql::Statement* s) {
- s->BindString(0, WideToUTF8(url.short_name()));
- s->BindString(1, WideToUTF8(url.keyword()));
+ s->BindString(0, UTF16ToUTF8(url.short_name()));
+ s->BindString(1, UTF16ToUTF8(url.keyword()));
GURL favicon_url = url.GetFavIconURL();
if (!favicon_url.is_valid()) {
s->BindString(2, std::string());
@@ -866,9 +866,9 @@ bool WebDatabase::GetKeywords(std::vector<TemplateURL*>* urls) {
std::string tmp;
tmp = s.ColumnString(1);
DCHECK(!tmp.empty());
- template_url->set_short_name(UTF8ToWide(tmp));
+ template_url->set_short_name(UTF8ToUTF16(tmp));
- template_url->set_keyword(UTF8ToWide(s.ColumnString(2)));
+ template_url->set_keyword(UTF8ToUTF16(s.ColumnString(2)));
tmp = s.ColumnString(3);
if (!tmp.empty())
@@ -2203,8 +2203,8 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded(){
"INSERT INTO credit_cards_temp "
"SELECT label,unique_id,name_on_card,type,card_number,"
"expiration_month,expiration_year,verification_code,0,"
- "shipping_address,card_number_encrypted,verification_code_encrypted "
- "FROM credit_cards")) {
+ "shipping_address,card_number_encrypted,"
+ "verification_code_encrypted FROM credit_cards")) {
LOG(WARNING) << "Unable to update web database to version 27.";
NOTREACHED();
return sql::INIT_FAILURE;
@@ -2509,8 +2509,8 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded(){
if (!db_.Execute(
"INSERT INTO autofill_profiles_temp "
"SELECT guid, label, first_name, middle_name, last_name, email, "
- "company_name, address_line_1, address_line_2, city, state, zipcode, "
- "country, phone, fax, date_modified "
+ "company_name, address_line_1, address_line_2, city, state, "
+ "zipcode, country, phone, fax, date_modified "
"FROM autofill_profiles")) {
LOG(WARNING) << "Unable to update web database to version 32.";
NOTREACHED();
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index dc38100..41489e9 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -305,8 +305,8 @@ TEST_F(WebDatabaseTest, Keywords) {
ASSERT_EQ(sql::INIT_OK, db.Init(file_));
TemplateURL template_url;
- template_url.set_short_name(L"short_name");
- template_url.set_keyword(L"keyword");
+ template_url.set_short_name(ASCIIToUTF16("short_name"));
+ template_url.set_keyword(ASCIIToUTF16("keyword"));
GURL favicon_url("http://favicon.url/");
GURL originating_url("http://google.com/");
template_url.SetFavIconURL(favicon_url);
@@ -398,8 +398,8 @@ TEST_F(WebDatabaseTest, UpdateKeyword) {
ASSERT_EQ(sql::INIT_OK, db.Init(file_));
TemplateURL template_url;
- template_url.set_short_name(L"short_name");
- template_url.set_keyword(L"keyword");
+ template_url.set_short_name(ASCIIToUTF16("short_name"));
+ template_url.set_keyword(ASCIIToUTF16("keyword"));
GURL favicon_url("http://favicon.url/");
GURL originating_url("http://originating.url/");
template_url.SetFavIconURL(favicon_url);
@@ -414,7 +414,7 @@ TEST_F(WebDatabaseTest, UpdateKeyword) {
GURL originating_url2("http://originating.url/");
template_url.set_originating_url(originating_url2);
template_url.set_autogenerate_keyword(true);
- EXPECT_EQ(L"url", template_url.keyword());
+ EXPECT_EQ(ASCIIToUTF16("url"), template_url.keyword());
template_url.add_input_encoding("Shift_JIS");
set_prepopulate_id(&template_url, 5);
set_logo_id(&template_url, 2000);
@@ -468,8 +468,8 @@ TEST_F(WebDatabaseTest, KeywordWithNoFavicon) {
ASSERT_EQ(sql::INIT_OK, db.Init(file_));
TemplateURL template_url;
- template_url.set_short_name(L"short_name");
- template_url.set_keyword(L"keyword");
+ template_url.set_short_name(ASCIIToUTF16("short_name"));
+ template_url.set_keyword(ASCIIToUTF16("keyword"));
template_url.SetURL("http://url/", 0, 0);
template_url.set_safe_for_autoreplace(true);
SetID(-100, &template_url);
diff --git a/net/base/escape.cc b/net/base/escape.cc
index 5479b82..ae8411b 100644
--- a/net/base/escape.cc
+++ b/net/base/escape.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -192,9 +192,9 @@ std::string EscapeQueryParamValue(const std::string& text, bool use_plus) {
// Convert the string to a sequence of bytes and then % escape anything
// except alphanumerics and !'()*-._~
-std::wstring EscapeQueryParamValueUTF8(const std::wstring& text,
- bool use_plus) {
- return UTF8ToWide(Escape(WideToUTF8(text), kQueryCharmap, use_plus));
+string16 EscapeQueryParamValueUTF8(const string16& text,
+ bool use_plus) {
+ return UTF8ToUTF16(Escape(UTF16ToUTF8(text), kQueryCharmap, use_plus));
}
// non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|}
diff --git a/net/base/escape.h b/net/base/escape.h
index 39447a5..faa7bd3 100644
--- a/net/base/escape.h
+++ b/net/base/escape.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -125,8 +125,8 @@ std::string EscapeQueryParamValue(const std::string& text, bool use_plus);
bool EscapeQueryParamValue(const string16& text, const char* codepage,
bool use_plus, string16* escaped);
-// A specialized version of EscapeQueryParamValue for wide strings that
+// A specialized version of EscapeQueryParamValue for string16s that
// assumes the codepage is UTF8. This is provided as a convenience.
-std::wstring EscapeQueryParamValueUTF8(const std::wstring& text, bool use_plus);
+string16 EscapeQueryParamValueUTF8(const string16& text, bool use_plus);
#endif // NET_BASE_ESCAPE_H_
diff --git a/net/base/escape_unittest.cc b/net/base/escape_unittest.cc
index 04a040e..60d4ae3 100644
--- a/net/base/escape_unittest.cc
+++ b/net/base/escape_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -66,7 +66,8 @@ TEST(EscapeTest, EscapeTextForFormSubmission) {
};
for (size_t i = 0; i < arraysize(escape_cases); ++i) {
EscapeCase value = escape_cases[i];
- EXPECT_EQ(value.output, EscapeQueryParamValueUTF8(value.input, true));
+ EXPECT_EQ(WideToUTF16Hack(value.output),
+ EscapeQueryParamValueUTF8(WideToUTF16Hack(value.input), true));
}
const EscapeCase escape_cases_no_plus[] = {
@@ -76,7 +77,8 @@ TEST(EscapeTest, EscapeTextForFormSubmission) {
};
for (size_t i = 0; i < arraysize(escape_cases_no_plus); ++i) {
EscapeCase value = escape_cases_no_plus[i];
- EXPECT_EQ(value.output, EscapeQueryParamValueUTF8(value.input, false));
+ EXPECT_EQ(WideToUTF16Hack(value.output),
+ EscapeQueryParamValueUTF8(WideToUTF16Hack(value.input), false));
}
// Test all the values in we're supposed to be escaping.
@@ -114,12 +116,10 @@ TEST(EscapeTest, EscapeTextForFormSubmission) {
string16 wide;
EXPECT_TRUE(EscapeQueryParamValue(test_str, base::kCodepageUTF8, true,
&wide));
- EXPECT_EQ(UTF16ToWideHack(wide),
- EscapeQueryParamValueUTF8(UTF16ToWideHack(test_str), true));
+ EXPECT_EQ(wide, EscapeQueryParamValueUTF8(test_str, true));
EXPECT_TRUE(EscapeQueryParamValue(test_str, base::kCodepageUTF8, false,
&wide));
- EXPECT_EQ(UTF16ToWideHack(wide),
- EscapeQueryParamValueUTF8(UTF16ToWideHack(test_str), false));
+ EXPECT_EQ(wide, EscapeQueryParamValueUTF8(test_str, false));
}
TEST(EscapeTest, EscapePath) {