OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/webdata/web_database.h" | 5 #include "chrome/browser/webdata/web_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const int kUrlIdPosition = 16; | 172 const int kUrlIdPosition = 16; |
173 | 173 |
174 // Keys used in the meta table. | 174 // Keys used in the meta table. |
175 const char* kDefaultSearchProviderKey = "Default Search Provider ID"; | 175 const char* kDefaultSearchProviderKey = "Default Search Provider ID"; |
176 const char* kBuiltinKeywordVersion = "Builtin Keyword Version"; | 176 const char* kBuiltinKeywordVersion = "Builtin Keyword Version"; |
177 | 177 |
178 // The maximum length allowed for form data. | 178 // The maximum length allowed for form data. |
179 const size_t kMaxDataLength = 1024; | 179 const size_t kMaxDataLength = 1024; |
180 | 180 |
181 void BindURLToStatement(const TemplateURL& url, sql::Statement* s) { | 181 void BindURLToStatement(const TemplateURL& url, sql::Statement* s) { |
182 s->BindString(0, WideToUTF8(url.short_name())); | 182 s->BindString(0, UTF16ToUTF8(url.short_name())); |
183 s->BindString(1, WideToUTF8(url.keyword())); | 183 s->BindString(1, UTF16ToUTF8(url.keyword())); |
184 GURL favicon_url = url.GetFavIconURL(); | 184 GURL favicon_url = url.GetFavIconURL(); |
185 if (!favicon_url.is_valid()) { | 185 if (!favicon_url.is_valid()) { |
186 s->BindString(2, std::string()); | 186 s->BindString(2, std::string()); |
187 } else { | 187 } else { |
188 s->BindString(2, history::HistoryDatabase::GURLToDatabaseURL( | 188 s->BindString(2, history::HistoryDatabase::GURLToDatabaseURL( |
189 url.GetFavIconURL())); | 189 url.GetFavIconURL())); |
190 } | 190 } |
191 s->BindString(3, url.url() ? url.url()->url() : std::string()); | 191 s->BindString(3, url.url() ? url.url()->url() : std::string()); |
192 s->BindInt(4, url.safe_for_autoreplace() ? 1 : 0); | 192 s->BindInt(4, url.safe_for_autoreplace() ? 1 : 0); |
193 if (!url.originating_url().is_valid()) { | 193 if (!url.originating_url().is_valid()) { |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 NOTREACHED() << "Statement prepare failed"; | 859 NOTREACHED() << "Statement prepare failed"; |
860 return false; | 860 return false; |
861 } | 861 } |
862 while (s.Step()) { | 862 while (s.Step()) { |
863 TemplateURL* template_url = new TemplateURL(); | 863 TemplateURL* template_url = new TemplateURL(); |
864 template_url->set_id(s.ColumnInt64(0)); | 864 template_url->set_id(s.ColumnInt64(0)); |
865 | 865 |
866 std::string tmp; | 866 std::string tmp; |
867 tmp = s.ColumnString(1); | 867 tmp = s.ColumnString(1); |
868 DCHECK(!tmp.empty()); | 868 DCHECK(!tmp.empty()); |
869 template_url->set_short_name(UTF8ToWide(tmp)); | 869 template_url->set_short_name(UTF8ToUTF16(tmp)); |
870 | 870 |
871 template_url->set_keyword(UTF8ToWide(s.ColumnString(2))); | 871 template_url->set_keyword(UTF8ToUTF16(s.ColumnString(2))); |
872 | 872 |
873 tmp = s.ColumnString(3); | 873 tmp = s.ColumnString(3); |
874 if (!tmp.empty()) | 874 if (!tmp.empty()) |
875 template_url->SetFavIconURL(GURL(tmp)); | 875 template_url->SetFavIconURL(GURL(tmp)); |
876 | 876 |
877 template_url->SetURL(s.ColumnString(4), 0, 0); | 877 template_url->SetURL(s.ColumnString(4), 0, 0); |
878 | 878 |
879 template_url->set_safe_for_autoreplace(s.ColumnInt(5) == 1); | 879 template_url->set_safe_for_autoreplace(s.ColumnInt(5) == 1); |
880 | 880 |
881 tmp = s.ColumnString(6); | 881 tmp = s.ColumnString(6); |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 "verification_code_encrypted BLOB)")) { | 2196 "verification_code_encrypted BLOB)")) { |
2197 LOG(WARNING) << "Unable to update web database to version 27."; | 2197 LOG(WARNING) << "Unable to update web database to version 27."; |
2198 NOTREACHED(); | 2198 NOTREACHED(); |
2199 return sql::INIT_FAILURE; | 2199 return sql::INIT_FAILURE; |
2200 } | 2200 } |
2201 | 2201 |
2202 if (!db_.Execute( | 2202 if (!db_.Execute( |
2203 "INSERT INTO credit_cards_temp " | 2203 "INSERT INTO credit_cards_temp " |
2204 "SELECT label,unique_id,name_on_card,type,card_number," | 2204 "SELECT label,unique_id,name_on_card,type,card_number," |
2205 "expiration_month,expiration_year,verification_code,0," | 2205 "expiration_month,expiration_year,verification_code,0," |
2206 "shipping_address,card_number_encrypted,verification_code_encrypted
" | 2206 "shipping_address,card_number_encrypted," |
2207 "FROM credit_cards")) { | 2207 "verification_code_encrypted FROM credit_cards")) { |
2208 LOG(WARNING) << "Unable to update web database to version 27."; | 2208 LOG(WARNING) << "Unable to update web database to version 27."; |
2209 NOTREACHED(); | 2209 NOTREACHED(); |
2210 return sql::INIT_FAILURE; | 2210 return sql::INIT_FAILURE; |
2211 } | 2211 } |
2212 | 2212 |
2213 if (!db_.Execute("DROP TABLE credit_cards")) { | 2213 if (!db_.Execute("DROP TABLE credit_cards")) { |
2214 LOG(WARNING) << "Unable to update web database to version 27."; | 2214 LOG(WARNING) << "Unable to update web database to version 27."; |
2215 NOTREACHED(); | 2215 NOTREACHED(); |
2216 return sql::INIT_FAILURE; | 2216 return sql::INIT_FAILURE; |
2217 } | 2217 } |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 "fax VARCHAR, " | 2502 "fax VARCHAR, " |
2503 "date_modified INTEGER NOT NULL DEFAULT 0)")) { | 2503 "date_modified INTEGER NOT NULL DEFAULT 0)")) { |
2504 LOG(WARNING) << "Unable to update web database to version 32."; | 2504 LOG(WARNING) << "Unable to update web database to version 32."; |
2505 NOTREACHED(); | 2505 NOTREACHED(); |
2506 return sql::INIT_FAILURE; | 2506 return sql::INIT_FAILURE; |
2507 } | 2507 } |
2508 | 2508 |
2509 if (!db_.Execute( | 2509 if (!db_.Execute( |
2510 "INSERT INTO autofill_profiles_temp " | 2510 "INSERT INTO autofill_profiles_temp " |
2511 "SELECT guid, label, first_name, middle_name, last_name, email, " | 2511 "SELECT guid, label, first_name, middle_name, last_name, email, " |
2512 "company_name, address_line_1, address_line_2, city, state, zipcode,
" | 2512 "company_name, address_line_1, address_line_2, city, state, " |
2513 "country, phone, fax, date_modified " | 2513 "zipcode, country, phone, fax, date_modified " |
2514 "FROM autofill_profiles")) { | 2514 "FROM autofill_profiles")) { |
2515 LOG(WARNING) << "Unable to update web database to version 32."; | 2515 LOG(WARNING) << "Unable to update web database to version 32."; |
2516 NOTREACHED(); | 2516 NOTREACHED(); |
2517 return sql::INIT_FAILURE; | 2517 return sql::INIT_FAILURE; |
2518 } | 2518 } |
2519 | 2519 |
2520 if (!db_.Execute("DROP TABLE autofill_profiles")) { | 2520 if (!db_.Execute("DROP TABLE autofill_profiles")) { |
2521 LOG(WARNING) << "Unable to update web database to version 32."; | 2521 LOG(WARNING) << "Unable to update web database to version 32."; |
2522 NOTREACHED(); | 2522 NOTREACHED(); |
2523 return sql::INIT_FAILURE; | 2523 return sql::INIT_FAILURE; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 | 2577 |
2578 // Add successive versions here. Each should set the version number and | 2578 // Add successive versions here. Each should set the version number and |
2579 // compatible version number as appropriate, then fall through to the next | 2579 // compatible version number as appropriate, then fall through to the next |
2580 // case. | 2580 // case. |
2581 | 2581 |
2582 case kCurrentVersionNumber: | 2582 case kCurrentVersionNumber: |
2583 // No migration needed. | 2583 // No migration needed. |
2584 return sql::INIT_OK; | 2584 return sql::INIT_OK; |
2585 } | 2585 } |
2586 } | 2586 } |
OLD | NEW |