| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ | 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <secmodt.h> | 9 #include <secmodt.h> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 | 15 |
| 16 class FilePath; | 16 class FilePath; |
| 17 | 17 |
| 18 namespace webkit_glue { | 18 namespace webkit { |
| 19 namespace forms { |
| 19 struct PasswordForm; | 20 struct PasswordForm; |
| 20 } | 21 } |
| 22 } |
| 21 | 23 |
| 22 // A wrapper for Firefox NSS decrypt component. | 24 // A wrapper for Firefox NSS decrypt component. |
| 23 class NSSDecryptor { | 25 class NSSDecryptor { |
| 24 public: | 26 public: |
| 25 NSSDecryptor(); | 27 NSSDecryptor(); |
| 26 ~NSSDecryptor(); | 28 ~NSSDecryptor(); |
| 27 | 29 |
| 28 // Initializes NSS if it hasn't already been initialized. | 30 // Initializes NSS if it hasn't already been initialized. |
| 29 bool Init(const FilePath& dll_path, const FilePath& db_path); | 31 bool Init(const FilePath& dll_path, const FilePath& db_path); |
| 30 | 32 |
| 31 // Decrypts Firefox stored passwords. Before using this method, | 33 // Decrypts Firefox stored passwords. Before using this method, |
| 32 // make sure Init() returns true. | 34 // make sure Init() returns true. |
| 33 string16 Decrypt(const std::string& crypt) const; | 35 string16 Decrypt(const std::string& crypt) const; |
| 34 | 36 |
| 35 // Parses the Firefox password file content, decrypts the | 37 // Parses the Firefox password file content, decrypts the |
| 36 // username/password and reads other related information. | 38 // username/password and reads other related information. |
| 37 // The result will be stored in |forms|. | 39 // The result will be stored in |forms|. |
| 38 void ParseSignons(const std::string& content, | 40 void ParseSignons(const std::string& content, |
| 39 std::vector<webkit_glue::PasswordForm>* forms); | 41 std::vector<webkit::forms::PasswordForm>* forms); |
| 40 | 42 |
| 41 // Reads and parses the Firefox password sqlite db, decrypts the | 43 // Reads and parses the Firefox password sqlite db, decrypts the |
| 42 // username/password and reads other related information. | 44 // username/password and reads other related information. |
| 43 // The result will be stored in |forms|. | 45 // The result will be stored in |forms|. |
| 44 bool ReadAndParseSignons(const FilePath& sqlite_file, | 46 bool ReadAndParseSignons(const FilePath& sqlite_file, |
| 45 std::vector<webkit_glue::PasswordForm>* forms); | 47 std::vector<webkit::forms::PasswordForm>* forms); |
| 46 private: | 48 private: |
| 47 // Does not actually free the slot, since we'll free it when NSSDecryptor is | 49 // Does not actually free the slot, since we'll free it when NSSDecryptor is |
| 48 // destroyed. | 50 // destroyed. |
| 49 void FreeSlot(PK11SlotInfo* slot) const {} | 51 void FreeSlot(PK11SlotInfo* slot) const {} |
| 50 PK11SlotInfo* GetKeySlotForDB() const { return db_slot_; } | 52 PK11SlotInfo* GetKeySlotForDB() const { return db_slot_; } |
| 51 | 53 |
| 52 SECStatus PK11SDR_DecryptWithSlot( | 54 SECStatus PK11SDR_DecryptWithSlot( |
| 53 PK11SlotInfo* slot, SECItem* data, SECItem* result, void* cx) const; | 55 PK11SlotInfo* slot, SECItem* data, SECItem* result, void* cx) const; |
| 54 | 56 |
| 55 bool is_nss_initialized_; | 57 bool is_nss_initialized_; |
| 56 PK11SlotInfo* db_slot_; | 58 PK11SlotInfo* db_slot_; |
| 57 | 59 |
| 58 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 60 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ | 63 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ |
| OLD | NEW |