| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autofill_table.h" | 5 #include "chrome/browser/webdata/autofill_table.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/guid.h" | 14 #include "base/guid.h" |
| 15 #include "base/i18n/case_conversion.h" | 15 #include "base/i18n/case_conversion.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "base/tuple.h" | 19 #include "base/tuple.h" |
| 20 #include "chrome/browser/password_manager/encryptor.h" | 20 #include "chrome/browser/password_manager/encryptor.h" |
| 21 #include "chrome/browser/webdata/autofill_change.h" | 21 #include "chrome/browser/webdata/autofill_change.h" |
| 22 #include "chrome/browser/webdata/autofill_entry.h" | 22 #include "chrome/browser/webdata/autofill_entry.h" |
| 23 #include "chrome/browser/webdata/web_database.h" |
| 23 #include "components/autofill/browser/autofill_country.h" | 24 #include "components/autofill/browser/autofill_country.h" |
| 24 #include "components/autofill/browser/autofill_profile.h" | 25 #include "components/autofill/browser/autofill_profile.h" |
| 25 #include "components/autofill/browser/autofill_type.h" | 26 #include "components/autofill/browser/autofill_type.h" |
| 26 #include "components/autofill/browser/credit_card.h" | 27 #include "components/autofill/browser/credit_card.h" |
| 27 #include "components/autofill/browser/personal_data_manager.h" | 28 #include "components/autofill/browser/personal_data_manager.h" |
| 28 #include "components/autofill/common/form_field_data.h" | 29 #include "components/autofill/common/form_field_data.h" |
| 29 #include "sql/statement.h" | 30 #include "sql/statement.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 | 32 |
| 32 using base::Time; | 33 using base::Time; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 if (!s2.Run()) | 313 if (!s2.Run()) |
| 313 return false; | 314 return false; |
| 314 | 315 |
| 315 sql::Statement s3(db->GetUniqueStatement( | 316 sql::Statement s3(db->GetUniqueStatement( |
| 316 "DELETE FROM autofill_profile_phones WHERE guid = ?")); | 317 "DELETE FROM autofill_profile_phones WHERE guid = ?")); |
| 317 s3.BindString(0, guid); | 318 s3.BindString(0, guid); |
| 318 | 319 |
| 319 return s3.Run(); | 320 return s3.Run(); |
| 320 } | 321 } |
| 321 | 322 |
| 323 int table_key = 0; |
| 324 |
| 325 WebDatabaseTable::TypeKey GetKey() { |
| 326 return reinterpret_cast<void*>(&table_key); |
| 327 } |
| 328 |
| 322 } // namespace | 329 } // namespace |
| 323 | 330 |
| 324 // The maximum length allowed for form data. | 331 // The maximum length allowed for form data. |
| 325 const size_t AutofillTable::kMaxDataLength = 1024; | 332 const size_t AutofillTable::kMaxDataLength = 1024; |
| 326 | 333 |
| 327 AutofillTable::AutofillTable(sql::Connection* db, sql::MetaTable* meta_table) | 334 AutofillTable::AutofillTable() { |
| 328 : WebDatabaseTable(db, meta_table) { | |
| 329 } | 335 } |
| 330 | 336 |
| 331 AutofillTable::~AutofillTable() { | 337 AutofillTable::~AutofillTable() { |
| 332 } | 338 } |
| 333 | 339 |
| 334 bool AutofillTable::Init() { | 340 AutofillTable* AutofillTable::FromWebDatabase(WebDatabase* db) { |
| 335 return (InitMainTable() && InitCreditCardsTable() && InitDatesTable() && | 341 return static_cast<AutofillTable*>(db->GetTable(GetKey())); |
| 336 InitProfilesTable() && InitProfileNamesTable() && | 342 } |
| 337 InitProfileEmailsTable() && InitProfilePhonesTable() && | 343 |
| 338 InitProfileTrashTable()); | 344 WebDatabaseTable::TypeKey AutofillTable::GetTypeKey() const { |
| 345 return GetKey(); |
| 346 } |
| 347 |
| 348 bool AutofillTable::Init(sql::Connection* db, sql::MetaTable* meta_table) { |
| 349 WebDatabaseTable::Init(db, meta_table); |
| 350 return (InitMainTable() && InitCreditCardsTable() && InitDatesTable() && |
| 351 InitProfilesTable() && InitProfileNamesTable() && |
| 352 InitProfileEmailsTable() && InitProfilePhonesTable() && |
| 353 InitProfileTrashTable()); |
| 339 } | 354 } |
| 340 | 355 |
| 341 bool AutofillTable::IsSyncable() { | 356 bool AutofillTable::IsSyncable() { |
| 342 return true; | 357 return true; |
| 343 } | 358 } |
| 344 | 359 |
| 345 bool AutofillTable::MigrateToVersion(int version, | 360 bool AutofillTable::MigrateToVersion(int version, |
| 346 const std::string& app_locale, | 361 const std::string& app_locale, |
| 347 bool* update_compatible_version) { | 362 bool* update_compatible_version) { |
| 348 // Migrate if necessary. | 363 // Migrate if necessary. |
| (...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 "WHERE guid=?")); | 2039 "WHERE guid=?")); |
| 2025 s_date.BindInt64(0, date_item->second); | 2040 s_date.BindInt64(0, date_item->second); |
| 2026 s_date.BindString(1, iter->guid()); | 2041 s_date.BindString(1, iter->guid()); |
| 2027 | 2042 |
| 2028 if (!s_date.Run()) | 2043 if (!s_date.Run()) |
| 2029 return false; | 2044 return false; |
| 2030 } | 2045 } |
| 2031 | 2046 |
| 2032 return true; | 2047 return true; |
| 2033 } | 2048 } |
| OLD | NEW |