OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/importer/firefox3_importer.h" | 5 #include "chrome/utility/importer/firefox3_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.h" | 12 #include "base/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/browser/browser_process.h" | 16 #include "chrome/common/importer/firefox_importer_utils.h" |
17 #include "chrome/browser/importer/bookmark_html_reader.h" | 17 #include "chrome/common/importer/firefox_importer_utils.h" |
18 #include "chrome/browser/importer/firefox_importer_utils.h" | |
19 #include "chrome/browser/importer/importer_bridge.h" | |
20 #include "chrome/browser/importer/nss_decryptor.h" | |
21 #include "chrome/browser/importer/reencode_favicon.h" | |
22 #include "chrome/common/importer/imported_bookmark_entry.h" | 18 #include "chrome/common/importer/imported_bookmark_entry.h" |
23 #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" |
24 #include "chrome/common/importer/importer_url_row.h" | 21 #include "chrome/common/importer/importer_url_row.h" |
25 #include "chrome/common/time_format.h" | 22 #include "chrome/common/time_format.h" |
26 #include "content/public/browser/browser_thread.h" | 23 #include "chrome/utility/importer/bookmark_html_reader.h" |
| 24 #include "chrome/utility/importer/favicon_reencode.h" |
| 25 #include "chrome/utility/importer/nss_decryptor.h" |
27 #include "content/public/common/password_form.h" | 26 #include "content/public/common/password_form.h" |
28 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
29 #include "sql/connection.h" | 28 #include "sql/connection.h" |
30 #include "sql/statement.h" | 29 #include "sql/statement.h" |
31 #include "url/gurl.h" | 30 #include "url/gurl.h" |
32 | 31 |
33 using content::BrowserThread; | |
34 | |
35 namespace { | 32 namespace { |
36 | 33 |
37 // Original definition is in http://mxr.mozilla.org/firefox/source/toolkit/ | 34 // Original definition is in http://mxr.mozilla.org/firefox/source/toolkit/ |
38 // components/places/public/nsINavBookmarksService.idl | 35 // components/places/public/nsINavBookmarksService.idl |
39 enum BookmarkItemType { | 36 enum BookmarkItemType { |
40 TYPE_BOOKMARK = 1, | 37 TYPE_BOOKMARK = 1, |
41 TYPE_FOLDER = 2, | 38 TYPE_FOLDER = 2, |
42 TYPE_SEPARATOR = 3, | 39 TYPE_SEPARATOR = 3, |
43 TYPE_DYNAMIC_CONTAINER = 4 | 40 TYPE_DYNAMIC_CONTAINER = 4 |
44 }; | 41 }; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 570 |
574 usage.favicon_url = GURL(s.ColumnString(0)); | 571 usage.favicon_url = GURL(s.ColumnString(0)); |
575 if (!usage.favicon_url.is_valid()) | 572 if (!usage.favicon_url.is_valid()) |
576 continue; // Don't bother importing favicons with invalid URLs. | 573 continue; // Don't bother importing favicons with invalid URLs. |
577 | 574 |
578 std::vector<unsigned char> data; | 575 std::vector<unsigned char> data; |
579 s.ColumnBlobAsVector(1, &data); | 576 s.ColumnBlobAsVector(1, &data); |
580 if (data.empty()) | 577 if (data.empty()) |
581 continue; // Data definitely invalid. | 578 continue; // Data definitely invalid. |
582 | 579 |
583 if (!ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 580 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
584 continue; // Unable to decode. | 581 continue; // Unable to decode. |
585 | 582 |
586 usage.urls = i->second; | 583 usage.urls = i->second; |
587 favicons->push_back(usage); | 584 favicons->push_back(usage); |
588 } | 585 } |
589 s.Reset(true); | 586 s.Reset(true); |
590 } | 587 } |
591 } | 588 } |
OLD | NEW |