OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "base/tuple.h" | 18 #include "base/tuple.h" |
19 #include "chrome/browser/autofill/autofill_country.h" | 19 #include "chrome/browser/autofill/autofill_country.h" |
20 #include "chrome/browser/autofill/autofill_profile.h" | 20 #include "chrome/browser/autofill/autofill_profile.h" |
21 #include "chrome/browser/autofill/autofill_type.h" | 21 #include "chrome/browser/autofill/autofill_type.h" |
22 #include "chrome/browser/autofill/credit_card.h" | 22 #include "chrome/browser/autofill/credit_card.h" |
23 #include "chrome/browser/autofill/personal_data_manager.h" | 23 #include "chrome/browser/autofill/personal_data_manager.h" |
24 #include "chrome/browser/password_manager/encryptor.h" | 24 #include "chrome/browser/password_manager/encryptor.h" |
25 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | |
25 #include "chrome/browser/webdata/autofill_change.h" | 26 #include "chrome/browser/webdata/autofill_change.h" |
26 #include "chrome/common/guid.h" | 27 #include "chrome/common/guid.h" |
27 #include "sql/statement.h" | 28 #include "sql/statement.h" |
28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
29 #include "webkit/glue/form_field.h" | 30 #include "webkit/glue/form_field.h" |
30 | 31 |
31 using base::Time; | 32 using base::Time; |
32 using webkit_glue::FormField; | 33 using webkit_glue::FormField; |
33 | 34 |
34 namespace { | 35 namespace { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 NOTREACHED() << "Statement prepare failed"; | 340 NOTREACHED() << "Statement prepare failed"; |
340 return false; | 341 return false; |
341 } | 342 } |
342 | 343 |
343 s3.BindString(0, guid); | 344 s3.BindString(0, guid); |
344 return s3.Run(); | 345 return s3.Run(); |
345 } | 346 } |
346 | 347 |
347 } // namespace | 348 } // namespace |
348 | 349 |
350 | |
351 AutofillTable::AutofillTable(sql::Connection* db, sql::MetaTable* meta_table) | |
352 : WebDatabaseTable(db, meta_table), | |
353 autofill_profile_syncable_service_(NULL) { | |
354 } | |
355 | |
356 AutofillTable::~AutofillTable() { | |
357 } | |
358 | |
349 bool AutofillTable::Init() { | 359 bool AutofillTable::Init() { |
350 return (InitMainTable() && InitCreditCardsTable() && InitDatesTable() && | 360 return (InitMainTable() && InitCreditCardsTable() && InitDatesTable() && |
351 InitProfilesTable() && InitProfileNamesTable() && | 361 InitProfilesTable() && InitProfileNamesTable() && |
352 InitProfileEmailsTable() && InitProfilePhonesTable() && | 362 InitProfileEmailsTable() && InitProfilePhonesTable() && |
353 InitProfileTrashTable()); | 363 InitProfileTrashTable()); |
354 } | 364 } |
355 | 365 |
356 bool AutofillTable::IsSyncable() { | 366 bool AutofillTable::IsSyncable() { |
357 return true; | 367 return true; |
358 } | 368 } |
359 | 369 |
370 AutofillProfileSyncableService* AutofillTable::GetSyncableService( | |
371 WebDatabase* web_database, | |
372 Profile* profile) { | |
373 if (!autofill_profile_syncable_service_.get()) { | |
374 autofill_profile_syncable_service_.reset( | |
375 new AutofillProfileSyncableService(web_database, profile)); | |
376 } | |
377 | |
378 DCHECK_EQ(web_database, autofill_profile_syncable_service_->web_database()); | |
akalin
2011/10/10 21:58:57
this seems kinda gross. It seems to me that WebDa
Ilya Sherman
2011/10/10 22:33:13
This would still be "needed" even if the WebDataba
| |
379 DCHECK_EQ(profile, autofill_profile_syncable_service_->profile()); | |
380 return autofill_profile_syncable_service_.get(); | |
381 } | |
382 | |
360 bool AutofillTable::AddFormFieldValues(const std::vector<FormField>& elements, | 383 bool AutofillTable::AddFormFieldValues(const std::vector<FormField>& elements, |
361 std::vector<AutofillChange>* changes) { | 384 std::vector<AutofillChange>* changes) { |
362 return AddFormFieldValuesTime(elements, changes, Time::Now()); | 385 return AddFormFieldValuesTime(elements, changes, Time::Now()); |
363 } | 386 } |
364 | 387 |
365 bool AutofillTable::AddFormFieldValue(const FormField& element, | 388 bool AutofillTable::AddFormFieldValue(const FormField& element, |
366 std::vector<AutofillChange>* changes) { | 389 std::vector<AutofillChange>* changes) { |
367 return AddFormFieldValueTime(element, changes, Time::Now()); | 390 return AddFormFieldValueTime(element, changes, Time::Now()); |
368 } | 391 } |
369 | 392 |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2101 "UPDATE autofill_profiles SET date_modified=? " | 2124 "UPDATE autofill_profiles SET date_modified=? " |
2102 "WHERE guid=?")); | 2125 "WHERE guid=?")); |
2103 s_date.BindInt64(0, date_item->second); | 2126 s_date.BindInt64(0, date_item->second); |
2104 s_date.BindString(1, iter->guid()); | 2127 s_date.BindString(1, iter->guid()); |
2105 if (!s_date.Run()) | 2128 if (!s_date.Run()) |
2106 return false; | 2129 return false; |
2107 } | 2130 } |
2108 | 2131 |
2109 return true; | 2132 return true; |
2110 } | 2133 } |
OLD | NEW |