OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_FIREFOX_IMPORTER_UTILS_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
6 #define CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ | 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
7 | 7 |
| 8 #include <string> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/file_path.h" | |
12 #include "base/native_library.h" | 12 #include "base/native_library.h" |
13 #include "build/build_config.h" | |
14 | |
15 class DictionaryValue; | |
16 class GURL; | |
17 class TemplateURL; | |
18 | |
19 namespace webkit_glue { | |
20 struct PasswordForm; | |
21 } | |
22 | |
23 #if defined(OS_WIN) | |
24 // Detects which version of Firefox is installed from registry. Returns its | |
25 // major version, and drops the minor version. Returns 0 if | |
26 // failed. If there are indicators of both FF2 and FF3 it is | |
27 // biased to return the biggest version. | |
28 int GetCurrentFirefoxMajorVersionFromRegistry(); | |
29 | |
30 // Detects where Firefox lives. Returns a empty string if Firefox | |
31 // is not installed. | |
32 std::wstring GetFirefoxInstallPathFromRegistry(); | |
33 #endif | |
34 | |
35 // Detects version of Firefox and installation path from given Firefox profile | |
36 bool GetFirefoxVersionAndPathFromProfile(const std::wstring& profile_path, | |
37 int* version, | |
38 std::wstring* app_path); | |
39 | |
40 // Gets the full path of the profiles.ini file. This file records | |
41 // the profiles that can be used by Firefox. Returns an empty | |
42 // string if failed. | |
43 FilePath GetProfilesINI(); | |
44 | |
45 // Parses the profile.ini file, and stores its information in |root|. | |
46 // This file is a plain-text file. Key/value pairs are stored one per | |
47 // line, and they are separeated in different sections. For example: | |
48 // [General] | |
49 // StartWithLastProfile=1 | |
50 // | |
51 // [Profile0] | |
52 // Name=default | |
53 // IsRelative=1 | |
54 // Path=Profiles/abcdefeg.default | |
55 // We set "[value]" in path "<Section>.<Key>". For example, the path | |
56 // "Genenral.StartWithLastProfile" has the value "1". | |
57 void ParseProfileINI(std::wstring file, DictionaryValue* root); | |
58 | |
59 // Returns true if we want to add the URL to the history. We filter | |
60 // out the URL with a unsupported scheme. | |
61 bool CanImportURL(const GURL& url); | |
62 | |
63 // Parses the OpenSearch XML files in |xml_files| and populates |search_engines| | |
64 // with the resulting TemplateURLs. | |
65 void ParseSearchEnginesFromXMLFiles(const std::vector<std::wstring>& xml_files, | |
66 std::vector<TemplateURL*>* search_engines); | |
67 | |
68 // Returns the index of the default search engine in the |search_engines| list. | |
69 // If none is found, -1 is returned. | |
70 int GetFirefoxDefaultSearchEngineIndex( | |
71 const std::vector<TemplateURL*>& search_engines, | |
72 const std::wstring& profile_path); | |
73 | |
74 // Returns the home page set in Firefox in a particular profile. | |
75 GURL GetHomepage(const std::wstring& profile_path); | |
76 | |
77 // Checks to see if this home page is a default home page, as specified by | |
78 // the resource file browserconfig.properties in the Firefox application | |
79 // directory. | |
80 bool IsDefaultHomepage(const GURL& homepage, const std::wstring& app_path); | |
81 | 13 |
82 // The following declarations of functions and types are from Firefox | 14 // The following declarations of functions and types are from Firefox |
83 // NSS library. | 15 // NSS library. |
84 // source code: | 16 // source code: |
85 // security/nss/lib/util/seccomon.h | 17 // security/nss/lib/util/seccomon.h |
86 // security/nss/lib/nss/nss.h | 18 // security/nss/lib/nss/nss.h |
87 // The license block is: | 19 // The license block is: |
88 | 20 |
89 /* ***** BEGIN LICENSE BLOCK ***** | 21 /* ***** BEGIN LICENSE BLOCK ***** |
90 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 22 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); | 96 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); |
165 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); | 97 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); |
166 typedef SECStatus | 98 typedef SECStatus |
167 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); | 99 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); |
168 typedef SECStatus | 100 typedef SECStatus |
169 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); | 101 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); |
170 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); | 102 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); |
171 typedef void (*PLArenaFinishFunc)(void); | 103 typedef void (*PLArenaFinishFunc)(void); |
172 typedef PRStatus (*PRCleanupFunc)(void); | 104 typedef PRStatus (*PRCleanupFunc)(void); |
173 | 105 |
| 106 namespace webkit_glue { |
| 107 struct PasswordForm; |
| 108 } |
| 109 |
174 // A wrapper for Firefox NSS decrypt component. | 110 // A wrapper for Firefox NSS decrypt component. |
175 class NSSDecryptor { | 111 class NSSDecryptor { |
176 public: | 112 public: |
177 NSSDecryptor(); | 113 NSSDecryptor(); |
178 ~NSSDecryptor(); | 114 ~NSSDecryptor(); |
179 | 115 |
180 // Loads NSS3 library and returns true if successful. | 116 // Loads NSS3 library and returns true if successful. |
181 // |dll_path| indicates the location of NSS3 DLL files, and |db_path| | 117 // |dll_path| indicates the location of NSS3 DLL files, and |db_path| |
182 // is the location of the database file that stores the keys. | 118 // is the location of the database file that stores the keys. |
183 bool Init(const std::wstring& dll_path, const std::wstring& db_path); | 119 bool Init(const std::wstring& dll_path, const std::wstring& db_path); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // NSS3 module handles. | 158 // NSS3 module handles. |
223 base::NativeLibrary nss3_dll_; | 159 base::NativeLibrary nss3_dll_; |
224 base::NativeLibrary softokn3_dll_; | 160 base::NativeLibrary softokn3_dll_; |
225 | 161 |
226 // True if NSS_Init() has been called | 162 // True if NSS_Init() has been called |
227 bool is_nss_initialized_; | 163 bool is_nss_initialized_; |
228 | 164 |
229 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 165 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
230 }; | 166 }; |
231 | 167 |
232 #endif // CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ | 168 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
OLD | NEW |