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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_table.cc

Issue 183953005: Rename components's Encryptor to OSEncrypt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/core/browser/webdata/autofill_table.h" 5 #include "components/autofill/core/browser/webdata/autofill_table.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 10 matching lines...) Expand all
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "base/tuple.h" 22 #include "base/tuple.h"
23 #include "components/autofill/core/browser/autofill_country.h" 23 #include "components/autofill/core/browser/autofill_country.h"
24 #include "components/autofill/core/browser/autofill_profile.h" 24 #include "components/autofill/core/browser/autofill_profile.h"
25 #include "components/autofill/core/browser/autofill_type.h" 25 #include "components/autofill/core/browser/autofill_type.h"
26 #include "components/autofill/core/browser/credit_card.h" 26 #include "components/autofill/core/browser/credit_card.h"
27 #include "components/autofill/core/browser/personal_data_manager.h" 27 #include "components/autofill/core/browser/personal_data_manager.h"
28 #include "components/autofill/core/browser/webdata/autofill_change.h" 28 #include "components/autofill/core/browser/webdata/autofill_change.h"
29 #include "components/autofill/core/browser/webdata/autofill_entry.h" 29 #include "components/autofill/core/browser/webdata/autofill_entry.h"
30 #include "components/autofill/core/common/form_field_data.h" 30 #include "components/autofill/core/common/form_field_data.h"
31 #include "components/encryptor/encryptor.h" 31 #include "components/encryptor/os_crypt.h"
32 #include "components/webdata/common/web_database.h" 32 #include "components/webdata/common/web_database.h"
33 #include "sql/statement.h" 33 #include "sql/statement.h"
34 #include "sql/transaction.h" 34 #include "sql/transaction.h"
35 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
36 #include "url/gurl.h" 36 #include "url/gurl.h"
37 37
38 using base::Time; 38 using base::Time;
39 39
40 namespace autofill { 40 namespace autofill {
41 namespace { 41 namespace {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 sql::Statement* s) { 117 sql::Statement* s) {
118 DCHECK(base::IsValidGUID(credit_card.guid())); 118 DCHECK(base::IsValidGUID(credit_card.guid()));
119 int index = 0; 119 int index = 0;
120 s->BindString(index++, credit_card.guid()); 120 s->BindString(index++, credit_card.guid());
121 121
122 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME)); 122 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME));
123 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_MONTH)); 123 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_MONTH));
124 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR)); 124 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR));
125 125
126 std::string encrypted_data; 126 std::string encrypted_data;
127 Encryptor::EncryptString16(credit_card.GetRawInfo(CREDIT_CARD_NUMBER), 127 OSCrypt::EncryptString16(credit_card.GetRawInfo(CREDIT_CARD_NUMBER),
128 &encrypted_data); 128 &encrypted_data);
129 s->BindBlob(index++, encrypted_data.data(), 129 s->BindBlob(index++, encrypted_data.data(),
130 static_cast<int>(encrypted_data.length())); 130 static_cast<int>(encrypted_data.length()));
131 131
132 s->BindInt64(index++, Time::Now().ToTimeT()); 132 s->BindInt64(index++, Time::Now().ToTimeT());
133 s->BindString(index++, credit_card.origin()); 133 s->BindString(index++, credit_card.origin());
134 } 134 }
135 135
136 scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) { 136 scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) {
137 scoped_ptr<CreditCard> credit_card(new CreditCard); 137 scoped_ptr<CreditCard> credit_card(new CreditCard);
138 138
139 int index = 0; 139 int index = 0;
140 credit_card->set_guid(s.ColumnString(index++)); 140 credit_card->set_guid(s.ColumnString(index++));
141 DCHECK(base::IsValidGUID(credit_card->guid())); 141 DCHECK(base::IsValidGUID(credit_card->guid()));
142 142
143 credit_card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(index++)); 143 credit_card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(index++));
144 credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); 144 credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++));
145 credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, 145 credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR,
146 s.ColumnString16(index++)); 146 s.ColumnString16(index++));
147 int encrypted_number_len = s.ColumnByteLength(index); 147 int encrypted_number_len = s.ColumnByteLength(index);
148 base::string16 credit_card_number; 148 base::string16 credit_card_number;
149 if (encrypted_number_len) { 149 if (encrypted_number_len) {
150 std::string encrypted_number; 150 std::string encrypted_number;
151 encrypted_number.resize(encrypted_number_len); 151 encrypted_number.resize(encrypted_number_len);
152 memcpy(&encrypted_number[0], s.ColumnBlob(index++), encrypted_number_len); 152 memcpy(&encrypted_number[0], s.ColumnBlob(index++), encrypted_number_len);
153 Encryptor::DecryptString16(encrypted_number, &credit_card_number); 153 OSCrypt::DecryptString16(encrypted_number, &credit_card_number);
154 } else { 154 } else {
155 index++; 155 index++;
156 } 156 }
157 credit_card->SetRawInfo(CREDIT_CARD_NUMBER, credit_card_number); 157 credit_card->SetRawInfo(CREDIT_CARD_NUMBER, credit_card_number);
158 // Intentionally skip column 5, which stores the modification date. 158 // Intentionally skip column 5, which stores the modification date.
159 index++; 159 index++;
160 credit_card->set_origin(s.ColumnString(index++)); 160 credit_card->set_origin(s.ColumnString(index++));
161 161
162 return credit_card.Pass(); 162 return credit_card.Pass();
163 } 163 }
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 !db_->Execute("CREATE INDEX autofill_name_value_lower ON " 2191 !db_->Execute("CREATE INDEX autofill_name_value_lower ON "
2192 "autofill (name, value_lower)")) { 2192 "autofill (name, value_lower)")) {
2193 return false; 2193 return false;
2194 } 2194 }
2195 2195
2196 2196
2197 return transaction.Commit(); 2197 return transaction.Commit();
2198 } 2198 }
2199 2199
2200 } // namespace autofill 2200 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698