Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/browser/webdata/web_database.cc

Issue 5515006: Revert 68358 - Don't re-save autofill profiles to the web database if they ha... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | chrome/browser/webdata/web_database_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 } 1686 }
1687 1687
1688 while (s.Step()) 1688 while (s.Step())
1689 profiles->push_back(AutoFillProfileFromStatement(s)); 1689 profiles->push_back(AutoFillProfileFromStatement(s));
1690 1690
1691 return s.Succeeded(); 1691 return s.Succeeded();
1692 } 1692 }
1693 1693
1694 bool WebDatabase::UpdateAutoFillProfile(const AutoFillProfile& profile) { 1694 bool WebDatabase::UpdateAutoFillProfile(const AutoFillProfile& profile) {
1695 DCHECK(guid::IsValidGUID(profile.guid())); 1695 DCHECK(guid::IsValidGUID(profile.guid()));
1696
1697 // Preserve appropriate modification dates by not updating unchanged profiles.
1698 AutoFillProfile* tmp_profile = NULL;
1699 DCHECK(GetAutoFillProfileForGUID(profile.guid(), &tmp_profile));
1700 scoped_ptr<AutoFillProfile> old_profile(tmp_profile);
1701 if (*old_profile == profile)
1702 return true;
1703
1704 sql::Statement s(db_.GetUniqueStatement( 1696 sql::Statement s(db_.GetUniqueStatement(
1705 "UPDATE autofill_profiles " 1697 "UPDATE autofill_profiles "
1706 "SET guid=?, label=?, first_name=?, middle_name=?, last_name=?, " 1698 "SET guid=?, label=?, first_name=?, middle_name=?, last_name=?, "
1707 " email=?, company_name=?, address_line_1=?, address_line_2=?, " 1699 " email=?, company_name=?, address_line_1=?, address_line_2=?, "
1708 " city=?, state=?, zipcode=?, country=?, phone=?, fax=?, " 1700 " city=?, state=?, zipcode=?, country=?, phone=?, fax=?, "
1709 " date_modified=? " 1701 " date_modified=? "
1710 "WHERE guid=?")); 1702 "WHERE guid=?"));
1711 if (!s) { 1703 if (!s) {
1712 NOTREACHED() << "Statement prepare failed"; 1704 NOTREACHED() << "Statement prepare failed";
1713 return false; 1705 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 } 1806 }
1815 1807
1816 while (s.Step()) 1808 while (s.Step())
1817 credit_cards->push_back(CreditCardFromStatement(s)); 1809 credit_cards->push_back(CreditCardFromStatement(s));
1818 1810
1819 return s.Succeeded(); 1811 return s.Succeeded();
1820 } 1812 }
1821 1813
1822 bool WebDatabase::UpdateCreditCard(const CreditCard& credit_card) { 1814 bool WebDatabase::UpdateCreditCard(const CreditCard& credit_card) {
1823 DCHECK(guid::IsValidGUID(credit_card.guid())); 1815 DCHECK(guid::IsValidGUID(credit_card.guid()));
1824
1825 // Preserve appropriate modification dates by not updating unchanged cards.
1826 CreditCard* tmp_credit_card = NULL;
1827 DCHECK(GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card));
1828 scoped_ptr<CreditCard> old_credit_card(tmp_credit_card);
1829 if (*old_credit_card == credit_card)
1830 return true;
1831
1832 sql::Statement s(db_.GetUniqueStatement( 1816 sql::Statement s(db_.GetUniqueStatement(
1833 "UPDATE credit_cards " 1817 "UPDATE credit_cards "
1834 "SET guid=?, label=?, name_on_card=?, expiration_month=?, " 1818 "SET guid=?, label=?, name_on_card=?, expiration_month=?, "
1835 " expiration_year=?, card_number_encrypted=?, date_modified=? " 1819 " expiration_year=?, card_number_encrypted=?, date_modified=? "
1836 "WHERE guid=?")); 1820 "WHERE guid=?"));
1837 if (!s) { 1821 if (!s) {
1838 NOTREACHED() << "Statement prepare failed"; 1822 NOTREACHED() << "Statement prepare failed";
1839 return false; 1823 return false;
1840 } 1824 }
1841 1825
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 2557
2574 // Add successive versions here. Each should set the version number and 2558 // Add successive versions here. Each should set the version number and
2575 // compatible version number as appropriate, then fall through to the next 2559 // compatible version number as appropriate, then fall through to the next
2576 // case. 2560 // case.
2577 2561
2578 case kCurrentVersionNumber: 2562 case kCurrentVersionNumber:
2579 // No migration needed. 2563 // No migration needed.
2580 return sql::INIT_OK; 2564 return sql::INIT_OK;
2581 } 2565 }
2582 } 2566 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | chrome/browser/webdata/web_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698