OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/utility/importer/firefox_importer.h" | 5 #include "chrome/utility/importer/firefox_importer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/common/importer/firefox_importer_utils.h" | 16 #include "chrome/common/importer/firefox_importer_utils.h" |
17 #include "chrome/common/importer/firefox_importer_utils.h" | 17 #include "chrome/common/importer/firefox_importer_utils.h" |
18 #include "chrome/common/importer/imported_bookmark_entry.h" | 18 #include "chrome/common/importer/imported_bookmark_entry.h" |
19 #include "chrome/common/importer/imported_favicon_usage.h" | 19 #include "chrome/common/importer/imported_favicon_usage.h" |
20 #include "chrome/common/importer/importer_bridge.h" | 20 #include "chrome/common/importer/importer_bridge.h" |
21 #include "chrome/common/importer/importer_url_row.h" | 21 #include "chrome/common/importer/importer_url_row.h" |
22 #include "chrome/utility/importer/bookmark_html_reader.h" | 22 #include "chrome/utility/importer/bookmark_html_reader.h" |
23 #include "chrome/utility/importer/favicon_reencode.h" | 23 #include "chrome/utility/importer/favicon_reencode.h" |
24 #include "chrome/utility/importer/nss_decryptor.h" | 24 #include "chrome/utility/importer/nss_decryptor.h" |
25 #include "content/public/common/password_form.h" | 25 #include "components/autofill/core/common/password_form.h" |
26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
27 #include "sql/connection.h" | 27 #include "sql/connection.h" |
28 #include "sql/statement.h" | 28 #include "sql/statement.h" |
29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Original definition is in http://mxr.mozilla.org/firefox/source/toolkit/ | 33 // Original definition is in http://mxr.mozilla.org/firefox/source/toolkit/ |
34 // components/places/public/nsINavBookmarksService.idl | 34 // components/places/public/nsINavBookmarksService.idl |
35 enum BookmarkItemType { | 35 enum BookmarkItemType { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 336 } |
337 | 337 |
338 void FirefoxImporter::ImportPasswords() { | 338 void FirefoxImporter::ImportPasswords() { |
339 // Initializes NSS3. | 339 // Initializes NSS3. |
340 NSSDecryptor decryptor; | 340 NSSDecryptor decryptor; |
341 if (!decryptor.Init(source_path_, source_path_) && | 341 if (!decryptor.Init(source_path_, source_path_) && |
342 !decryptor.Init(app_path_, source_path_)) { | 342 !decryptor.Init(app_path_, source_path_)) { |
343 return; | 343 return; |
344 } | 344 } |
345 | 345 |
346 std::vector<content::PasswordForm> forms; | 346 std::vector<autofill::PasswordForm> forms; |
347 base::FilePath source_path = source_path_; | 347 base::FilePath source_path = source_path_; |
348 base::FilePath file = source_path.AppendASCII("signons.sqlite"); | 348 base::FilePath file = source_path.AppendASCII("signons.sqlite"); |
349 if (base::PathExists(file)) { | 349 if (base::PathExists(file)) { |
350 // Since Firefox 3.1, passwords are in signons.sqlite db. | 350 // Since Firefox 3.1, passwords are in signons.sqlite db. |
351 decryptor.ReadAndParseSignons(file, &forms); | 351 decryptor.ReadAndParseSignons(file, &forms); |
352 } else { | 352 } else { |
353 // Firefox 3.0 uses signons3.txt to store the passwords. | 353 // Firefox 3.0 uses signons3.txt to store the passwords. |
354 file = source_path.AppendASCII("signons3.txt"); | 354 file = source_path.AppendASCII("signons3.txt"); |
355 if (!base::PathExists(file)) | 355 if (!base::PathExists(file)) |
356 file = source_path.AppendASCII("signons2.txt"); | 356 file = source_path.AppendASCII("signons2.txt"); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 595 |
596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
597 continue; // Unable to decode. | 597 continue; // Unable to decode. |
598 | 598 |
599 usage.urls = i->second; | 599 usage.urls = i->second; |
600 favicons->push_back(usage); | 600 favicons->push_back(usage); |
601 } | 601 } |
602 s.Reset(true); | 602 s.Reset(true); |
603 } | 603 } |
604 } | 604 } |
OLD | NEW |