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_WIN_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); | 98 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); |
99 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); | 99 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); |
100 typedef SECStatus | 100 typedef SECStatus |
101 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); | 101 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); |
102 typedef SECStatus | 102 typedef SECStatus |
103 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); | 103 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); |
104 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); | 104 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); |
105 typedef void (*PLArenaFinishFunc)(void); | 105 typedef void (*PLArenaFinishFunc)(void); |
106 typedef PRStatus (*PRCleanupFunc)(void); | 106 typedef PRStatus (*PRCleanupFunc)(void); |
107 | 107 |
108 namespace webkit_glue { | 108 namespace webkit { |
| 109 namespace forms { |
109 struct PasswordForm; | 110 struct PasswordForm; |
110 } | 111 } |
| 112 } |
111 | 113 |
112 // A wrapper for Firefox NSS decrypt component. | 114 // A wrapper for Firefox NSS decrypt component. |
113 class NSSDecryptor { | 115 class NSSDecryptor { |
114 public: | 116 public: |
115 NSSDecryptor(); | 117 NSSDecryptor(); |
116 ~NSSDecryptor(); | 118 ~NSSDecryptor(); |
117 | 119 |
118 // Loads NSS3 library and returns true if successful. | 120 // Loads NSS3 library and returns true if successful. |
119 // |dll_path| indicates the location of NSS3 DLL files, and |db_path| | 121 // |dll_path| indicates the location of NSS3 DLL files, and |db_path| |
120 // is the location of the database file that stores the keys. | 122 // is the location of the database file that stores the keys. |
121 bool Init(const FilePath& dll_path, const FilePath& db_path); | 123 bool Init(const FilePath& dll_path, const FilePath& db_path); |
122 | 124 |
123 // Frees the libraries. | 125 // Frees the libraries. |
124 void Free(); | 126 void Free(); |
125 | 127 |
126 // Decrypts Firefox stored passwords. Before using this method, | 128 // Decrypts Firefox stored passwords. Before using this method, |
127 // make sure Init() returns true. | 129 // make sure Init() returns true. |
128 string16 Decrypt(const std::string& crypt) const; | 130 string16 Decrypt(const std::string& crypt) const; |
129 | 131 |
130 // Parses the Firefox password file content, decrypts the | 132 // Parses the Firefox password file content, decrypts the |
131 // username/password and reads other related information. | 133 // username/password and reads other related information. |
132 // The result will be stored in |forms|. | 134 // The result will be stored in |forms|. |
133 void ParseSignons(const std::string& content, | 135 void ParseSignons(const std::string& content, |
134 std::vector<webkit_glue::PasswordForm>* forms); | 136 std::vector<webkit::forms::PasswordForm>* forms); |
135 | 137 |
136 // Reads and parses the Firefox password sqlite db, decrypts the | 138 // Reads and parses the Firefox password sqlite db, decrypts the |
137 // username/password and reads other related information. | 139 // username/password and reads other related information. |
138 // The result will be stored in |forms|. | 140 // The result will be stored in |forms|. |
139 bool ReadAndParseSignons(const FilePath& sqlite_file, | 141 bool ReadAndParseSignons(const FilePath& sqlite_file, |
140 std::vector<webkit_glue::PasswordForm>* forms); | 142 std::vector<webkit::forms::PasswordForm>* forms); |
141 | 143 |
142 private: | 144 private: |
143 // Call NSS initialization funcs. | 145 // Call NSS initialization funcs. |
144 bool InitNSS(const FilePath& db_path, | 146 bool InitNSS(const FilePath& db_path, |
145 base::NativeLibrary plds4_dll, | 147 base::NativeLibrary plds4_dll, |
146 base::NativeLibrary nspr4_dll); | 148 base::NativeLibrary nspr4_dll); |
147 | 149 |
148 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } | 150 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } |
149 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } | 151 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } |
150 | 152 |
(...skipping 19 matching lines...) Expand all Loading... |
170 base::NativeLibrary nss3_dll_; | 172 base::NativeLibrary nss3_dll_; |
171 base::NativeLibrary softokn3_dll_; | 173 base::NativeLibrary softokn3_dll_; |
172 | 174 |
173 // True if NSS_Init() has been called | 175 // True if NSS_Init() has been called |
174 bool is_nss_initialized_; | 176 bool is_nss_initialized_; |
175 | 177 |
176 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 178 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
177 }; | 179 }; |
178 | 180 |
179 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 181 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
OLD | NEW |