Chromium Code Reviews

Side by Side Diff: chrome/utility/importer/firefox_importer_unittest_utils.h

Issue 306123004: NSSDecryptor::ReadAndParseSignons() - improved password form scheme detection, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unittest added Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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_UTILITY_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ 5 #ifndef CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_
6 #define CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ 6 #define CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
11 #include "chrome/utility/importer/nss_decryptor.h" 11 #include "chrome/utility/importer/nss_decryptor.h"
12 #include "components/autofill/core/common/password_form.h"
12 13
13 class FFDecryptorServerChannelListener; 14 class FFDecryptorServerChannelListener;
14 15
15 namespace base { 16 namespace base {
16 class MessageLoopForIO; 17 class MessageLoopForIO;
17 } 18 }
18 19
19 namespace IPC { 20 namespace IPC {
20 class Channel; 21 class Channel;
21 } // namespace IPC 22 } // namespace IPC
22 23
24 typedef std::vector<autofill::PasswordForm> PasswordFormVector;
vabr (Chromium) 2014/06/05 16:36:20 Please don't pollute the global namespace with thi
25
23 // On OS X NSSDecryptor needs to run in a separate process. To allow us to use 26 // On OS X NSSDecryptor needs to run in a separate process. To allow us to use
24 // the same unit test on all platforms we use a proxy class which spawns a 27 // the same unit test on all platforms we use a proxy class which spawns a
25 // child process to do decryption on OS X, and calls through directly 28 // child process to do decryption on OS X, and calls through directly
26 // to NSSDecryptor on other platforms. 29 // to NSSDecryptor on other platforms.
27 // On OS X: 30 // On OS X:
28 // 2 IPC messages are sent for every method of NSSDecryptor, one containing the 31 // 2 IPC messages are sent for every method of NSSDecryptor, one containing the
29 // input arguments sent from Server->Child and one coming back containing 32 // input arguments sent from Server->Child and one coming back containing
30 // the return argument e.g. 33 // the return argument e.g.
31 // 34 //
32 // -> Msg_Decryptor_Init(dll_path, db_path) 35 // -> Msg_Decryptor_Init(dll_path, db_path)
33 // <- Msg_Decryptor_InitReturnCode(bool) 36 // <- Msg_Decryptor_InitReturnCode(bool)
34 class FFUnitTestDecryptorProxy { 37 class FFUnitTestDecryptorProxy {
35 public: 38 public:
36 FFUnitTestDecryptorProxy(); 39 FFUnitTestDecryptorProxy();
37 virtual ~FFUnitTestDecryptorProxy(); 40 virtual ~FFUnitTestDecryptorProxy();
38 41
39 // Initialize a decryptor, returns true if the object was 42 // Initialize a decryptor, returns true if the object was
40 // constructed successfully. 43 // constructed successfully.
41 bool Setup(const base::FilePath& nss_path); 44 bool Setup(const base::FilePath& nss_path);
42 45
43 // This match the parallel functions in NSSDecryptor. 46 // This match the parallel functions in NSSDecryptor.
44 bool DecryptorInit(const base::FilePath& dll_path, 47 bool DecryptorInit(const base::FilePath& dll_path,
45 const base::FilePath& db_path); 48 const base::FilePath& db_path);
46 base::string16 Decrypt(const std::string& crypt); 49 base::string16 Decrypt(const std::string& crypt);
50 PasswordFormVector ParseSignons(const base::FilePath& signons_path);
47 51
48 private: 52 private:
49 #if defined(OS_MACOSX) 53 #if defined(OS_MACOSX)
50 // Blocks until either a timeout is reached, or until the client process 54 // Blocks until either a timeout is reached, or until the client process
51 // responds to an IPC message. 55 // responds to an IPC message.
52 // Returns true if a reply was received successfully and false if the 56 // Returns true if a reply was received successfully and false if the
53 // the operation timed out. 57 // the operation timed out.
54 bool WaitForClientResponse(); 58 bool WaitForClientResponse();
55 59
56 base::ProcessHandle child_process_; 60 base::ProcessHandle child_process_;
(...skipping 20 matching lines...)
77 } 81 }
78 82
79 bool FFUnitTestDecryptorProxy::DecryptorInit(const base::FilePath& dll_path, 83 bool FFUnitTestDecryptorProxy::DecryptorInit(const base::FilePath& dll_path,
80 const base::FilePath& db_path) { 84 const base::FilePath& db_path) {
81 return decryptor_.Init(dll_path, db_path); 85 return decryptor_.Init(dll_path, db_path);
82 } 86 }
83 87
84 base::string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) { 88 base::string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) {
85 return decryptor_.Decrypt(crypt); 89 return decryptor_.Decrypt(crypt);
86 } 90 }
91
92 PasswordFormVector FFUnitTestDecryptorProxy::ParseSignons(
93 const base::FilePath& signons_path) {
94 return decryptor_.ParseSignons(signons_path);
95 }
96
87 #endif // !OS_MACOSX 97 #endif // !OS_MACOSX
88 98
89 #endif // CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ 99 #endif // CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_
OLDNEW

Powered by Google App Engine