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