summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson <mpearson@chromium.org>2015-05-13 16:59:53 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-14 00:00:13 +0000
commit3c6d7afbb243889bc593c69085302d460a706bdb (patch)
tree3fb65deec258007255ed163f068380cd82d3081c
parentb8271d08c3352611e312b28f2a45dc1917fcbc9b (diff)
downloadchromium_src-3c6d7afbb243889bc593c69085302d460a706bdb.zip
chromium_src-3c6d7afbb243889bc593c69085302d460a706bdb.tar.gz
chromium_src-3c6d7afbb243889bc593c69085302d460a706bdb.tar.bz2
Omnibox - Strip Extra Whitespace from Custom Search Engine Names
Whitespace in the form of tabs and line feeds and the like can screw things up. This fixes the fresh.amazon.com bug. (I tested it interatively.) By the way, there is no need to do a migration pass. The data will be correctly loaded when read from the database. (I checked.) While it's true the database will be out of date until written again, given that the actual data used is correct, I don't think that's an issue. TBR=rdevlin.cronin,isherman,lazyboy,pvalenzuela,kmadhusu,avi rdevlin.cronin - this trivial template URL data API change required some changes in chrome/browser/extensions isherman - this trivial template URL data API change required some changes in chrome/browser/importer lazyboy - this trivial template URL data API change required some changes in chrome/browser/renderer_context_menu pvalenzuela - this trivial template URL data API change required some changes in chrome/browser/sync/test/integration kmadhusu - this trivial template URL data API change required some changes in chrome/browser/ui/search/ avi - this trivial template URL data API change required some changes in chrome/browser/ui/cocoa/browser/ BUG=485357 Review URL: https://codereview.chromium.org/1135163002 Cr-Commit-Position: refs/heads/master@{#329742}
-rw-r--r--chrome/browser/autocomplete/autocomplete_provider_unittest.cc11
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/history_url_provider_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc14
-rw-r--r--chrome/browser/autocomplete/shortcuts_backend_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/zero_suggest_provider_unittest.cc2
-rw-r--r--chrome/browser/chrome_content_browser_client_unittest.cc2
-rw-r--r--chrome/browser/extensions/api/search_engines_private/search_engines_private_api.cc2
-rw-r--r--chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc2
-rw-r--r--chrome/browser/importer/in_process_importer_bridge.cc2
-rw-r--r--chrome/browser/renderer_context_menu/render_view_context_menu.cc2
-rw-r--r--chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc4
-rw-r--r--chrome/browser/search/instant_service_unittest.cc2
-rw-r--r--chrome/browser/search/instant_unittest_base.cc1
-rw-r--r--chrome/browser/search/search_unittest.cc4
-rw-r--r--chrome/browser/search_engines/default_search_pref_migration.cc4
-rw-r--r--chrome/browser/search_engines/default_search_pref_migration_unittest.cc8
-rw-r--r--chrome/browser/search_engines/search_provider_install_data_unittest.cc2
-rw-r--r--chrome/browser/sync/test/integration/search_engines_helper.cc2
-rw-r--r--chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view_browsertest.cc8
-rw-r--r--chrome/browser/ui/search/instant_search_prerenderer_unittest.cc2
-rw-r--r--chrome/browser/ui/search/instant_test_utils.cc4
-rw-r--r--chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc1
-rw-r--r--chrome/browser/ui/search/search_ipc_router_unittest.cc1
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc2
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper.cc2
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.cc2
-rw-r--r--components/omnibox/autocomplete_result_unittest.cc4
-rw-r--r--components/omnibox/keyword_provider_unittest.cc2
-rw-r--r--components/search_engines/default_search_manager.cc8
-rw-r--r--components/search_engines/default_search_manager_unittest.cc12
-rw-r--r--components/search_engines/keyword_table.cc4
-rw-r--r--components/search_engines/keyword_table_unittest.cc44
-rw-r--r--components/search_engines/template_url.cc4
-rw-r--r--components/search_engines/template_url.h2
-rw-r--r--components/search_engines/template_url_data.cc9
-rw-r--r--components/search_engines/template_url_data.h4
-rw-r--r--components/search_engines/template_url_fetcher_unittest.cc2
-rw-r--r--components/search_engines/template_url_parser.cc7
-rw-r--r--components/search_engines/template_url_prepopulate_data.cc2
-rw-r--r--components/search_engines/template_url_prepopulate_data_unittest.cc12
-rw-r--r--components/search_engines/template_url_service.cc13
-rw-r--r--components/search_engines/template_url_service_sync_unittest.cc20
-rw-r--r--components/search_engines/template_url_service_unittest.cc32
-rw-r--r--components/search_engines/util.cc2
46 files changed, 168 insertions, 106 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc
index 5609909..003b488 100644
--- a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc
@@ -249,6 +249,7 @@ void AutocompleteProviderTest::RegisterTemplateURL(
}
TemplateURLData data;
data.SetURL(template_url);
+ data.SetShortName(keyword);
data.SetKeyword(keyword);
TemplateURL* default_t_url = new TemplateURL(data);
TemplateURLService* turl_model =
@@ -324,6 +325,8 @@ void AutocompleteProviderTest::
// Reset the default TemplateURL.
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("default"));
+ data.SetKeyword(base::ASCIIToUTF16("default"));
data.SetURL("http://defaultturl/{searchTerms}");
TemplateURL* default_t_url = new TemplateURL(data);
TemplateURLService* turl_model =
@@ -335,7 +338,7 @@ void AutocompleteProviderTest::
// Create another TemplateURL for KeywordProvider.
TemplateURLData data2;
- data2.short_name = base::ASCIIToUTF16("k");
+ data2.SetShortName(base::ASCIIToUTF16("k"));
data2.SetKeyword(base::ASCIIToUTF16("k"));
data2.SetURL("http://keyword/{searchTerms}");
TemplateURL* keyword_t_url = new TemplateURL(data2);
@@ -356,7 +359,7 @@ void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
// Create a TemplateURL for KeywordProvider.
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16("foo.com");
+ data.SetShortName(base::ASCIIToUTF16("foo.com"));
data.SetKeyword(base::ASCIIToUTF16("foo.com"));
data.SetURL("http://foo.com/{searchTerms}");
TemplateURL* keyword_t_url = new TemplateURL(data);
@@ -365,7 +368,7 @@ void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
// Make a TemplateURL for KeywordProvider that a shorter version of the
// first.
- data.short_name = base::ASCIIToUTF16("f");
+ data.SetShortName(base::ASCIIToUTF16("f"));
data.SetKeyword(base::ASCIIToUTF16("f"));
data.SetURL("http://f.com/{searchTerms}");
keyword_t_url = new TemplateURL(data);
@@ -373,7 +376,7 @@ void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
ASSERT_NE(0, keyword_t_url->id());
// Create another TemplateURL for KeywordProvider.
- data.short_name = base::ASCIIToUTF16("bar.com");
+ data.SetShortName(base::ASCIIToUTF16("bar.com"));
data.SetKeyword(base::ASCIIToUTF16("bar.com"));
data.SetURL("http://bar.com/{searchTerms}");
keyword_t_url = new TemplateURL(data);
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index dabf73e..dac4d57 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -734,6 +734,7 @@ TEST_F(HistoryQuickProviderTest, PreventInlineAutocomplete) {
TEST_F(HistoryQuickProviderTest, CullSearchResults) {
// Set up a default search engine.
TemplateURLData data;
+ data.SetShortName(ASCIIToUTF16("TestEngine"));
data.SetKeyword(ASCIIToUTF16("TestEngine"));
data.SetURL("http://testsearch.com/?q={searchTerms}");
TemplateURLService* template_url_service =
diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc
index 68120d5..d111f25 100644
--- a/chrome/browser/autocomplete/history_url_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc
@@ -836,6 +836,7 @@ TEST_F(HistoryURLProviderTest, DoesNotProvideMatchesOnFocus) {
TEST_F(HistoryURLProviderTest, CullSearchResults) {
// Set up a default search engine.
TemplateURLData data;
+ data.SetShortName(ASCIIToUTF16("TestEngine"));
data.SetKeyword(ASCIIToUTF16("TestEngine"));
data.SetURL("http://testsearch.com/?q={searchTerms}");
TemplateURLService* template_url_service =
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 167f32e..8217327 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -291,7 +291,7 @@ void SearchProviderTest::SetUp() {
// Reset the default TemplateURL.
TemplateURLData data;
- data.short_name = ASCIIToUTF16("t");
+ data.SetShortName(ASCIIToUTF16("t"));
data.SetURL("http://defaultturl/{searchTerms}");
data.suggestions_url = "http://defaultturl2/{searchTerms}";
data.instant_url = "http://does/not/exist?strk=1";
@@ -306,7 +306,7 @@ void SearchProviderTest::SetUp() {
term1_url_ = AddSearchToHistory(default_t_url_, term1_, 1);
// Create another TemplateURL.
- data.short_name = ASCIIToUTF16("k");
+ data.SetShortName(ASCIIToUTF16("k"));
data.SetKeyword(ASCIIToUTF16("k"));
data.SetURL("http://keyword/{searchTerms}");
data.suggestions_url = "http://suggest_keyword/{searchTerms}";
@@ -1283,8 +1283,8 @@ TEST_F(SearchProviderTest, CommandLineOverrides) {
TemplateURLServiceFactory::GetForProfile(&profile_);
TemplateURLData data;
- data.short_name = ASCIIToUTF16("default");
- data.SetKeyword(data.short_name);
+ data.SetShortName(ASCIIToUTF16("default"));
+ data.SetKeyword(data.short_name());
data.SetURL("{google:baseURL}{searchTerms}");
default_t_url_ = new TemplateURL(data);
turl_model->Add(default_t_url_);
@@ -3235,7 +3235,7 @@ TEST_F(SearchProviderTest, ReflectsBookmarkBarState) {
TEST_F(SearchProviderTest, CanSendURL) {
TemplateURLData template_url_data;
- template_url_data.short_name = ASCIIToUTF16("t");
+ template_url_data.SetShortName(ASCIIToUTF16("t"));
template_url_data.SetURL("http://www.google.com/{searchTerms}");
template_url_data.suggestions_url = "http://www.google.com/{searchTerms}";
template_url_data.instant_url = "http://does/not/exist?strk=1";
@@ -3460,8 +3460,8 @@ TEST_F(SearchProviderTest, SuggestQueryUsesToken) {
TemplateURLServiceFactory::GetForProfile(&profile_);
TemplateURLData data;
- data.short_name = ASCIIToUTF16("default");
- data.SetKeyword(data.short_name);
+ data.SetShortName(ASCIIToUTF16("default"));
+ data.SetKeyword(data.short_name());
data.SetURL("http://example/{searchTerms}{google:sessionToken}");
data.suggestions_url =
"http://suggest/?q={searchTerms}&{google:sessionToken}";
diff --git a/chrome/browser/autocomplete/shortcuts_backend_unittest.cc b/chrome/browser/autocomplete/shortcuts_backend_unittest.cc
index e10692e..0adbab4 100644
--- a/chrome/browser/autocomplete/shortcuts_backend_unittest.cc
+++ b/chrome/browser/autocomplete/shortcuts_backend_unittest.cc
@@ -100,6 +100,7 @@ void ShortcutsBackendTest::SetSearchProvider() {
TemplateURLServiceFactory::GetForProfile(&profile_);
TemplateURLData data;
data.SetURL("http://foo.com/search?bar={searchTerms}");
+ data.SetShortName(base::UTF8ToUTF16("foo"));
data.SetKeyword(base::UTF8ToUTF16("foo"));
TemplateURL* template_url = new TemplateURL(data);
diff --git a/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc b/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
index 5699e93..105efe7 100644
--- a/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
+++ b/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
@@ -172,7 +172,7 @@ void ZeroSuggestProviderTest::SetUp() {
turl_model->Load();
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16("t");
+ data.SetShortName(base::ASCIIToUTF16("t"));
data.SetURL("https://www.google.com/?q={searchTerms}");
data.suggestions_url = "https://www.google.com/complete/?q={searchTerms}";
data.instant_url = "https://does/not/exist?strk=1";
diff --git a/chrome/browser/chrome_content_browser_client_unittest.cc b/chrome/browser/chrome_content_browser_client_unittest.cc
index 6d37b76..6b35cb9 100644
--- a/chrome/browser/chrome_content_browser_client_unittest.cc
+++ b/chrome/browser/chrome_content_browser_client_unittest.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -163,6 +164,7 @@ class InstantNTPURLRewriteTest : public BrowserWithTestWindowTest {
ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("foo.com"));
data.SetURL("http://foo.com/url?bar={searchTerms}");
data.new_tab_url = new_tab_page_url.spec();
TemplateURL* template_url = new TemplateURL(data);
diff --git a/chrome/browser/extensions/api/search_engines_private/search_engines_private_api.cc b/chrome/browser/extensions/api/search_engines_private/search_engines_private_api.cc
index 013021d..391468d 100644
--- a/chrome/browser/extensions/api/search_engines_private/search_engines_private_api.cc
+++ b/chrome/browser/extensions/api/search_engines_private/search_engines_private_api.cc
@@ -120,7 +120,7 @@ SearchEnginesPrivateAddOtherSearchEngineFunction::Run() {
EXTENSION_FUNCTION_VALIDATE(parameters.get());
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16(parameters->name);
+ data.SetShortName(base::ASCIIToUTF16(parameters->name));
data.SetKeyword(base::ASCIIToUTF16(parameters->keyword));
data.SetURL(parameters->url);
TemplateURL* turl = new TemplateURL(data);
diff --git a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
index d4a1327..9f697e0 100644
--- a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
+++ b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
@@ -72,7 +72,7 @@ TemplateURLData ConvertSearchProvider(
}
if (search_provider.name)
- data.short_name = base::UTF8ToUTF16(*search_provider.name);
+ data.SetShortName(base::UTF8ToUTF16(*search_provider.name));
if (search_provider.keyword)
data.SetKeyword(base::UTF8ToUTF16(*search_provider.keyword));
data.SetURL(SubstituteInstallParam(search_provider.search_url,
diff --git a/chrome/browser/importer/in_process_importer_bridge.cc b/chrome/browser/importer/in_process_importer_bridge.cc
index b1c0861..ccf8a33 100644
--- a/chrome/browser/importer/in_process_importer_bridge.cc
+++ b/chrome/browser/importer/in_process_importer_bridge.cc
@@ -103,7 +103,7 @@ TemplateURL* CreateTemplateURL(const base::string16& url,
data.SetKeyword(keyword);
// We set short name by using the title if it exists.
// Otherwise, we use the shortcut.
- data.short_name = title.empty() ? keyword : title;
+ data.SetShortName(title.empty() ? keyword : title);
data.SetURL(TemplateURLRef::DisplayURLToURLRef(url));
return new TemplateURL(data);
}
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index 387205a..be5d6ef 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -1752,7 +1752,7 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
search_engine_tab_helper->delegate()) {
base::string16 keyword(TemplateURL::GenerateKeyword(params_.page_url));
TemplateURLData data;
- data.short_name = keyword;
+ data.SetShortName(keyword);
data.SetKeyword(keyword);
data.SetURL(params_.keyword_url.spec());
data.favicon_url =
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc b/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
index ae93e95..0498a2c 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc
@@ -477,8 +477,8 @@ class SearchByImageBrowserTest : public InProcessBrowserTest {
ASSERT_TRUE(model->loaded());
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16(kShortName);
- data.SetKeyword(data.short_name);
+ data.SetShortName(base::ASCIIToUTF16(kShortName));
+ data.SetKeyword(data.short_name());
data.SetURL(test_server()->GetURL(kSearchURL).spec());
data.image_url = GetImageSearchURL().spec();
data.image_url_post_params = kImageSearchPostParams;
diff --git a/chrome/browser/search/instant_service_unittest.cc b/chrome/browser/search/instant_service_unittest.cc
index 7d22a54..66253b7 100644
--- a/chrome/browser/search/instant_service_unittest.cc
+++ b/chrome/browser/search/instant_service_unittest.cc
@@ -8,6 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_observer.h"
#include "chrome/browser/search/instant_unittest_base.h"
@@ -128,6 +129,7 @@ TEST_F(InstantServiceEnabledTest,
// Set a default search provider that doesn't support Instant.
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("foobar.com"));
data.SetURL("https://foobar.com/url?bar={searchTerms}");
TemplateURL* template_url = new TemplateURL(data);
// Takes ownership of |template_url|.
diff --git a/chrome/browser/search/instant_unittest_base.cc b/chrome/browser/search/instant_unittest_base.cc
index bedbaef..4e8002a 100644
--- a/chrome/browser/search/instant_unittest_base.cc
+++ b/chrome/browser/search/instant_unittest_base.cc
@@ -49,6 +49,7 @@ void InstantUnitTestBase::SetUpWithoutQueryExtraction() {
void InstantUnitTestBase::SetUserSelectedDefaultSearchProvider(
const std::string& base_url) {
TemplateURLData data;
+ data.SetShortName(base::UTF8ToUTF16(base_url));
data.SetKeyword(base::UTF8ToUTF16(base_url));
data.SetURL(base_url + "url?bar={searchTerms}");
data.instant_url = base_url +
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index 0307b3c..90007c8 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -57,6 +57,7 @@ class SearchTest : public BrowserWithTestWindowTest {
TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile());
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("foo.com"));
data.SetURL("http://foo.com/url?bar={searchTerms}");
data.instant_url = "http://foo.com/instant?"
"{google:forceInstantResults}foo=foo#foo=foo&strk";
@@ -86,6 +87,7 @@ class SearchTest : public BrowserWithTestWindowTest {
"http://foo.com/instant?foo=foo#foo=foo";
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("foo.com"));
data.SetURL("http://foo.com/url?bar={searchTerms}");
data.instant_url = (has_search_term_replacement_key ?
kInstantURLWithStrk : kInstantURLNoStrk);
@@ -511,6 +513,7 @@ TEST_F(SearchTest, CommandLineOverrides) {
TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile());
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("Google"));
data.SetURL("{google:baseURL}search?q={searchTerms}");
data.instant_url = "{google:baseURL}webhp?strk";
data.search_terms_replacement_key = "strk";
@@ -763,6 +766,7 @@ class SearchURLTest : public SearchTest {
TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile());
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("Google"));
data.SetURL("{google:baseURL}search?"
"{google:instantExtendedEnabledParameter}q={searchTerms}");
data.search_terms_replacement_key = "espv";
diff --git a/chrome/browser/search_engines/default_search_pref_migration.cc b/chrome/browser/search_engines/default_search_pref_migration.cc
index bc81a5b..b854d0f 100644
--- a/chrome/browser/search_engines/default_search_pref_migration.cc
+++ b/chrome/browser/search_engines/default_search_pref_migration.cc
@@ -42,8 +42,8 @@ scoped_ptr<TemplateURLData> LoadDefaultSearchProviderFromLegacyPrefs(
return scoped_ptr<TemplateURLData>();
scoped_ptr<TemplateURLData> default_provider_data(new TemplateURLData);
- default_provider_data->short_name =
- base::UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderName));
+ default_provider_data->SetShortName(
+ base::UTF8ToUTF16(prefs->GetString(prefs::kDefaultSearchProviderName)));
default_provider_data->SetKeyword(keyword);
default_provider_data->SetURL(search_url);
default_provider_data->suggestions_url =
diff --git a/chrome/browser/search_engines/default_search_pref_migration_unittest.cc b/chrome/browser/search_engines/default_search_pref_migration_unittest.cc
index c4f0261..d78010d 100644
--- a/chrome/browser/search_engines/default_search_pref_migration_unittest.cc
+++ b/chrome/browser/search_engines/default_search_pref_migration_unittest.cc
@@ -139,7 +139,7 @@ scoped_ptr<TemplateURL> DefaultSearchPrefMigrationTest::CreateKeyword(
const std::string& keyword,
const std::string& url) {
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16(short_name);
+ data.SetShortName(base::ASCIIToUTF16(short_name));
data.SetKeyword(base::ASCIIToUTF16(keyword));
data.SetURL(url);
scoped_ptr<TemplateURL> t_url(new TemplateURL(data));
@@ -161,7 +161,7 @@ TEST_F(DefaultSearchPrefMigrationTest, MigrateUserSelectedValue) {
default_search_manager()->GetDefaultSearchEngine(&source);
ASSERT_TRUE(modern_default);
EXPECT_EQ(DefaultSearchManager::FROM_USER, source);
- EXPECT_EQ(t_url->short_name(), modern_default->short_name);
+ EXPECT_EQ(t_url->short_name(), modern_default->short_name());
EXPECT_EQ(t_url->keyword(), modern_default->keyword());
EXPECT_EQ(t_url->url(), modern_default->url());
}
@@ -181,7 +181,7 @@ TEST_F(DefaultSearchPrefMigrationTest, MigrateOnlyOnce) {
default_search_manager()->GetDefaultSearchEngine(&source);
ASSERT_TRUE(modern_default);
EXPECT_EQ(DefaultSearchManager::FROM_USER, source);
- EXPECT_EQ(t_url->short_name(), modern_default->short_name);
+ EXPECT_EQ(t_url->short_name(), modern_default->short_name());
EXPECT_EQ(t_url->keyword(), modern_default->keyword());
EXPECT_EQ(t_url->url(), modern_default->url());
default_search_manager()->ClearUserSelectedDefaultSearchEngine();
@@ -215,7 +215,7 @@ TEST_F(DefaultSearchPrefMigrationTest, ModernValuePresent) {
default_search_manager()->GetDefaultSearchEngine(&source);
ASSERT_TRUE(modern_default);
EXPECT_EQ(DefaultSearchManager::FROM_USER, source);
- EXPECT_EQ(t_url2->short_name(), modern_default->short_name);
+ EXPECT_EQ(t_url2->short_name(), modern_default->short_name());
EXPECT_EQ(t_url2->keyword(), modern_default->keyword());
EXPECT_EQ(t_url2->url(), modern_default->url());
}
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 31c0434..8a72aee 100644
--- a/chrome/browser/search_engines/search_provider_install_data_unittest.cc
+++ b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
@@ -174,7 +174,7 @@ TemplateURL* SearchProviderInstallDataTest::AddNewTemplateURL(
const std::string& url,
const base::string16& keyword) {
TemplateURLData data;
- data.short_name = keyword;
+ data.SetShortName(keyword);
data.SetKeyword(keyword);
data.SetURL(url);
TemplateURL* t_url = new TemplateURL(data);
diff --git a/chrome/browser/sync/test/integration/search_engines_helper.cc b/chrome/browser/sync/test/integration/search_engines_helper.cc
index 083cb5b..0eb1455 100644
--- a/chrome/browser/sync/test/integration/search_engines_helper.cc
+++ b/chrome/browser/sync/test/integration/search_engines_helper.cc
@@ -195,7 +195,7 @@ TemplateURL* CreateTestTemplateURL(Profile* profile,
const std::string& url,
const std::string& sync_guid) {
TemplateURLData data;
- data.short_name = CreateKeyword(seed);
+ data.SetShortName(CreateKeyword(seed));
data.SetKeyword(keyword);
data.SetURL(url);
data.favicon_url = GURL("http://favicon.url");
diff --git a/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller_unittest.mm
index 355948c..be3cd69 100644
--- a/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller_unittest.mm
@@ -232,7 +232,7 @@ TEST_F(EditSearchEngineControllerTest, ValidateFields) {
// Tests editing an existing TemplateURL.
TEST_F(EditSearchEngineControllerTest, EditTemplateURL) {
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16("Foobar");
+ data.SetShortName(base::ASCIIToUTF16("Foobar"));
data.SetKeyword(base::ASCIIToUTF16("keyword"));
std::string urlString = TemplateURLRef::DisplayURLToURLRef(
base::ASCIIToUTF16("http://foo-bar.com"));
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index 8c02bb4..7744770 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -267,7 +267,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
ASSERT_TRUE(model->loaded());
TemplateURLData data;
- data.short_name = ASCIIToUTF16(kSearchShortName);
+ data.SetShortName(ASCIIToUTF16(kSearchShortName));
data.SetKeyword(ASCIIToUTF16(kSearchKeyword));
data.SetURL(kSearchURL);
TemplateURL* template_url = new TemplateURL(data);
@@ -630,7 +630,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_DesiredTLDWithTemporaryText) {
// non-verbatim entry with "ab" as a prefix. This way, by arrowing down, we
// can set "abc" as temporary text in the omnibox.
TemplateURLData data;
- data.short_name = ASCIIToUTF16("abc");
+ data.SetShortName(ASCIIToUTF16("abc"));
data.SetKeyword(ASCIIToUTF16(kSearchText));
data.SetURL("http://abc.com/");
template_url_service->Add(new TemplateURL(data));
@@ -1077,7 +1077,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, NonSubstitutingKeywordTest) {
// Add a non-default substituting keyword.
TemplateURLData data;
- data.short_name = ASCIIToUTF16("Search abc");
+ data.SetShortName(ASCIIToUTF16("Search abc"));
data.SetKeyword(ASCIIToUTF16(kSearchText));
data.SetURL("http://abc.com/{searchTerms}");
TemplateURL* template_url = new TemplateURL(data);
@@ -1102,7 +1102,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, NonSubstitutingKeywordTest) {
// Try a non-substituting keyword.
template_url_service->Remove(template_url);
- data.short_name = ASCIIToUTF16("abc");
+ data.SetShortName(ASCIIToUTF16("abc"));
data.SetURL("http://abc.com/");
template_url_service->Add(new TemplateURL(data));
diff --git a/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc b/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
index a347a39..23ffae6 100644
--- a/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
+++ b/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
@@ -320,7 +320,7 @@ TEST_F(InstantSearchPrerendererTest, PrerenderingAllowed) {
// Do not allow prerendering for custom search provider requests.
TemplateURLData data;
data.SetURL("https://www.dummyurl.com/search?q=%s&img=1");
- data.short_name = ASCIIToUTF16("t");
+ data.SetShortName(ASCIIToUTF16("t"));
data.SetKeyword(ASCIIToUTF16("k"));
TemplateURL* t_url = new TemplateURL(data);
TemplateURLService* service =
diff --git a/chrome/browser/ui/search/instant_test_utils.cc b/chrome/browser/ui/search/instant_test_utils.cc
index 838a9db..e40f16c 100644
--- a/chrome/browser/ui/search/instant_test_utils.cc
+++ b/chrome/browser/ui/search/instant_test_utils.cc
@@ -54,7 +54,7 @@ void InstantTestBase::SetupInstant(Browser* browser) {
TemplateURLData data;
// Necessary to use exact URL for both the main URL and the alternate URL for
// search term extraction to work in InstantExtended.
- data.short_name = base::ASCIIToUTF16("name");
+ data.SetShortName(base::ASCIIToUTF16("name"));
data.SetURL(instant_url_.spec() +
"q={searchTerms}&is_search&{google:omniboxStartMarginParameter}");
data.instant_url = instant_url_.spec();
@@ -75,7 +75,7 @@ void InstantTestBase::SetInstantURL(const std::string& url) {
ui_test_utils::WaitForTemplateURLServiceToLoad(service);
TemplateURLData data;
- data.short_name = base::ASCIIToUTF16("name");
+ data.SetShortName(base::ASCIIToUTF16("name"));
data.SetURL(url);
data.instant_url = url;
diff --git a/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc b/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
index c672091..3684620 100644
--- a/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
+++ b/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
@@ -52,6 +52,7 @@ class NewTabPageInterceptorTest : public InProcessBrowserTest {
UIThreadSearchTermsData::SetGoogleBaseURL("https://mock.http/");
std::string base_url("{google:baseURL}");
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("Google"));
data.SetKeyword(base::UTF8ToUTF16(base_url));
data.SetURL(base_url + "url?bar={searchTerms}");
data.new_tab_url = base_url + new_tab_path;
diff --git a/chrome/browser/ui/search/search_ipc_router_unittest.cc b/chrome/browser/ui/search/search_ipc_router_unittest.cc
index daa211d..224c714 100644
--- a/chrome/browser/ui/search/search_ipc_router_unittest.cc
+++ b/chrome/browser/ui/search/search_ipc_router_unittest.cc
@@ -108,6 +108,7 @@ class SearchIPCRouterTest : public BrowserWithTestWindowTest {
ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
TemplateURLData data;
+ data.SetShortName(base::ASCIIToUTF16("foo.com"));
data.SetURL("http://foo.com/url?bar={searchTerms}");
data.instant_url = "http://foo.com/instant?"
"{google:omniboxStartMarginParameter}foo=foo#foo=foo&espv";
diff --git a/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc b/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
index 1d44df9..382c20d 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
@@ -242,7 +242,7 @@ TEST_F(KeywordEditorControllerTest, MutateTemplateURLService) {
int original_row_count = table_model()->RowCount();
TemplateURLData data;
- data.short_name = ASCIIToUTF16("b");
+ data.SetShortName(ASCIIToUTF16("b"));
data.SetKeyword(ASCIIToUTF16("a"));
TemplateURL* turl = new TemplateURL(data);
util()->model()->Add(turl);
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
index c1763ef..0c94a83 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
@@ -214,7 +214,7 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
}
TemplateURLData data;
- data.short_name = keyword;
+ data.SetShortName(keyword);
data.SetKeyword(keyword);
data.SetURL(url.spec());
DCHECK(controller.GetLastCommittedEntry());
diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc
index 83492ea..24a73e9 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.cc
+++ b/chrome/browser/ui/search_engines/template_url_table_model.cc
@@ -260,7 +260,7 @@ void TemplateURLTableModel::Add(int index,
DCHECK(!url.empty());
template_url_service_->RemoveObserver(this);
TemplateURLData data;
- data.short_name = short_name;
+ data.SetShortName(short_name);
data.SetKeyword(keyword);
data.SetURL(url);
TemplateURL* turl = new TemplateURL(data);
diff --git a/components/omnibox/autocomplete_result_unittest.cc b/components/omnibox/autocomplete_result_unittest.cc
index 402ee36..0529d33 100644
--- a/components/omnibox/autocomplete_result_unittest.cc
+++ b/components/omnibox/autocomplete_result_unittest.cc
@@ -400,7 +400,7 @@ TEST_F(AutocompleteResultTest, SortAndCullEmptyDestinationURLs) {
TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) {
// Register a template URL that corresponds to 'foo' search engine.
TemplateURLData url_data;
- url_data.short_name = base::ASCIIToUTF16("unittest");
+ url_data.SetShortName(base::ASCIIToUTF16("unittest"));
url_data.SetKeyword(base::ASCIIToUTF16("foo"));
url_data.SetURL("http://www.foo.com/s?q={searchTerms}");
template_url_service_.get()->Add(new TemplateURL(url_data));
@@ -446,7 +446,7 @@ TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) {
TEST_F(AutocompleteResultTest, SortAndCullWithMatchDups) {
// Register a template URL that corresponds to 'foo' search engine.
TemplateURLData url_data;
- url_data.short_name = base::ASCIIToUTF16("unittest");
+ url_data.SetShortName(base::ASCIIToUTF16("unittest"));
url_data.SetKeyword(base::ASCIIToUTF16("foo"));
url_data.SetURL("http://www.foo.com/s?q={searchTerms}");
template_url_service_.get()->Add(new TemplateURL(url_data));
diff --git a/components/omnibox/keyword_provider_unittest.cc b/components/omnibox/keyword_provider_unittest.cc
index eedc847..de0d4db 100644
--- a/components/omnibox/keyword_provider_unittest.cc
+++ b/components/omnibox/keyword_provider_unittest.cc
@@ -269,7 +269,7 @@ TEST_F(KeywordProviderTest, Contents) {
TEST_F(KeywordProviderTest, AddKeyword) {
TemplateURLData data;
- data.short_name = ASCIIToUTF16("Test");
+ data.SetShortName(ASCIIToUTF16("Test"));
base::string16 keyword(ASCIIToUTF16("foo"));
data.SetKeyword(keyword);
data.SetURL("http://www.google.com/foo?q={searchTerms}");
diff --git a/components/search_engines/default_search_manager.cc b/components/search_engines/default_search_manager.cc
index c71ffad..2173123 100644
--- a/components/search_engines/default_search_manager.cc
+++ b/components/search_engines/default_search_manager.cc
@@ -157,7 +157,7 @@ void DefaultSearchManager::SetUserSelectedDefaultSearchEngine(
base::DictionaryValue url_dict;
url_dict.SetString(kID, base::Int64ToString(data.id));
- url_dict.SetString(kShortName, data.short_name);
+ url_dict.SetString(kShortName, data.short_name());
url_dict.SetString(kKeyword, data.keyword());
url_dict.SetInteger(kPrepopulateID, data.prepopulate_id);
url_dict.SetString(kSyncGUID, data.sync_guid);
@@ -268,7 +268,7 @@ void DefaultSearchManager::MergePrefsDataWithPrepopulated() {
if (!prefs_default_search_->safe_for_autoreplace) {
prepopulated_urls[i]->safe_for_autoreplace = false;
prepopulated_urls[i]->SetKeyword(prefs_default_search_->keyword());
- prepopulated_urls[i]->short_name = prefs_default_search_->short_name;
+ prepopulated_urls[i]->SetShortName(prefs_default_search_->short_name());
}
prepopulated_urls[i]->id = prefs_default_search_->id;
prepopulated_urls[i]->sync_guid = prefs_default_search_->sync_guid;
@@ -318,7 +318,9 @@ void DefaultSearchManager::LoadDefaultSearchEngineFromPrefs() {
std::string id;
url_dict->GetString(kID, &id);
base::StringToInt64(id, &prefs_default_search_->id);
- url_dict->GetString(kShortName, &prefs_default_search_->short_name);
+ base::string16 short_name;
+ url_dict->GetString(kShortName, &short_name);
+ prefs_default_search_->SetShortName(short_name);
url_dict->GetInteger(kPrepopulateID, &prefs_default_search_->prepopulate_id);
url_dict->GetString(kSyncGUID, &prefs_default_search_->sync_guid);
diff --git a/components/search_engines/default_search_manager_unittest.cc b/components/search_engines/default_search_manager_unittest.cc
index a6718d6..02e15a6 100644
--- a/components/search_engines/default_search_manager_unittest.cc
+++ b/components/search_engines/default_search_manager_unittest.cc
@@ -30,7 +30,7 @@ void ExpectSimilar(const TemplateURLData* expected,
ASSERT_TRUE(expected != NULL);
ASSERT_TRUE(actual != NULL);
- EXPECT_EQ(expected->short_name, actual->short_name);
+ EXPECT_EQ(expected->short_name(), actual->short_name());
EXPECT_EQ(expected->keyword(), actual->keyword());
EXPECT_EQ(expected->url(), actual->url());
EXPECT_EQ(expected->suggestions_url, actual->suggestions_url);
@@ -86,7 +86,7 @@ void SetPolicy(user_prefs::TestingPrefServiceSyncable* prefs,
EXPECT_FALSE(data->url().empty());
}
scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
- entry->SetString(DefaultSearchManager::kShortName, data->short_name);
+ entry->SetString(DefaultSearchManager::kShortName, data->short_name());
entry->SetString(DefaultSearchManager::kKeyword, data->keyword());
entry->SetString(DefaultSearchManager::kURL, data->url());
entry->SetString(DefaultSearchManager::kFaviconURL, data->favicon_url.spec());
@@ -120,7 +120,7 @@ void SetPolicy(user_prefs::TestingPrefServiceSyncable* prefs,
scoped_ptr<TemplateURLData> GenerateDummyTemplateURLData(std::string type) {
scoped_ptr<TemplateURLData> data(new TemplateURLData());
- data->short_name = base::UTF8ToUTF16(std::string(type).append("name"));
+ data->SetShortName(base::UTF8ToUTF16(std::string(type).append("name")));
data->SetKeyword(base::UTF8ToUTF16(std::string(type).append("key")));
data->SetURL(std::string("http://").append(type).append("foo/{searchTerms}"));
data->suggestions_url = std::string("http://").append(type).append("sugg");
@@ -162,7 +162,7 @@ TEST_F(DefaultSearchManagerTest, ReadAndWritePref) {
DefaultSearchManager manager(pref_service(),
DefaultSearchManager::ObserverCallback());
TemplateURLData data;
- data.short_name = base::UTF8ToUTF16("name1");
+ data.SetShortName(base::UTF8ToUTF16("name1"));
data.SetKeyword(base::UTF8ToUTF16("key1"));
data.SetURL("http://foo1/{searchTerms}");
data.suggestions_url = "http://sugg1";
@@ -242,8 +242,8 @@ TEST_F(DefaultSearchManagerTest, DefaultSearchSetByOverrides) {
ExpectSimilar(prepopulated_urls[default_search_index],
manager.GetDefaultSearchEngine(&source));
EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, source);
- EXPECT_NE(manager.GetDefaultSearchEngine(NULL)->short_name,
- first_default.short_name);
+ EXPECT_NE(manager.GetDefaultSearchEngine(NULL)->short_name(),
+ first_default.short_name());
EXPECT_NE(manager.GetDefaultSearchEngine(NULL)->keyword(),
first_default.keyword());
}
diff --git a/components/search_engines/keyword_table.cc b/components/search_engines/keyword_table.cc
index 59dff73..3e21c1f 100644
--- a/components/search_engines/keyword_table.cc
+++ b/components/search_engines/keyword_table.cc
@@ -103,7 +103,7 @@ void BindURLToStatement(const TemplateURLData& data,
base::JSONWriter::Write(&alternate_urls_value, &alternate_urls);
s->BindInt64(id_column, data.id);
- s->BindString16(starting_column, data.short_name);
+ s->BindString16(starting_column, data.short_name());
s->BindString16(starting_column + 1, data.keyword());
s->BindString(starting_column + 2, data.favicon_url.is_valid() ?
history::URLDatabase::GURLToDatabaseURL(data.favicon_url) :
@@ -291,7 +291,7 @@ bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s,
TemplateURLData* data) {
DCHECK(data);
- data->short_name = s.ColumnString16(1);
+ data->SetShortName(s.ColumnString16(1));
data->SetKeyword(s.ColumnString16(2));
// Due to past bugs, we might have persisted entries with empty URLs. Avoid
// reading these out. (GetKeywords() will delete these entries on return.)
diff --git a/components/search_engines/keyword_table_unittest.cc b/components/search_engines/keyword_table_unittest.cc
index 15fa614..70c83fc 100644
--- a/components/search_engines/keyword_table_unittest.cc
+++ b/components/search_engines/keyword_table_unittest.cc
@@ -42,7 +42,7 @@ class KeywordTableTest : public testing::Test {
TemplateURLData CreateAndAddKeyword() const {
TemplateURLData keyword;
- keyword.short_name = ASCIIToUTF16("short_name");
+ keyword.SetShortName(ASCIIToUTF16("short_name"));
keyword.SetKeyword(ASCIIToUTF16("keyword"));
keyword.SetURL("http://url/");
keyword.suggestions_url = "url2";
@@ -117,7 +117,7 @@ TEST_F(KeywordTableTest, Keywords) {
EXPECT_EQ(1U, keywords.size());
const TemplateURLData& restored_keyword = keywords.front();
- EXPECT_EQ(keyword.short_name, restored_keyword.short_name);
+ EXPECT_EQ(keyword.short_name(), restored_keyword.short_name());
EXPECT_EQ(keyword.keyword(), restored_keyword.keyword());
EXPECT_EQ(keyword.url(), restored_keyword.url());
EXPECT_EQ(keyword.suggestions_url, restored_keyword.suggestions_url);
@@ -162,7 +162,7 @@ TEST_F(KeywordTableTest, UpdateKeyword) {
EXPECT_EQ(1U, keywords.size());
const TemplateURLData& restored_keyword = keywords.front();
- EXPECT_EQ(keyword.short_name, restored_keyword.short_name);
+ EXPECT_EQ(keyword.short_name(), restored_keyword.short_name());
EXPECT_EQ(keyword.keyword(), restored_keyword.keyword());
EXPECT_EQ(keyword.suggestions_url, restored_keyword.suggestions_url);
EXPECT_EQ(keyword.instant_url, restored_keyword.instant_url);
@@ -179,7 +179,7 @@ TEST_F(KeywordTableTest, UpdateKeyword) {
TEST_F(KeywordTableTest, KeywordWithNoFavicon) {
TemplateURLData keyword;
- keyword.short_name = ASCIIToUTF16("short_name");
+ keyword.SetShortName(ASCIIToUTF16("short_name"));
keyword.SetKeyword(ASCIIToUTF16("keyword"));
keyword.SetURL("http://url/");
keyword.safe_for_autoreplace = true;
@@ -190,7 +190,7 @@ TEST_F(KeywordTableTest, KeywordWithNoFavicon) {
EXPECT_EQ(1U, keywords.size());
const TemplateURLData& restored_keyword = keywords.front();
- EXPECT_EQ(keyword.short_name, restored_keyword.short_name);
+ EXPECT_EQ(keyword.short_name(), restored_keyword.short_name());
EXPECT_EQ(keyword.keyword(), restored_keyword.keyword());
EXPECT_EQ(keyword.favicon_url, restored_keyword.favicon_url);
EXPECT_EQ(keyword.safe_for_autoreplace,
@@ -200,13 +200,13 @@ TEST_F(KeywordTableTest, KeywordWithNoFavicon) {
TEST_F(KeywordTableTest, SanitizeURLs) {
TemplateURLData keyword;
- keyword.short_name = ASCIIToUTF16("legit");
+ keyword.SetShortName(ASCIIToUTF16("legit"));
keyword.SetKeyword(ASCIIToUTF16("legit"));
keyword.SetURL("http://url/");
keyword.id = 1000;
AddKeyword(keyword);
- keyword.short_name = ASCIIToUTF16("bogus");
+ keyword.SetShortName(ASCIIToUTF16("bogus"));
keyword.SetKeyword(ASCIIToUTF16("bogus"));
keyword.id = 2000;
AddKeyword(keyword);
@@ -224,3 +224,33 @@ TEST_F(KeywordTableTest, SanitizeURLs) {
// GetKeywords() should erase the entry with the empty URL field.
EXPECT_EQ(1U, GetKeywords().size());
}
+
+TEST_F(KeywordTableTest, SanitizeShortName) {
+ TemplateURLData keyword;
+ {
+ keyword.SetShortName(ASCIIToUTF16("legit name"));
+ keyword.SetKeyword(ASCIIToUTF16("legit"));
+ keyword.SetURL("http://url/");
+ keyword.id = 1000;
+ AddKeyword(keyword);
+ KeywordTable::Keywords keywords(GetKeywords());
+ EXPECT_EQ(1U, keywords.size());
+ const TemplateURLData& keyword_from_database = keywords.front();
+ EXPECT_EQ(keyword.id, keyword_from_database.id);
+ EXPECT_EQ(ASCIIToUTF16("legit name"), keyword_from_database.short_name());
+ RemoveKeyword(keyword.id);
+ }
+
+ {
+ keyword.SetShortName(ASCIIToUTF16("\t\tbogus \tname \n"));
+ keyword.SetKeyword(ASCIIToUTF16("bogus"));
+ keyword.id = 2000;
+ AddKeyword(keyword);
+ KeywordTable::Keywords keywords(GetKeywords());
+ EXPECT_EQ(1U, keywords.size());
+ const TemplateURLData& keyword_from_database = keywords.front();
+ EXPECT_EQ(keyword.id, keyword_from_database.id);
+ EXPECT_EQ(ASCIIToUTF16("bogus name"), keyword_from_database.short_name());
+ RemoveKeyword(keyword.id);
+ }
+}
diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc
index 33bee0a..fc2c6f1 100644
--- a/components/search_engines/template_url.cc
+++ b/components/search_engines/template_url.cc
@@ -1277,7 +1277,7 @@ bool TemplateURL::MatchesData(const TemplateURL* t_url,
if (!t_url || !data)
return !t_url && !data;
- return (t_url->short_name() == data->short_name) &&
+ return (t_url->short_name() == data->short_name()) &&
t_url->HasSameKeywordAs(*data, search_terms_data) &&
(t_url->url() == data->url()) &&
(t_url->suggestions_url() == data->suggestions_url) &&
@@ -1299,7 +1299,7 @@ bool TemplateURL::MatchesData(const TemplateURL* t_url,
}
base::string16 TemplateURL::AdjustedShortNameForLocaleDirection() const {
- base::string16 bidi_safe_short_name = data_.short_name;
+ base::string16 bidi_safe_short_name = data_.short_name();
base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name);
return bidi_safe_short_name;
}
diff --git a/components/search_engines/template_url.h b/components/search_engines/template_url.h
index cc73726..cd337d2 100644
--- a/components/search_engines/template_url.h
+++ b/components/search_engines/template_url.h
@@ -536,7 +536,7 @@ class TemplateURL {
const TemplateURLData& data() const { return data_; }
- const base::string16& short_name() const { return data_.short_name; }
+ const base::string16& short_name() const { return data_.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.
base::string16 AdjustedShortNameForLocaleDirection() const;
diff --git a/components/search_engines/template_url_data.cc b/components/search_engines/template_url_data.cc
index fdbec7d..8013697 100644
--- a/components/search_engines/template_url_data.cc
+++ b/components/search_engines/template_url_data.cc
@@ -7,6 +7,7 @@
#include "base/guid.h"
#include "base/i18n/case_conversion.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
TemplateURLData::TemplateURLData()
@@ -26,6 +27,14 @@ TemplateURLData::TemplateURLData()
TemplateURLData::~TemplateURLData() {
}
+void TemplateURLData::SetShortName(const base::string16& short_name) {
+ DCHECK(!short_name.empty());
+
+ // Remove tabs, carriage returns, and the like, as they can corrupt
+ // how the short name is displayed.
+ short_name_ = base::CollapseWhitespace(short_name, true);
+}
+
void TemplateURLData::SetKeyword(const base::string16& keyword) {
DCHECK(!keyword.empty());
diff --git a/components/search_engines/template_url_data.h b/components/search_engines/template_url_data.h
index b460150..15fbad0 100644
--- a/components/search_engines/template_url_data.h
+++ b/components/search_engines/template_url_data.h
@@ -23,7 +23,8 @@ struct TemplateURLData {
// A short description of the template. This is the name we show to the user
// in various places that use TemplateURLs. For example, the location bar
// shows this when the user selects a substituting match.
- base::string16 short_name;
+ void SetShortName(const base::string16& short_name);
+ const base::string16& short_name() const { return short_name_; }
// The shortcut for this TemplateURL. |keyword| must be non-empty.
void SetKeyword(const base::string16& keyword);
@@ -115,6 +116,7 @@ struct TemplateURLData {
private:
// Private so we can enforce using the setters and thus enforce that these
// fields are never empty.
+ base::string16 short_name_;
base::string16 keyword_;
std::string url_;
};
diff --git a/components/search_engines/template_url_fetcher_unittest.cc b/components/search_engines/template_url_fetcher_unittest.cc
index 18ff0f7..56b6a52 100644
--- a/components/search_engines/template_url_fetcher_unittest.cc
+++ b/components/search_engines/template_url_fetcher_unittest.cc
@@ -280,7 +280,7 @@ TEST_F(TemplateURLFetcherTest, ExplicitBeforeLoadTest) {
TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) {
base::string16 keyword(ASCIIToUTF16("test"));
TemplateURLData data;
- data.short_name = keyword;
+ data.SetShortName(keyword);
data.SetKeyword(keyword);
data.SetURL("http://example.com/");
test_util()->model()->Add(new TemplateURL(data));
diff --git a/components/search_engines/template_url_parser.cc b/components/search_engines/template_url_parser.cc
index 14298da..edcc1dc 100644
--- a/components/search_engines/template_url_parser.cc
+++ b/components/search_engines/template_url_parser.cc
@@ -251,7 +251,7 @@ void TemplateURLParsingContext::EndElementImpl(void* ctx, const xmlChar* name) {
context->ProcessURLParams();
break;
case TemplateURLParsingContext::SHORT_NAME:
- context->data_.short_name = context->string_;
+ context->data_.SetShortName(context->string_);
break;
case TemplateURLParsingContext::IMAGE: {
GURL image_url(base::UTF16ToUTF8(context->string_));
@@ -299,8 +299,9 @@ TemplateURL* TemplateURLParsingContext::GetTemplateURL(
const SearchTermsData& search_terms_data,
bool show_in_default_list) {
// TODO(jcampan): Support engines that use POST; see http://crbug.com/18107
- if (method_ == TemplateURLParsingContext::POST || data_.short_name.empty() ||
- !IsHTTPRef(data_.url()) || !IsHTTPRef(data_.suggestions_url))
+ if (method_ == TemplateURLParsingContext::POST ||
+ data_.short_name().empty() || !IsHTTPRef(data_.url()) ||
+ !IsHTTPRef(data_.suggestions_url))
return NULL;
if (suggestion_method_ == TemplateURLParsingContext::POST)
data_.suggestions_url.clear();
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc
index 5d79f66..e66a22f 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -1050,7 +1050,7 @@ scoped_ptr<TemplateURLData> MakePrepopulatedTemplateURLData(
int id) {
scoped_ptr<TemplateURLData> data(new TemplateURLData);
- data->short_name = name;
+ data->SetShortName(name);
data->SetKeyword(keyword);
data->SetURL(search_url.as_string());
data->suggestions_url = suggest_url.as_string();
diff --git a/components/search_engines/template_url_prepopulate_data_unittest.cc b/components/search_engines/template_url_prepopulate_data_unittest.cc
index 15f3b8b..68bf84c 100644
--- a/components/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/components/search_engines/template_url_prepopulate_data_unittest.cc
@@ -138,7 +138,7 @@ TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
&default_index);
ASSERT_EQ(1u, t_urls.size());
- EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name);
+ EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name());
EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword());
EXPECT_EQ("foo.com", GetHostFromTemplateURLData(*t_urls[0]));
EXPECT_EQ("foi.com", t_urls[0]->favicon_url.host());
@@ -163,7 +163,7 @@ TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
t_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
&prefs_, &default_index);
ASSERT_EQ(1u, t_urls.size());
- EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name);
+ EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name());
EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword());
EXPECT_EQ("foo.com", GetHostFromTemplateURLData(*t_urls[0]));
EXPECT_EQ("foi.com", t_urls[0]->favicon_url.host());
@@ -230,14 +230,14 @@ TEST_F(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) {
&default_index);
ASSERT_FALSE(t_urls.empty());
for (size_t i = 0; i < t_urls.size(); ++i) {
- EXPECT_NE(ASCIIToUTF16("foo"), t_urls[i]->short_name);
+ EXPECT_NE(ASCIIToUTF16("foo"), t_urls[i]->short_name());
EXPECT_NE(ASCIIToUTF16("fook"), t_urls[i]->keyword());
EXPECT_NE("foi.com", t_urls[i]->favicon_url.host());
EXPECT_NE("foo.com", GetHostFromTemplateURLData(*t_urls[i]));
EXPECT_NE(1001, t_urls[i]->prepopulate_id);
}
// Ensures the default URL is Google and has the optional fields filled.
- EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name);
+ EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name());
EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty());
EXPECT_FALSE(t_urls[default_index]->instant_url.empty());
EXPECT_FALSE(t_urls[default_index]->image_url.empty());
@@ -262,7 +262,7 @@ TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
// Ensure all the URLs have the required fields populated.
ASSERT_FALSE(t_urls.empty());
for (size_t i = 0; i < t_urls.size(); ++i) {
- ASSERT_FALSE(t_urls[i]->short_name.empty());
+ ASSERT_FALSE(t_urls[i]->short_name().empty());
ASSERT_FALSE(t_urls[i]->keyword().empty());
ASSERT_FALSE(t_urls[i]->favicon_url.host().empty());
ASSERT_FALSE(GetHostFromTemplateURLData(*t_urls[i]).empty());
@@ -271,7 +271,7 @@ TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
}
// Ensures the default URL is Google and has the optional fields filled.
- EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name);
+ EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name());
EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty());
EXPECT_FALSE(t_urls[default_index]->instant_url.empty());
EXPECT_FALSE(t_urls[default_index]->image_url.empty());
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index 923fa55..880f2a3 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -379,9 +379,10 @@ void TemplateURLService::AddWithOverrides(TemplateURL* template_url,
const base::string16& short_name,
const base::string16& keyword,
const std::string& url) {
+ DCHECK(!short_name.empty());
DCHECK(!keyword.empty());
DCHECK(!url.empty());
- template_url->data_.short_name = short_name;
+ template_url->data_.SetShortName(short_name);
template_url->data_.SetKeyword(keyword);
template_url->SetURL(url);
Add(template_url);
@@ -476,7 +477,7 @@ void TemplateURLService::RegisterOmniboxKeyword(
return;
TemplateURLData data;
- data.short_name = base::UTF8ToUTF16(extension_name);
+ data.SetShortName(base::UTF8ToUTF16(extension_name));
data.SetKeyword(base::UTF8ToUTF16(keyword));
data.SetURL(template_url_string);
TemplateURL* url = new TemplateURL(data);
@@ -1206,7 +1207,7 @@ TemplateURLService::CreateTemplateURLFromTemplateURLAndSyncData(
TemplateURLData data(existing_turl ?
existing_turl->data() : TemplateURLData());
- data.short_name = base::UTF8ToUTF16(specifics.short_name());
+ data.SetShortName(base::UTF8ToUTF16(specifics.short_name()));
data.originating_url = GURL(specifics.originating_url());
base::string16 keyword(base::UTF8ToUTF16(specifics.keyword()));
// NOTE: Once this code has shipped in a couple of stable releases, we can
@@ -1342,7 +1343,7 @@ void TemplateURLService::Init(const Initializer* initializers,
// TemplateURLService ends up owning the TemplateURL, don't try and free
// it.
TemplateURLData data;
- data.short_name = base::UTF8ToUTF16(initializers[i].content);
+ data.SetShortName(base::UTF8ToUTF16(initializers[i].content));
data.SetKeyword(base::UTF8ToUTF16(initializers[i].keyword));
data.SetURL(initializers[i].url);
TemplateURL* template_url = new TemplateURL(data);
@@ -1812,7 +1813,7 @@ bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics(
if (!default_search_provider_->safe_for_autoreplace()) {
update_data.safe_for_autoreplace = false;
update_data.SetKeyword(default_search_provider_->keyword());
- update_data.short_name = default_search_provider_->short_name();
+ update_data.SetShortName(default_search_provider_->short_name());
}
UpdateNoNotify(default_search_provider_, TemplateURL(update_data));
} else {
@@ -1967,7 +1968,7 @@ bool TemplateURLService::ResetTemplateURLNoNotify(
DCHECK(!keyword.empty());
DCHECK(!search_url.empty());
TemplateURLData data(url->data());
- data.short_name = title;
+ data.SetShortName(title);
data.SetKeyword(keyword);
if (search_url != data.url()) {
data.SetURL(search_url);
diff --git a/components/search_engines/template_url_service_sync_unittest.cc b/components/search_engines/template_url_service_sync_unittest.cc
index d7baad5..66a6123 100644
--- a/components/search_engines/template_url_service_sync_unittest.cc
+++ b/components/search_engines/template_url_service_sync_unittest.cc
@@ -290,7 +290,7 @@ TemplateURL* TemplateURLServiceSyncTest::CreateTestTemplateURL(
bool safe_for_autoreplace,
bool created_by_policy) const {
TemplateURLData data;
- data.short_name = ASCIIToUTF16("unittest");
+ data.SetShortName(ASCIIToUTF16("unittest"));
data.SetKeyword(keyword);
data.SetURL(url);
data.favicon_url = GURL("http://favicon.url");
@@ -1267,7 +1267,7 @@ TEST_F(TemplateURLServiceSyncTest, DuplicateEncodingsRemoved) {
syncer::SyncDataList initial_data;
TemplateURLData data;
- data.short_name = ASCIIToUTF16("test");
+ data.SetShortName(ASCIIToUTF16("test"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://test/%s");
data.input_encodings.push_back("UTF-8");
@@ -1451,7 +1451,7 @@ TEST_F(TemplateURLServiceSyncTest, MergeTwiceWithSameSyncData) {
// the second merge, as the last_modified timestamp remains the same.
scoped_ptr<TemplateURL> temp_turl(Deserialize(initial_data[0]));
TemplateURLData data(temp_turl->data());
- data.short_name = ASCIIToUTF16("SomethingDifferent");
+ data.SetShortName(ASCIIToUTF16("SomethingDifferent"));
temp_turl.reset(new TemplateURL(data));
initial_data.clear();
initial_data.push_back(
@@ -1529,7 +1529,7 @@ TEST_F(TemplateURLServiceSyncTest, DefaultGuidDeletedBeforeNewDSPArrives) {
// Create a second default search provider for the
// FindNewDefaultSearchProvider method to find.
TemplateURLData data;
- data.short_name = ASCIIToUTF16("unittest");
+ data.SetShortName(ASCIIToUTF16("unittest"));
data.SetKeyword(ASCIIToUTF16("key2"));
data.SetURL("http://key2.com/{searchTerms}");
data.favicon_url = GURL("http://favicon.url");
@@ -2129,7 +2129,7 @@ TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine) {
const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default");
EXPECT_TRUE(result_turl);
EXPECT_EQ(default_turl->keyword(), result_turl->keyword());
- EXPECT_EQ(default_turl->short_name, result_turl->short_name());
+ EXPECT_EQ(default_turl->short_name(), result_turl->short_name());
EXPECT_EQ(default_turl->url(), result_turl->url());
}
@@ -2152,7 +2152,7 @@ TEST_F(TemplateURLServiceSyncTest, AddPrepopulatedEngine) {
const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default");
EXPECT_TRUE(result_turl);
EXPECT_EQ(default_turl->keyword(), result_turl->keyword());
- EXPECT_EQ(default_turl->short_name, result_turl->short_name());
+ EXPECT_EQ(default_turl->short_name(), result_turl->short_name());
EXPECT_EQ(default_turl->url(), result_turl->url());
}
@@ -2182,7 +2182,7 @@ TEST_F(TemplateURLServiceSyncTest, UpdatePrepopulatedEngine) {
const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default");
EXPECT_TRUE(result_turl);
EXPECT_EQ(default_turl->keyword(), result_turl->keyword());
- EXPECT_EQ(default_turl->short_name, result_turl->short_name());
+ EXPECT_EQ(default_turl->short_name(), result_turl->short_name());
EXPECT_EQ(default_turl->url(), result_turl->url());
}
@@ -2193,7 +2193,7 @@ TEST_F(TemplateURLServiceSyncTest, MergeEditedPrepopulatedEngine) {
TemplateURLData data(*default_turl);
data.safe_for_autoreplace = false;
data.SetKeyword(ASCIIToUTF16("new_kw"));
- data.short_name = ASCIIToUTF16("my name");
+ data.SetShortName(ASCIIToUTF16("my name"));
data.SetURL("http://wrong.url.com?q={searchTerms}");
data.date_created = Time::FromTimeT(50);
data.last_modified = Time::FromTimeT(50);
@@ -2223,7 +2223,7 @@ TEST_F(TemplateURLServiceSyncTest, MergeNonEditedPrepopulatedEngine) {
TemplateURLData data(*default_turl);
data.safe_for_autoreplace = true; // Can be replaced with built-in values.
data.SetKeyword(ASCIIToUTF16("new_kw"));
- data.short_name = ASCIIToUTF16("my name");
+ data.SetShortName(ASCIIToUTF16("my name"));
data.SetURL("http://wrong.url.com?q={searchTerms}");
data.date_created = Time::FromTimeT(50);
data.last_modified = Time::FromTimeT(50);
@@ -2242,7 +2242,7 @@ TEST_F(TemplateURLServiceSyncTest, MergeNonEditedPrepopulatedEngine) {
const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default");
EXPECT_TRUE(result_turl);
EXPECT_EQ(default_turl->keyword(), result_turl->keyword());
- EXPECT_EQ(default_turl->short_name, result_turl->short_name());
+ EXPECT_EQ(default_turl->short_name(), result_turl->short_name());
EXPECT_EQ(default_turl->url(), result_turl->url());
}
diff --git a/components/search_engines/template_url_service_unittest.cc b/components/search_engines/template_url_service_unittest.cc
index f045731..ae483bd 100644
--- a/components/search_engines/template_url_service_unittest.cc
+++ b/components/search_engines/template_url_service_unittest.cc
@@ -70,7 +70,7 @@ TemplateURL* CreateKeywordWithDate(
Time date_created,
Time last_modified) {
TemplateURLData data;
- data.short_name = base::UTF8ToUTF16(short_name);
+ data.SetShortName(base::UTF8ToUTF16(short_name));
data.SetKeyword(base::UTF8ToUTF16(keyword));
data.SetURL(url);
data.suggestions_url = suggest_url;
@@ -249,7 +249,7 @@ TemplateURL* TemplateURLServiceTest::CreatePreloadedTemplateURL(
bool safe_for_autoreplace,
int prepopulate_id) {
TemplateURLData data;
- data.short_name = ASCIIToUTF16("unittest");
+ data.SetShortName(ASCIIToUTF16("unittest"));
data.SetKeyword(ASCIIToUTF16("unittest"));
data.SetURL("http://www.unittest.com/{searchTerms}");
data.favicon_url = GURL("http://favicon.url");
@@ -285,7 +285,7 @@ TEST_F(TemplateURLServiceTest, AddUpdateRemove) {
const size_t initial_count = model()->GetTemplateURLs().size();
TemplateURLData data;
- data.short_name = ASCIIToUTF16("google");
+ data.SetShortName(ASCIIToUTF16("google"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://www.google.com/foo/bar");
data.favicon_url = GURL("http://favicon.url");
@@ -363,7 +363,7 @@ TEST_F(TemplateURLServiceTest, AddSameKeyword) {
// Test what happens when we try to add a TemplateURL with the same keyword as
// one in the model.
TemplateURLData data;
- data.short_name = ASCIIToUTF16("second");
+ data.SetShortName(ASCIIToUTF16("second"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://test2");
data.safe_for_autoreplace = false;
@@ -380,7 +380,7 @@ TEST_F(TemplateURLServiceTest, AddSameKeyword) {
// Now try adding a replaceable TemplateURL. This should just delete the
// passed-in URL.
- data.short_name = ASCIIToUTF16("third");
+ data.SetShortName(ASCIIToUTF16("third"));
data.SetURL("http://test3");
data.safe_for_autoreplace = true;
model()->Add(new TemplateURL(data));
@@ -392,7 +392,7 @@ TEST_F(TemplateURLServiceTest, AddSameKeyword) {
// Now try adding a non-replaceable TemplateURL again. This should uniquify
// the existing entry's keyword.
- data.short_name = ASCIIToUTF16("fourth");
+ data.SetShortName(ASCIIToUTF16("fourth"));
data.SetURL("http://test4");
data.safe_for_autoreplace = false;
TemplateURL* t_url2 = new TemplateURL(data);
@@ -464,7 +464,7 @@ TEST_F(TemplateURLServiceTest, AddSameKeywordWithExtensionPresent) {
// Adding another replaceable keyword should remove the existing one, but
// leave the extension as is.
TemplateURLData data;
- data.short_name = ASCIIToUTF16("name1");
+ data.SetShortName(ASCIIToUTF16("name1"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://test3");
data.safe_for_autoreplace = true;
@@ -477,7 +477,7 @@ TEST_F(TemplateURLServiceTest, AddSameKeywordWithExtensionPresent) {
// Adding a nonreplaceable keyword should remove the existing replaceable
// keyword and replace the extension as the associated URL for this keyword,
// but not evict the extension from the service entirely.
- data.short_name = ASCIIToUTF16("name2");
+ data.SetShortName(ASCIIToUTF16("name2"));
data.SetURL("http://test4");
data.safe_for_autoreplace = false;
TemplateURL* t_url2 = new TemplateURL(data);
@@ -620,7 +620,7 @@ TEST_F(TemplateURLServiceTest, Reset) {
test_util()->VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
TemplateURLData data;
- data.short_name = ASCIIToUTF16("google");
+ data.SetShortName(ASCIIToUTF16("google"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://www.google.com/foo/bar");
data.favicon_url = GURL("http://favicon.url");
@@ -744,7 +744,7 @@ TEST_F(TemplateURLServiceTest, DefaultSearchProviderLoadedFromPrefs) {
test_util()->VerifyLoad();
TemplateURLData data;
- data.short_name = ASCIIToUTF16("a");
+ data.SetShortName(ASCIIToUTF16("a"));
data.safe_for_autoreplace = true;
data.SetURL("http://url/{searchTerms}");
data.suggestions_url = "http://url2";
@@ -848,7 +848,7 @@ TEST_F(TemplateURLServiceTest, RepairSearchEnginesWithManagedDefault) {
test_util()->VerifyLoad();
// Verify that the default manager we are getting is the managed one.
TemplateURLData data;
- data.short_name = ASCIIToUTF16(kName);
+ data.SetShortName(ASCIIToUTF16(kName));
data.SetKeyword(ASCIIToUTF16(kKeyword));
data.SetURL(kSearchURL);
data.favicon_url = GURL(kIconURL);
@@ -1227,7 +1227,7 @@ TEST_F(TemplateURLServiceTest, TestManagedDefaultSearch) {
// Verify that the default manager we are getting is the managed one.
TemplateURLData data;
- data.short_name = ASCIIToUTF16(kName);
+ data.SetShortName(ASCIIToUTF16(kName));
data.SetKeyword(ASCIIToUTF16(kKeyword));
data.SetURL(kSearchURL);
data.favicon_url = GURL(kIconURL);
@@ -1255,7 +1255,7 @@ TEST_F(TemplateURLServiceTest, TestManagedDefaultSearch) {
// Verify that the default manager we are now getting is the correct one.
TemplateURLData data2;
- data2.short_name = ASCIIToUTF16(kNewName);
+ data2.SetShortName(ASCIIToUTF16(kNewName));
data2.SetKeyword(ASCIIToUTF16(kNewKeyword));
data2.SetURL(kNewSearchURL);
data2.suggestions_url = kNewSuggestURL;
@@ -1330,7 +1330,7 @@ TEST_F(TemplateURLServiceTest, PatchEmptySyncGUID) {
const size_t initial_count = model()->GetTemplateURLs().size();
TemplateURLData data;
- data.short_name = ASCIIToUTF16("google");
+ data.SetShortName(ASCIIToUTF16("google"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://www.google.com/foo/bar");
data.sync_guid.clear();
@@ -1359,7 +1359,7 @@ TEST_F(TemplateURLServiceTest, DuplicateInputEncodings) {
const size_t initial_count = model()->GetTemplateURLs().size();
TemplateURLData data;
- data.short_name = ASCIIToUTF16("google");
+ data.SetShortName(ASCIIToUTF16("google"));
data.SetKeyword(ASCIIToUTF16("keyword"));
data.SetURL("http://www.google.com/foo/bar");
std::vector<std::string> encodings;
@@ -1470,7 +1470,7 @@ TEST_F(TemplateURLServiceTest, ExtensionEngineVsPolicy) {
test_util()->VerifyLoad();
// Verify that the default manager we are getting is the managed one.
TemplateURLData data;
- data.short_name = ASCIIToUTF16(kName);
+ data.SetShortName(ASCIIToUTF16(kName));
data.SetKeyword(ASCIIToUTF16(kKeyword));
data.SetURL(kSearchURL);
data.favicon_url = GURL(kIconURL);
diff --git a/components/search_engines/util.cc b/components/search_engines/util.cc
index 961a93e..2e16a9c 100644
--- a/components/search_engines/util.cc
+++ b/components/search_engines/util.cc
@@ -169,7 +169,7 @@ void MergeIntoPrepopulatedEngineData(const TemplateURL* original_turl,
if (!original_turl->safe_for_autoreplace()) {
prepopulated_url->safe_for_autoreplace = false;
prepopulated_url->SetKeyword(original_turl->keyword());
- prepopulated_url->short_name = original_turl->short_name();
+ prepopulated_url->SetShortName(original_turl->short_name());
}
prepopulated_url->id = original_turl->id();
prepopulated_url->sync_guid = original_turl->sync_guid();