Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / utility / importer / nss_decryptor_system_nss.h
blobde2dd7272878e13412b3c89506c3fbfb7397a595
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
3 // found in the LICENSE file.
5 #ifndef CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_
6 #define CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_
8 #include <secmodt.h>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/strings/string16.h"
15 struct FirefoxRawPasswordInfo;
17 namespace autofill {
18 struct PasswordForm;
21 namespace base {
22 class FilePath;
25 // A wrapper for Firefox NSS decrypt component.
26 class NSSDecryptor {
27 public:
28 NSSDecryptor();
29 ~NSSDecryptor();
31 // Initializes NSS if it hasn't already been initialized.
32 bool Init(const base::FilePath& dll_path, const base::FilePath& db_path);
34 // Decrypts Firefox stored passwords. Before using this method,
35 // make sure Init() returns true.
36 base::string16 Decrypt(const std::string& crypt) const;
38 // Parses the Firefox password file content, decrypts the
39 // username/password and reads other related information.
40 // The result will be stored in |forms|.
41 void ParseSignons(const base::FilePath& signon_file,
42 std::vector<autofill::PasswordForm>* forms);
44 // Reads and parses the Firefox password sqlite db, decrypts the
45 // username/password and reads other related information.
46 // The result will be stored in |forms|.
47 bool ReadAndParseSignons(const base::FilePath& sqlite_file,
48 std::vector<autofill::PasswordForm>* forms);
50 // Reads and parses the Firefox password file logins.json, decrypts the
51 // username/password and reads other related information.
52 // The result will be stored in |forms|.
53 bool ReadAndParseLogins(const base::FilePath& json_file,
54 std::vector<autofill::PasswordForm>* forms);
56 private:
57 // Does not actually free the slot, since we'll free it when NSSDecryptor is
58 // destroyed.
59 void FreeSlot(PK11SlotInfo* slot) const {}
61 // Turns unprocessed information extracted from Firefox's password file
62 // into PasswordForm.
63 bool CreatePasswordFormFromRawInfo(
64 const FirefoxRawPasswordInfo& raw_password_info,
65 autofill::PasswordForm* form);
67 PK11SlotInfo* GetKeySlotForDB() const { return db_slot_; }
69 SECStatus PK11SDR_DecryptWithSlot(
70 PK11SlotInfo* slot, SECItem* data, SECItem* result, void* cx) const;
72 bool is_nss_initialized_;
73 PK11SlotInfo* db_slot_;
75 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor);
78 #endif // CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_