summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/policy/policy_templates.json20
-rw-r--r--chrome/browser/policy/configuration_policy_handler.cc5
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store_unittest.cc14
-rw-r--r--chrome/browser/policy/policy_browsertest.cc9
-rw-r--r--chrome/browser/search_engines/template_url_service.cc10
-rw-r--r--chrome/browser/search_engines/template_url_service_factory.cc4
-rw-r--r--chrome/browser/webdata/keyword_table.cc39
-rw-r--r--chrome/browser/webdata/keyword_table.h4
-rw-r--r--chrome/browser/webdata/keyword_table_unittest.cc21
-rw-r--r--chrome/common/pref_names.cc5
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--chrome/test/data/policy/policy_test_cases.json8
-rw-r--r--components/test/data/web_database/version_52.sql33
-rw-r--r--components/webdata/common/web_database.cc2
-rw-r--r--components/webdata/common/web_database_migration_unittest.cc43
-rw-r--r--sync/protocol/proto_value_conversions.cc1
-rw-r--r--sync/protocol/search_engine_specifics.proto3
17 files changed, 197 insertions, 25 deletions
diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json
index 10ad804..44b942e 100644
--- a/chrome/app/policy/policy_templates.json
+++ b/chrome/app/policy/policy_templates.json
@@ -117,7 +117,7 @@
# persistent IDs for all fields (but not for groups!) are needed. These are
# specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs,
# because doing so would break the deployed wire format!
-# For your editing convenience: highest ID currently used: 236
+# For your editing convenience: highest ID currently used: 237
#
# Placeholders:
# The following placeholder strings are automatically substituted:
@@ -1888,6 +1888,24 @@
This policy is only respected if the 'DefaultSearchProviderEnabled' policy is enabled.''',
},
{
+ 'name': 'DefaultSearchProviderNewTabURL',
+ 'type': 'string',
+ 'schema': { 'type': 'string' },
+ 'supported_on': ['chrome.*:30-', 'chrome_os:0.30-', 'android:30-'],
+ 'features': {
+ 'dynamic_refresh': True,
+ 'per_profile': True,
+ },
+ 'example_value': 'http://search.my.company/newtab',
+ 'id': 237,
+ 'caption': '''Default search provider new tab page URL''',
+ 'desc': '''Specifies the URL that a search engine uses to provide a new tab page.
+
+ This policy is optional. If not set, no new tab page will be provided.
+
+ This policy is only respected if the 'DefaultSearchProviderEnabled' policy is enabled.''',
+ },
+ {
'name': 'DefaultSearchProviderSearchURLPostParams',
'type': 'string',
'schema': { 'type': 'string' },
diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc
index 63b6f82..30bcc9c 100644
--- a/chrome/browser/policy/configuration_policy_handler.cc
+++ b/chrome/browser/policy/configuration_policy_handler.cc
@@ -103,6 +103,9 @@ const DefaultSearchSimplePolicyHandlerEntry kDefaultSearchPolicyMap[] = {
{ key::kDefaultSearchProviderImageURL,
prefs::kDefaultSearchProviderImageURL,
Value::TYPE_STRING },
+ { key::kDefaultSearchProviderNewTabURL,
+ prefs::kDefaultSearchProviderNewTabURL,
+ Value::TYPE_STRING },
{ key::kDefaultSearchProviderSearchURLPostParams,
prefs::kDefaultSearchProviderSearchURLPostParams,
Value::TYPE_STRING },
@@ -967,6 +970,7 @@ void DefaultSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
prefs->SetString(prefs::kDefaultSearchProviderEncodings, std::string());
prefs->SetString(prefs::kDefaultSearchProviderKeyword, std::string());
prefs->SetString(prefs::kDefaultSearchProviderInstantURL, std::string());
+ prefs->SetString(prefs::kDefaultSearchProviderNewTabURL, std::string());
prefs->SetValue(prefs::kDefaultSearchProviderAlternateURLs,
new ListValue());
prefs->SetString(prefs::kDefaultSearchProviderSearchTermsReplacementKey,
@@ -996,6 +1000,7 @@ void DefaultSearchPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderEncodings);
EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderKeyword);
EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderInstantURL);
+ EnsureStringPrefExists(prefs, prefs::kDefaultSearchProviderNewTabURL);
EnsureListPrefExists(prefs, prefs::kDefaultSearchProviderAlternateURLs);
EnsureStringPrefExists(prefs,
prefs::kDefaultSearchProviderSearchTermsReplacementKey);
diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
index 400d53b..6df3ae9 100644
--- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
@@ -641,6 +641,7 @@ class ConfigurationPolicyPrefStoreDefaultSearchTest
static const char* const kReplacementKey;
static const char* const kImageURL;
static const char* const kImageParams;
+ static const char* const kNewTabURL;
// Build a default search policy by setting search-related keys in |policy| to
// reasonable values. You can update any of the keys after calling this
@@ -666,6 +667,8 @@ const char* const ConfigurationPolicyPrefStoreDefaultSearchTest::kImageURL =
"http://test.com/searchbyimage/upload";
const char* const ConfigurationPolicyPrefStoreDefaultSearchTest::kImageParams =
"image_content=content,image_url=http://test.com/test.png";
+const char* const ConfigurationPolicyPrefStoreDefaultSearchTest::kNewTabURL =
+ "http://test.com/newtab";
void ConfigurationPolicyPrefStoreDefaultSearchTest::
BuildDefaultSearchPolicy(PolicyMap* policy) {
@@ -701,6 +704,9 @@ void ConfigurationPolicyPrefStoreDefaultSearchTest::
policy->Set(key::kDefaultSearchProviderImageURLPostParams,
POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
base::Value::CreateStringValue(kImageParams), NULL);
+ policy->Set(key::kDefaultSearchProviderNewTabURL,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ base::Value::CreateStringValue(kNewTabURL), NULL);
}
// Checks that if the policy for default search is valid, i.e. there's a
@@ -765,6 +771,10 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) {
EXPECT_TRUE(store_->GetValue(
prefs::kDefaultSearchProviderImageURLPostParams, &value));
EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
+
+ EXPECT_TRUE(store_->GetValue(
+ prefs::kDefaultSearchProviderNewTabURL, &value));
+ EXPECT_TRUE(base::StringValue(std::string()).Equals(value));
}
// Checks that for a fully defined search policy, all elements have been
@@ -844,6 +854,8 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MissingUrl) {
EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderImageURL, NULL));
EXPECT_FALSE(store_->GetValue(
prefs::kDefaultSearchProviderImageURLPostParams, NULL));
+ EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderInstantURL, NULL));
+ EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderNewTabURL, NULL));
}
// Checks that if the default search policy is invalid, that no elements of the
@@ -870,6 +882,8 @@ TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, Invalid) {
EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderImageURL, NULL));
EXPECT_FALSE(store_->GetValue(
prefs::kDefaultSearchProviderImageURLPostParams, NULL));
+ EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderInstantURL, NULL));
+ EXPECT_FALSE(store_->GetValue(prefs::kDefaultSearchProviderNewTabURL, NULL));
}
// Checks that if the default search policy is invalid, that no elements of the
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 3dc3612..cefed43 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -707,6 +707,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
const std::string kImageURL("http://test.com/searchbyimage/upload");
const std::string kImageURLPostParams(
"image_content=content,image_url=http://test.com/test.png");
+ const std::string kNewTabURL("http://search.example/newtab");
TemplateURLService* service = TemplateURLServiceFactory::GetForProfile(
browser()->profile());
@@ -722,7 +723,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
default_search->search_terms_replacement_key() ==
kSearchTermsReplacementKey &&
default_search->image_url() == kImageURL &&
- default_search->image_url_post_params() == kImageURLPostParams);
+ default_search->image_url_post_params() == kImageURLPostParams &&
+ default_search->new_tab_url() == kNewTabURL);
// Override the default search provider using policies.
PolicyMap policies;
@@ -751,6 +753,10 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
base::Value::CreateStringValue(kImageURLPostParams),
NULL);
+ policies.Set(key::kDefaultSearchProviderNewTabURL,
+ POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ base::Value::CreateStringValue(kNewTabURL),
+ NULL);
UpdateProviderPolicy(policies);
default_search = service->GetDefaultSearchProvider();
ASSERT_TRUE(default_search);
@@ -763,6 +769,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) {
default_search->search_terms_replacement_key());
EXPECT_EQ(kImageURL, default_search->image_url());
EXPECT_EQ(kImageURLPostParams, default_search->image_url_post_params());
+ EXPECT_EQ(kNewTabURL, default_search->new_tab_url());
// Verify that searching from the omnibox uses kSearchURL.
chrome::FocusLocationBar(browser());
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index 5a7ec76..55df617 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -68,12 +68,12 @@ bool TemplateURLsHaveSamePrefs(const TemplateURL* url1,
(url1->suggestions_url() == url2->suggestions_url()) &&
(url1->instant_url() == url2->instant_url()) &&
(url1->image_url() == url2->image_url()) &&
+ (url1->new_tab_url() == url2->new_tab_url()) &&
(url1->search_url_post_params() == url2->search_url_post_params()) &&
(url1->suggestions_url_post_params() ==
url2->suggestions_url_post_params()) &&
(url1->instant_url_post_params() == url2->instant_url_post_params()) &&
(url1->image_url_post_params() == url2->image_url_post_params()) &&
- (url1->image_url() == url2->image_url()) &&
(url1->favicon_url() == url2->favicon_url()) &&
(url1->safe_for_autoreplace() == url2->safe_for_autoreplace()) &&
(url1->show_in_default_list() == url2->show_in_default_list()) &&
@@ -1253,6 +1253,7 @@ syncer::SyncData TemplateURLService::CreateSyncDataFromTemplateURL(
se_specifics->set_instant_url(turl.instant_url());
if (!turl.image_url().empty())
se_specifics->set_image_url(turl.image_url());
+ se_specifics->set_new_tab_url(turl.new_tab_url());
if (!turl.search_url_post_params().empty())
se_specifics->set_search_url_post_params(turl.search_url_post_params());
if (!turl.suggestions_url_post_params().empty()) {
@@ -1317,6 +1318,7 @@ TemplateURL* TemplateURLService::CreateTemplateURLFromTemplateURLAndSyncData(
data.suggestions_url = specifics.suggestions_url();
data.instant_url = specifics.instant_url();
data.image_url = specifics.image_url();
+ data.new_tab_url = specifics.new_tab_url();
data.search_url_post_params = specifics.search_url_post_params();
data.suggestions_url_post_params = specifics.suggestions_url_post_params();
data.instant_url_post_params = specifics.instant_url_post_params();
@@ -1580,6 +1582,7 @@ void TemplateURLService::SaveDefaultSearchProviderToPrefs(
std::string suggest_url;
std::string instant_url;
std::string image_url;
+ std::string new_tab_url;
std::string search_url_post_params;
std::string suggest_url_post_params;
std::string instant_url_post_params;
@@ -1599,6 +1602,7 @@ void TemplateURLService::SaveDefaultSearchProviderToPrefs(
suggest_url = t_url->suggestions_url();
instant_url = t_url->instant_url();
image_url = t_url->image_url();
+ new_tab_url = t_url->new_tab_url();
search_url_post_params = t_url->search_url_post_params();
suggest_url_post_params = t_url->suggestions_url_post_params();
instant_url_post_params = t_url->instant_url_post_params();
@@ -1620,6 +1624,7 @@ void TemplateURLService::SaveDefaultSearchProviderToPrefs(
prefs->SetString(prefs::kDefaultSearchProviderSuggestURL, suggest_url);
prefs->SetString(prefs::kDefaultSearchProviderInstantURL, instant_url);
prefs->SetString(prefs::kDefaultSearchProviderImageURL, image_url);
+ prefs->SetString(prefs::kDefaultSearchProviderNewTabURL, new_tab_url);
prefs->SetString(prefs::kDefaultSearchProviderSearchURLPostParams,
search_url_post_params);
prefs->SetString(prefs::kDefaultSearchProviderSuggestURLPostParams,
@@ -1680,6 +1685,8 @@ bool TemplateURLService::LoadDefaultSearchProviderFromPrefs(
prefs->GetString(prefs::kDefaultSearchProviderInstantURL);
std::string image_url =
prefs->GetString(prefs::kDefaultSearchProviderImageURL);
+ std::string new_tab_url =
+ prefs->GetString(prefs::kDefaultSearchProviderNewTabURL);
std::string search_url_post_params =
prefs->GetString(prefs::kDefaultSearchProviderSearchURLPostParams);
std::string suggest_url_post_params =
@@ -1707,6 +1714,7 @@ bool TemplateURLService::LoadDefaultSearchProviderFromPrefs(
data.suggestions_url = suggest_url;
data.instant_url = instant_url;
data.image_url = image_url;
+ data.new_tab_url = new_tab_url;
data.search_url_post_params = search_url_post_params;
data.suggestions_url_post_params = suggest_url_post_params;
data.instant_url_post_params = instant_url_post_params;
diff --git a/chrome/browser/search_engines/template_url_service_factory.cc b/chrome/browser/search_engines/template_url_service_factory.cc
index 1beedcd..4b769c6 100644
--- a/chrome/browser/search_engines/template_url_service_factory.cc
+++ b/chrome/browser/search_engines/template_url_service_factory.cc
@@ -87,6 +87,10 @@ void TemplateURLServiceFactory::RegisterProfilePrefs(
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
+ prefs::kDefaultSearchProviderNewTabURL,
+ std::string(),
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ registry->RegisterStringPref(
prefs::kDefaultSearchProviderSearchURLPostParams,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc
index b6816d1..ec02c29 100644
--- a/chrome/browser/webdata/keyword_table.cc
+++ b/chrome/browser/webdata/keyword_table.cc
@@ -76,6 +76,10 @@ const std::string ColumnsForVersion(int version, bool concatenated) {
columns.push_back("instant_url_post_params");
columns.push_back("image_url_post_params");
}
+ if (version >= 53) {
+ // Column added in version 53.
+ columns.push_back("new_tab_url");
+ }
return JoinString(columns, std::string(concatenated ? " || " : ", "));
}
@@ -127,6 +131,7 @@ void BindURLToStatement(const TemplateURLData& data,
s->BindString(starting_column + 20, data.suggestions_url_post_params);
s->BindString(starting_column + 21, data.instant_url_post_params);
s->BindString(starting_column + 22, data.image_url_post_params);
+ s->BindString(starting_column + 23, data.new_tab_url);
}
WebDatabaseTable::TypeKey GetKey() {
@@ -178,7 +183,8 @@ bool KeywordTable::Init(sql::Connection* db, sql::MetaTable* meta_table) {
"search_url_post_params VARCHAR,"
"suggest_url_post_params VARCHAR,"
"instant_url_post_params VARCHAR,"
- "image_url_post_params VARCHAR)");
+ "image_url_post_params VARCHAR,"
+ "new_tab_url VARCHAR)");
}
bool KeywordTable::IsSyncable() {
@@ -228,6 +234,9 @@ bool KeywordTable::MigrateToVersion(int version,
case 52:
*update_compatible_version = true;
return MigrateToVersion52AddImageSearchAndPOSTSupport();
+ case 53:
+ *update_compatible_version = true;
+ return MigrateToVersion53AddNewTabURLColumn();
}
return true;
@@ -236,7 +245,8 @@ bool KeywordTable::MigrateToVersion(int version,
bool KeywordTable::AddKeyword(const TemplateURLData& data) {
DCHECK(data.id);
std::string query("INSERT INTO keywords (" + GetKeywordColumns() + ") "
- "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
+ " ?)");
sql::Statement s(db_->GetUniqueStatement(query.c_str()));
BindURLToStatement(data, &s, 0, 1);
@@ -281,8 +291,9 @@ bool KeywordTable::UpdateKeyword(const TemplateURLData& data) {
"created_by_policy=?, instant_url=?, last_modified=?, sync_guid=?, "
"alternate_urls=?, search_terms_replacement_key=?, image_url=?,"
"search_url_post_params=?, suggest_url_post_params=?, "
- "instant_url_post_params=?, image_url_post_params=? WHERE id=?"));
- BindURLToStatement(data, &s, 23, 0); // "23" binds id() as the last item.
+ "instant_url_post_params=?, image_url_post_params=?, new_tab_url=? "
+ "WHERE id=?"));
+ BindURLToStatement(data, &s, 24, 0); // "24" binds id() as the last item.
return s.Run();
}
@@ -473,15 +484,24 @@ bool KeywordTable::MigrateToVersion52AddImageSearchAndPOSTSupport() {
// Fill the |image_url| and other four post params columns with empty strings;
return transaction.Begin() &&
db_->Execute("ALTER TABLE keywords ADD COLUMN image_url "
- "VARCHAR DEFAULT ''") &&
+ "VARCHAR DEFAULT ''") &&
db_->Execute("ALTER TABLE keywords ADD COLUMN search_url_post_params "
- "VARCHAR DEFAULT ''") &&
+ "VARCHAR DEFAULT ''") &&
db_->Execute("ALTER TABLE keywords ADD COLUMN suggest_url_post_params "
- "VARCHAR DEFAULT ''") &&
+ "VARCHAR DEFAULT ''") &&
db_->Execute("ALTER TABLE keywords ADD COLUMN instant_url_post_params "
- "VARCHAR DEFAULT ''") &&
+ "VARCHAR DEFAULT ''") &&
db_->Execute("ALTER TABLE keywords ADD COLUMN image_url_post_params "
- "VARCHAR DEFAULT ''") &&
+ "VARCHAR DEFAULT ''") &&
+ transaction.Commit();
+}
+
+bool KeywordTable::MigrateToVersion53AddNewTabURLColumn() {
+ sql::Transaction transaction(db_);
+
+ return transaction.Begin() &&
+ db_->Execute("ALTER TABLE keywords ADD COLUMN new_tab_url "
+ "VARCHAR DEFAULT ''") &&
transaction.Commit();
}
@@ -502,6 +522,7 @@ bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s,
data->suggestions_url = s.ColumnString(11);
data->instant_url = s.ColumnString(14);
data->image_url = s.ColumnString(19);
+ data->new_tab_url = s.ColumnString(24);
data->search_url_post_params = s.ColumnString(20);
data->suggestions_url_post_params = s.ColumnString(21);
data->instant_url_post_params = s.ColumnString(22);
diff --git a/chrome/browser/webdata/keyword_table.h b/chrome/browser/webdata/keyword_table.h
index 7634846..477721b 100644
--- a/chrome/browser/webdata/keyword_table.h
+++ b/chrome/browser/webdata/keyword_table.h
@@ -67,7 +67,8 @@ class Statement;
// was added in version 52.
// image_url_post_params See TemplateURLData::image_url_post_params. This
// was added in version 52.
-//
+// new_tab_url See TemplateURLData::new_tab_url. This was added in
+// version 53.
//
// This class also manages some fields in the |meta| table:
//
@@ -137,6 +138,7 @@ class KeywordTable : public WebDatabaseTable {
bool MigrateToVersion48RemoveKeywordsBackup();
bool MigrateToVersion49AddSearchTermsReplacementKeyColumn();
bool MigrateToVersion52AddImageSearchAndPOSTSupport();
+ bool MigrateToVersion53AddNewTabURLColumn();
private:
FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContents);
diff --git a/chrome/browser/webdata/keyword_table_unittest.cc b/chrome/browser/webdata/keyword_table_unittest.cc
index 760166e..d9b61a5 100644
--- a/chrome/browser/webdata/keyword_table_unittest.cc
+++ b/chrome/browser/webdata/keyword_table_unittest.cc
@@ -137,6 +137,7 @@ TEST_F(KeywordTableTest, GetTableContents) {
keyword.SetURL("http://url/");
keyword.suggestions_url = "url2";
keyword.image_url = "http://image-search-url/";
+ keyword.new_tab_url = "http://new-tab-url/";
keyword.favicon_url = GURL("http://favicon.url/");
keyword.show_in_default_list = true;
keyword.safe_for_autoreplace = true;
@@ -152,6 +153,7 @@ TEST_F(KeywordTableTest, GetTableContents) {
keyword.SetKeyword(ASCIIToUTF16("url"));
keyword.instant_url = "http://instant2/";
keyword.image_url.clear();
+ keyword.new_tab_url.clear();
keyword.originating_url = GURL("http://originating.url/");
keyword.input_encodings.push_back("Shift_JIS");
keyword.id = 2;
@@ -163,9 +165,9 @@ TEST_F(KeywordTableTest, GetTableContents) {
const char kTestContents[] = "1short_namekeywordhttp://favicon.url/"
"http://url/1001url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]espv"
- "http://image-search-url/2short_nameurlhttp://favicon.url/http://url/1"
- "http://originating.url/00Shift_JIS1url250http://instant2/0"
- "FEDC-BA09-8765-4321[]";
+ "http://image-search-url/http://new-tab-url/2short_nameurl"
+ "http://favicon.url/http://url/1http://originating.url/00Shift_JIS1url250"
+ "http://instant2/0FEDC-BA09-8765-4321[]";
std::string contents;
EXPECT_TRUE(table_->GetTableContents("keywords",
@@ -192,6 +194,7 @@ TEST_F(KeywordTableTest, GetTableContentsOrdering) {
keyword.image_url = "http://image-search-url/";
keyword.search_url_post_params = "ie=utf-8,oe=utf-8";
keyword.image_url_post_params = "name=1,value=2";
+ keyword.new_tab_url = "http://new-tab-url";
EXPECT_TRUE(table_->AddKeyword(keyword));
keyword.SetKeyword(ASCIIToUTF16("url"));
@@ -206,13 +209,15 @@ TEST_F(KeywordTableTest, GetTableContentsOrdering) {
keyword.image_url.clear();
keyword.search_url_post_params.clear();
keyword.image_url_post_params.clear();
+ keyword.new_tab_url.clear();
EXPECT_TRUE(table_->AddKeyword(keyword));
- const char kTestContents[] = "1short_nameurlhttp://favicon.url/http://url/1"
- "http://originating.url/00Shift_JIS1url250http://instant2/0"
- "FEDC-BA09-8765-4321[]2short_namekeywordhttp://favicon.url/"
- "http://url/1001url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]espv"
- "http://image-search-url/ie=utf-8,oe=utf-8name=1,value=2";
+ const char kTestContents[] = "1short_nameurlhttp://favicon.url/"
+ "http://url/1http://originating.url/00Shift_JIS1url250http://instant2/"
+ "0FEDC-BA09-8765-4321[]2short_namekeywordhttp://favicon.url/http://url/"
+ "1001url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]espv"
+ "http://image-search-url/ie=utf-8,oe=utf-8name=1,value=2"
+ "http://new-tab-url";
std::string contents;
EXPECT_TRUE(table_->GetTableContents("keywords",
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 0fefea4..ead6ad8 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -411,6 +411,11 @@ const char kDefaultSearchProviderInstantURL[] =
const char kDefaultSearchProviderImageURL[] =
"default_search_provider.image_url";
+// The URL (as understood by TemplateURLRef) the default search provider uses
+// for the new tab page.
+const char kDefaultSearchProviderNewTabURL[] =
+ "default_search_provider.new_tab_url";
+
// The string of post parameters (as understood by TemplateURLRef) the default
// search provider uses for searches by using POST.
const char kDefaultSearchProviderSearchURLPostParams[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 3d7dbb8..9168388 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -169,6 +169,7 @@ extern const char kDefaultSearchProviderSearchURL[];
extern const char kDefaultSearchProviderSuggestURL[];
extern const char kDefaultSearchProviderInstantURL[];
extern const char kDefaultSearchProviderImageURL[];
+extern const char kDefaultSearchProviderNewTabURL[];
extern const char kDefaultSearchProviderSearchURLPostParams[];
extern const char kDefaultSearchProviderSuggestURLPostParams[];
extern const char kDefaultSearchProviderInstantURLPostParams[];
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json
index d47daca..d3864f0 100644
--- a/chrome/test/data/policy/policy_test_cases.json
+++ b/chrome/test/data/policy/policy_test_cases.json
@@ -769,6 +769,14 @@
]
},
+ "DefaultSearchProviderNewTabURL": {
+ "os": ["win", "linux", "mac", "chromeos"],
+ "test_policy": { "DefaultSearchProviderSearchURL": "http://www.google.com/?q={searchTerms}", "DefaultSearchProviderNewTabURL": "http://www.google.com/newtab" },
+ "pref_mappings": [
+ { "pref": "default_search_provider.new_tab_url" }
+ ]
+ },
+
"DefaultSearchProviderIconURL": {
"os": ["win", "linux", "mac", "chromeos"],
"test_policy": { "DefaultSearchProviderSearchURL": "http://www.google.com/?q={searchTerms}", "DefaultSearchProviderIconURL": "http://www.google.com/favicon.ico" },
diff --git a/components/test/data/web_database/version_52.sql b/components/test/data/web_database/version_52.sql
new file mode 100644
index 0000000..ec362a6
--- /dev/null
+++ b/components/test/data/web_database/version_52.sql
@@ -0,0 +1,33 @@
+PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR);
+INSERT INTO "meta" VALUES('version','52');
+INSERT INTO "meta" VALUES('last_compatible_version','48');
+INSERT INTO "meta" VALUES('Default Search Provider ID','2');
+INSERT INTO "meta" VALUES('Builtin Keyword Version','62');
+CREATE TABLE web_intents ( service_url LONGVARCHAR, action VARCHAR, type VARCHAR, title LONGVARCHAR, disposition VARCHAR, scheme VARCHAR, UNIQUE (service_url, action, scheme, type));
+CREATE TABLE web_intents_defaults ( action VARCHAR, type VARCHAR, url_pattern LONGVARCHAR, user_date INTEGER, suppression INTEGER, service_url LONGVARCHAR, scheme VARCHAR, UNIQUE (action, scheme, type, url_pattern));
+CREATE TABLE keywords (id INTEGER PRIMARY KEY,short_name VARCHAR NOT NULL,keyword VARCHAR NOT NULL,favicon_url VARCHAR NOT NULL,url VARCHAR NOT NULL,safe_for_autoreplace INTEGER,originating_url VARCHAR,date_created INTEGER DEFAULT 0,usage_count INTEGER DEFAULT 0,input_encodings VARCHAR,show_in_default_list INTEGER,suggest_url VARCHAR,prepopulate_id INTEGER DEFAULT 0,created_by_policy INTEGER DEFAULT 0,instant_url VARCHAR,last_modified INTEGER DEFAULT 0,sync_guid VARCHAR,alternate_urls VARCHAR,search_terms_replacement_key VARCHAR,image_url VARCHAR,search_url_post_params VARCHAR,suggest_url_post_params VARCHAR,instant_url_post_params VARCHAR,image_url_post_params VARCHAR);
+INSERT INTO "keywords" VALUES(2,'Google','google.com','http://www.google.com/favicon.ico','{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}',1,'',0,0,'UTF-8',1,'{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&q={searchTerms}&{google:cursorPosition}{google:zeroPrefixUrl}{google:pageClassification}sugkey={google:suggestAPIKeyParameter}',1,0,'{google:baseURL}webhp?sourceid=chrome-instant&{google:RLZ}{google:instantEnabledParameter}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}',0,'2BB4ECA1-7D0F-2FB9-45B0-AD87B8298C9D','["{google:baseURL}#q={searchTerms}","{google:baseURL}search#q={searchTerms}","{google:baseURL}webhp#q={searchTerms}"]','espv','{google:baseURL}searchbyimage/upload','','','','encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource}');
+INSERT INTO "keywords" VALUES(3,'Bing','bing.com','http://www.bing.com/s/wlflag.ico','http://www.bing.com/search?setmkt=en-US&q={searchTerms}',1,'',0,0,'UTF-8',1,'http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}',3,0,'',0,'A0226B1A-8662-A160-C4D4-078608DBD17E','[]','','','','','','');
+INSERT INTO "keywords" VALUES(4,'Yahoo!','yahoo.com','http://search.yahoo.com/favicon.ico','http://search.yahoo.com/search?ei={inputEncoding}&fr=crmas&p={searchTerms}',1,'',0,0,'UTF-8',1,'http://ff.search.yahoo.com/gossip?output=fxjson&command={searchTerms}',2,0,'',0,'531278E0-9380-7556-D9A0-9F85AA1DCF06','[]','','','','','','');
+INSERT INTO "keywords" VALUES(5,'AOL','aol.com','http://search.aol.com/favicon.ico','http://search.aol.com/aol/search?query={searchTerms}',1,'',0,0,'UTF-8',1,'http://autocomplete.search.aol.com/autocomplete/get?output=json&it=&q={searchTerms}',35,0,'',0,'680838DC-A89F-7598-901A-C6B849F94F67','[]','','','','','','');
+INSERT INTO "keywords" VALUES(6,'Ask','ask.com','http://sp.ask.com/sh/i/a16/favicon/favicon.ico','http://www.ask.com/web?q={searchTerms}',1,'',0,0,'UTF-8',1,'http://ss.ask.com/query?q={searchTerms}&li=ff',4,0,'',0,'25AC092A-10E6-EA19-11CE-55382548F3DC','[]','','','','','','');
+CREATE TABLE token_service (service VARCHAR PRIMARY KEY NOT NULL,encrypted_token BLOB);
+CREATE TABLE web_app_icons (url LONGVARCHAR,width int,height int,image BLOB, UNIQUE (url, width, height));
+CREATE TABLE web_apps (url LONGVARCHAR UNIQUE,has_all_images INTEGER NOT NULL);
+CREATE TABLE autofill (name VARCHAR, value VARCHAR, value_lower VARCHAR, pair_id INTEGER PRIMARY KEY, count INTEGER DEFAULT 1);
+CREATE TABLE credit_cards ( guid VARCHAR PRIMARY KEY, name_on_card VARCHAR, expiration_month INTEGER, expiration_year INTEGER, card_number_encrypted BLOB, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '');
+CREATE TABLE autofill_dates ( pair_id INTEGER DEFAULT 0, date_created INTEGER DEFAULT 0);
+CREATE TABLE autofill_profiles ( guid VARCHAR PRIMARY KEY, company_name VARCHAR, address_line_1 VARCHAR, address_line_2 VARCHAR, city VARCHAR, state VARCHAR, zipcode VARCHAR, country VARCHAR, country_code VARCHAR, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '');
+CREATE TABLE autofill_profile_names ( guid VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR);
+CREATE TABLE autofill_profile_emails ( guid VARCHAR, email VARCHAR);
+CREATE TABLE autofill_profile_phones ( guid VARCHAR, type INTEGER DEFAULT 0, number VARCHAR);
+CREATE TABLE autofill_profiles_trash ( guid VARCHAR);
+CREATE INDEX web_intents_index ON web_intents (action);
+CREATE INDEX web_intents_default_index ON web_intents_defaults (action);
+CREATE INDEX web_apps_url_index ON web_apps (url);
+CREATE INDEX autofill_name ON autofill (name);
+CREATE INDEX autofill_name_value_lower ON autofill (name, value_lower);
+CREATE INDEX autofill_dates_pair_id ON autofill_dates (pair_id);
+COMMIT;
diff --git a/components/webdata/common/web_database.cc b/components/webdata/common/web_database.cc
index e4e44ef..161fb80 100644
--- a/components/webdata/common/web_database.cc
+++ b/components/webdata/common/web_database.cc
@@ -14,7 +14,7 @@
// corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
// static
-const int WebDatabase::kCurrentVersionNumber = 52;
+const int WebDatabase::kCurrentVersionNumber = 53;
namespace {
diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc
index 5e6ef6e..770e153 100644
--- a/components/webdata/common/web_database_migration_unittest.cc
+++ b/components/webdata/common/web_database_migration_unittest.cc
@@ -247,7 +247,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 52;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 53;
void WebDatabaseMigrationTest::LoadDatabase(
const base::FilePath::StringType& file) {
@@ -2029,8 +2029,9 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion49ToCurrent) {
}
// Tests that the columns |image_url|, |search_url_post_params|,
-// |suggest_url_post_params|, |instant_url_post_params|, |image_url_post_params|
-// are added to the keyword table schema for a version 52 database.
+// |suggest_url_post_params|, |instant_url_post_params|, and
+// |image_url_post_params| are added to the keyword table schema for a version
+// 50 database.
TEST_F(WebDatabaseMigrationTest, MigrateVersion50ToCurrent) {
ASSERT_NO_FATAL_FAILURE(
LoadDatabase(FILE_PATH_LITERAL("version_50.sql")));
@@ -2080,3 +2081,39 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion50ToCurrent) {
"image_url_post_params"));
}
}
+
+// Tests that the column |new_tab_url| is added to the keyword table schema for
+// a version 52 database.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion52ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(
+ LoadDatabase(FILE_PATH_LITERAL("version_52.sql")));
+
+ // Verify pre-conditions. These are expectations for version 52 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ sql::MetaTable meta_table;
+ ASSERT_TRUE(meta_table.Init(&connection, 52, 52));
+
+ ASSERT_FALSE(connection.DoesColumnExist("keywords", "new_tab_url"));
+ }
+
+ DoMigration();
+
+ // Verify post-conditions. These are expectations for current version of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ // New columns should have been created.
+ EXPECT_TRUE(connection.DoesColumnExist("keywords", "new_tab_url"));
+ }
+}
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 4431357..f4fe44d 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -550,6 +550,7 @@ base::DictionaryValue* SearchEngineSpecificsToValue(
SET_STR(suggestions_url_post_params);
SET_STR(instant_url_post_params);
SET_STR(image_url_post_params);
+ SET_STR(new_tab_url);
return value;
}
diff --git a/sync/protocol/search_engine_specifics.proto b/sync/protocol/search_engine_specifics.proto
index 26c5bec..8db631c 100644
--- a/sync/protocol/search_engine_specifics.proto
+++ b/sync/protocol/search_engine_specifics.proto
@@ -75,5 +75,8 @@ message SearchEngineSpecifics {
optional string suggestions_url_post_params = 23;
optional string instant_url_post_params = 24;
optional string image_url_post_params = 25;
+
+ // The parameterized URL for a search provider specified new tab page.
+ optional string new_tab_url = 26;
}