summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc2
-rw-r--r--chrome/browser/webdata/web_database.cc41
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc10
3 files changed, 41 insertions, 12 deletions
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index d2ea87a..05b8a12 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -3141,7 +3141,7 @@ void RegisterUserPrefs(PrefService* prefs) {
int GetDataVersion(PrefService* prefs) {
// Increment this if you change the above data in ways that mean users with
// existing data should get a new version.
- const int kCurrentDataVersion = 28;
+ const int kCurrentDataVersion = 29;
if (!prefs)
return kCurrentDataVersion;
// If a version number exist in the preferences file, it overrides the
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 005c8b2..17b0baf 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -56,8 +56,9 @@ using webkit_glue::PasswordForm;
// input_encodings Semicolon separated list of supported input
// encodings, may be empty.
// suggest_url
-// prepopulate_id See TemplateURL::prepoulate_id.
+// prepopulate_id See TemplateURL::prepopulate_id.
// autogenerate_keyword
+// logo_id See TemplateURL::logo_id
//
// logins
// origin_url
@@ -157,8 +158,9 @@ namespace {
typedef std::vector<Tuple3<int64, string16, string16> > AutofillElementList;
// Current version number.
-const int kCurrentVersionNumber = 24;
-const int kCompatibleVersionNumber = 21;
+const int kCurrentVersionNumber = 25;
+const int kCompatibleVersionNumber = 25;
+const int kUrlIdPosition = 14;
// Keys used in the meta table.
const char* kDefaultSearchProviderKey = "Default Search Provider ID";
@@ -209,6 +211,7 @@ void BindURLToStatement(const TemplateURL& url, sql::Statement* s) {
s->BindString(10, std::string());
s->BindInt(11, url.prepopulate_id());
s->BindInt(12, url.autogenerate_keyword() ? 1 : 0);
+ s->BindInt(13, url.logo_id());
}
void InitPasswordFormFromStatement(PasswordForm* form, sql::Statement* s) {
@@ -623,7 +626,8 @@ bool WebDatabase::InitKeywordsTable() {
"input_encodings VARCHAR,"
"suggest_url VARCHAR,"
"prepopulate_id INTEGER DEFAULT 0,"
- "autogenerate_keyword INTEGER DEFAULT 0)")) {
+ "autogenerate_keyword INTEGER DEFAULT 0,"
+ "logo_id INTEGER DEFAULT 0)")) {
NOTREACHED();
return false;
}
@@ -829,14 +833,14 @@ bool WebDatabase::AddKeyword(const TemplateURL& url) {
"(short_name, keyword, favicon_url, url, safe_for_autoreplace, "
"originating_url, date_created, usage_count, input_encodings, "
"show_in_default_list, suggest_url, prepopulate_id, "
- "autogenerate_keyword, id) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"));
+ "autogenerate_keyword, logo_id, id) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"));
if (!s) {
NOTREACHED() << "Statement prepare failed";
return false;
}
BindURLToStatement(url, &s);
- s.BindInt64(13, url.id());
+ s.BindInt64(kUrlIdPosition, url.id());
if (!s.Run()) {
NOTREACHED();
return false;
@@ -860,7 +864,7 @@ bool WebDatabase::GetKeywords(std::vector<TemplateURL*>* urls) {
"SELECT id, short_name, keyword, favicon_url, url, "
"safe_for_autoreplace, originating_url, date_created, "
"usage_count, input_encodings, show_in_default_list, "
- "suggest_url, prepopulate_id, autogenerate_keyword "
+ "suggest_url, prepopulate_id, autogenerate_keyword, logo_id "
"FROM keywords ORDER BY id ASC"));
if (!s) {
NOTREACHED() << "Statement prepare failed";
@@ -908,6 +912,8 @@ bool WebDatabase::GetKeywords(std::vector<TemplateURL*>* urls) {
template_url->set_autogenerate_keyword(s.ColumnInt(13) == 1);
+ template_url->set_logo_id(s.ColumnInt(14));
+
urls->push_back(template_url);
}
return s.Succeeded();
@@ -920,14 +926,14 @@ bool WebDatabase::UpdateKeyword(const TemplateURL& url) {
"SET short_name=?, keyword=?, favicon_url=?, url=?, "
"safe_for_autoreplace=?, originating_url=?, date_created=?, "
"usage_count=?, input_encodings=?, show_in_default_list=?, "
- "suggest_url=?, prepopulate_id=?, autogenerate_keyword=? "
- "WHERE id=?"));
+ "suggest_url=?, prepopulate_id=?, autogenerate_keyword=?, "
+ "logo_id=? WHERE id=?"));
if (!s) {
NOTREACHED() << "Statement prepare failed";
return false;
}
BindURLToStatement(url, &s);
- s.BindInt64(13, url.id());
+ s.BindInt64(kUrlIdPosition, url.id());
return s.Run();
}
@@ -1974,6 +1980,19 @@ void WebDatabase::MigrateOldVersionsAsNeeded() {
// FALL THROUGH
}
+ case 24:
+ // Add the logo_id column.
+ if (!db_.Execute("ALTER TABLE keywords ADD COLUMN logo_id "
+ "INTEGER DEFAULT 0")) {
+ NOTREACHED();
+ LOG(WARNING) << "Unable to update web database to version 25.";
+ return;
+ }
+ meta_table_.SetVersionNumber(25);
+ meta_table_.SetCompatibleVersionNumber(
+ std::min(25, kCompatibleVersionNumber));
+ // FALL THROUGH
+
// Add successive versions here. Each should set the version number and
// compatible version number as appropriate, then fall through to the next
// case.
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index 25109a7..48301ff 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -155,6 +155,10 @@ class WebDatabaseTest : public testing::Test {
url->set_prepopulate_id(id);
}
+ static void set_logo_id(TemplateURL* url, int id) {
+ url->set_logo_id(id);
+ }
+
static AutofillEntry MakeAutofillEntry(const char* name,
const char* value,
time_t timestamp0,
@@ -189,6 +193,7 @@ TEST_F(WebDatabaseTest, Keywords) {
template_url.set_usage_count(32);
template_url.add_input_encoding("UTF-8");
set_prepopulate_id(&template_url, 10);
+ set_logo_id(&template_url, 1000);
SetID(1, &template_url);
EXPECT_TRUE(db.AddKeyword(template_url));
@@ -222,6 +227,8 @@ TEST_F(WebDatabaseTest, Keywords) {
EXPECT_EQ(10, restored_url->prepopulate_id());
+ EXPECT_EQ(1000, restored_url->logo_id());
+
EXPECT_TRUE(db.RemoveKeyword(restored_url->id()));
template_urls.clear();
@@ -272,6 +279,7 @@ TEST_F(WebDatabaseTest, UpdateKeyword) {
EXPECT_EQ(L"url", template_url.keyword());
template_url.add_input_encoding("Shift_JIS");
set_prepopulate_id(&template_url, 5);
+ set_logo_id(&template_url, 2000);
EXPECT_TRUE(db.UpdateKeyword(template_url));
std::vector<TemplateURL*> template_urls;
@@ -306,6 +314,8 @@ TEST_F(WebDatabaseTest, UpdateKeyword) {
EXPECT_EQ(template_url.prepopulate_id(), restored_url->prepopulate_id());
+ EXPECT_EQ(template_url.logo_id(), restored_url->logo_id());
+
delete restored_url;
}