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 "components/webdata/autofill/autofill_table.h" | 5 #include "components/webdata/autofill/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> |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 WebDatabaseTable::TypeKey GetKey() { | 327 WebDatabaseTable::TypeKey GetKey() { |
328 return reinterpret_cast<void*>(&table_key); | 328 return reinterpret_cast<void*>(&table_key); |
329 } | 329 } |
330 | 330 |
331 } // namespace | 331 } // namespace |
332 | 332 |
333 // The maximum length allowed for form data. | 333 // The maximum length allowed for form data. |
334 const size_t AutofillTable::kMaxDataLength = 1024; | 334 const size_t AutofillTable::kMaxDataLength = 1024; |
335 | 335 |
336 AutofillTable::AutofillTable() | 336 AutofillTable::AutofillTable(const std::string& app_locale) |
337 : app_locale_(AutofillCountry::ApplicationLocale()) { | 337 : app_locale_(app_locale) { |
338 } | 338 } |
339 | 339 |
340 AutofillTable::~AutofillTable() { | 340 AutofillTable::~AutofillTable() { |
341 } | 341 } |
342 | 342 |
343 AutofillTable* AutofillTable::FromWebDatabase(WebDatabase* db) { | 343 AutofillTable* AutofillTable::FromWebDatabase(WebDatabase* db) { |
344 return static_cast<AutofillTable*>(db->GetTable(GetKey())); | 344 return static_cast<AutofillTable*>(db->GetTable(GetKey())); |
345 } | 345 } |
346 | 346 |
347 WebDatabaseTable::TypeKey AutofillTable::GetTypeKey() const { | 347 WebDatabaseTable::TypeKey AutofillTable::GetTypeKey() const { |
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 std::string guid = s.ColumnString(0); | 1984 std::string guid = s.ColumnString(0); |
1985 int64 date_modified = s.ColumnInt64(1); | 1985 int64 date_modified = s.ColumnInt64(1); |
1986 modification_map.insert( | 1986 modification_map.insert( |
1987 std::pair<std::string, int64>(guid, date_modified)); | 1987 std::pair<std::string, int64>(guid, date_modified)); |
1988 AutofillProfile* profile = NULL; | 1988 AutofillProfile* profile = NULL; |
1989 if (!GetAutofillProfile(guid, &profile)) | 1989 if (!GetAutofillProfile(guid, &profile)) |
1990 return false; | 1990 return false; |
1991 | 1991 |
1992 scoped_ptr<AutofillProfile> p(profile); | 1992 scoped_ptr<AutofillProfile> p(profile); |
1993 | 1993 |
1994 if (PersonalDataManager::IsValidLearnableProfile(*p)) { | 1994 if (PersonalDataManager::IsValidLearnableProfile(*p, app_locale_)) { |
1995 std::vector<AutofillProfile> merged_profiles; | 1995 std::vector<AutofillProfile> merged_profiles; |
1996 bool merged = PersonalDataManager::MergeProfile( | 1996 bool merged = PersonalDataManager::MergeProfile( |
1997 *p, accumulated_profiles_p, &merged_profiles); | 1997 *p, accumulated_profiles_p, app_locale_, &merged_profiles); |
1998 | 1998 |
1999 std::swap(accumulated_profiles, merged_profiles); | 1999 std::swap(accumulated_profiles, merged_profiles); |
2000 | 2000 |
2001 accumulated_profiles_p.clear(); | 2001 accumulated_profiles_p.clear(); |
2002 accumulated_profiles_p.resize(accumulated_profiles.size()); | 2002 accumulated_profiles_p.resize(accumulated_profiles.size()); |
2003 std::transform(accumulated_profiles.begin(), | 2003 std::transform(accumulated_profiles.begin(), |
2004 accumulated_profiles.end(), | 2004 accumulated_profiles.end(), |
2005 accumulated_profiles_p.begin(), | 2005 accumulated_profiles_p.begin(), |
2006 address_of<AutofillProfile>); | 2006 address_of<AutofillProfile>); |
2007 | 2007 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 "WHERE guid=?")); | 2040 "WHERE guid=?")); |
2041 s_date.BindInt64(0, date_item->second); | 2041 s_date.BindInt64(0, date_item->second); |
2042 s_date.BindString(1, iter->guid()); | 2042 s_date.BindString(1, iter->guid()); |
2043 | 2043 |
2044 if (!s_date.Run()) | 2044 if (!s_date.Run()) |
2045 return false; | 2045 return false; |
2046 } | 2046 } |
2047 | 2047 |
2048 return true; | 2048 return true; |
2049 } | 2049 } |
OLD | NEW |