| 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/importer/nss_decryptor.h" | 5 #include "chrome/browser/importer/nss_decryptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 bool NSSDecryptor::ReadAndParseSignons(const FilePath& sqlite_file, | 235 bool NSSDecryptor::ReadAndParseSignons(const FilePath& sqlite_file, |
| 236 std::vector<webkit::forms::PasswordForm>* forms) { | 236 std::vector<webkit::forms::PasswordForm>* forms) { |
| 237 sql::Connection db; | 237 sql::Connection db; |
| 238 if (!db.Open(sqlite_file)) | 238 if (!db.Open(sqlite_file)) |
| 239 return false; | 239 return false; |
| 240 | 240 |
| 241 const char* query = "SELECT hostname FROM moz_disabledHosts"; | 241 const char* query = "SELECT hostname FROM moz_disabledHosts"; |
| 242 sql::Statement s(db.GetUniqueStatement(query)); | 242 sql::Statement s(db.GetUniqueStatement(query)); |
| 243 if (!s) | 243 if (!s.is_valid()) |
| 244 return false; | 244 return false; |
| 245 | 245 |
| 246 GURL::Replacements rep; | 246 GURL::Replacements rep; |
| 247 rep.ClearQuery(); | 247 rep.ClearQuery(); |
| 248 rep.ClearRef(); | 248 rep.ClearRef(); |
| 249 rep.ClearUsername(); | 249 rep.ClearUsername(); |
| 250 rep.ClearPassword(); | 250 rep.ClearPassword(); |
| 251 // Read domains for which passwords are never saved. | 251 // Read domains for which passwords are never saved. |
| 252 while (s.Step()) { | 252 while (s.Step()) { |
| 253 webkit::forms::PasswordForm form; | 253 webkit::forms::PasswordForm form; |
| 254 form.origin = GURL(s.ColumnString(0)).ReplaceComponents(rep); | 254 form.origin = GURL(s.ColumnString(0)).ReplaceComponents(rep); |
| 255 form.signon_realm = form.origin.GetOrigin().spec(); | 255 form.signon_realm = form.origin.GetOrigin().spec(); |
| 256 form.blacklisted_by_user = true; | 256 form.blacklisted_by_user = true; |
| 257 forms->push_back(form); | 257 forms->push_back(form); |
| 258 } | 258 } |
| 259 | 259 |
| 260 const char* query2 = "SELECT hostname, httpRealm, formSubmitURL, " | 260 const char* query2 = "SELECT hostname, httpRealm, formSubmitURL, " |
| 261 "usernameField, passwordField, encryptedUsername, " | 261 "usernameField, passwordField, encryptedUsername, " |
| 262 "encryptedPassword FROM moz_logins"; | 262 "encryptedPassword FROM moz_logins"; |
| 263 | 263 |
| 264 sql::Statement s2(db.GetUniqueStatement(query2)); | 264 sql::Statement s2(db.GetUniqueStatement(query2)); |
| 265 if (!s2) | 265 if (!s2.is_valid()) |
| 266 return false; | 266 return false; |
| 267 | 267 |
| 268 while (s2.Step()) { | 268 while (s2.Step()) { |
| 269 GURL url; | 269 GURL url; |
| 270 std::string realm(s2.ColumnString(1)); | 270 std::string realm(s2.ColumnString(1)); |
| 271 if (!realm.empty()) { | 271 if (!realm.empty()) { |
| 272 // In this case, the scheme may not exsit. Assume HTTP. | 272 // In this case, the scheme may not exsit. Assume HTTP. |
| 273 std::string host(s2.ColumnString(0)); | 273 std::string host(s2.ColumnString(0)); |
| 274 if (host.find("://") == std::string::npos) | 274 if (host.find("://") == std::string::npos) |
| 275 host = "http://" + host; | 275 host = "http://" + host; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 290 // The user name, password and action. | 290 // The user name, password and action. |
| 291 form.username_element = s2.ColumnString16(3); | 291 form.username_element = s2.ColumnString16(3); |
| 292 form.username_value = Decrypt(s2.ColumnString(5)); | 292 form.username_value = Decrypt(s2.ColumnString(5)); |
| 293 form.password_element = s2.ColumnString16(4); | 293 form.password_element = s2.ColumnString16(4); |
| 294 form.password_value = Decrypt(s2.ColumnString(6)); | 294 form.password_value = Decrypt(s2.ColumnString(6)); |
| 295 form.action = GURL(s2.ColumnString(2)).ReplaceComponents(rep); | 295 form.action = GURL(s2.ColumnString(2)).ReplaceComponents(rep); |
| 296 forms->push_back(form); | 296 forms->push_back(form); |
| 297 } | 297 } |
| 298 return true; | 298 return true; |
| 299 } | 299 } |
| OLD | NEW |