| 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 #ifndef CHROME_UTILITY_IMPORTER_SAFARI_IMPORTER_H_ | 5 #ifndef CHROME_UTILITY_IMPORTER_SAFARI_IMPORTER_H_ |
| 6 #define CHROME_UTILITY_IMPORTER_SAFARI_IMPORTER_H_ | 6 #define CHROME_UTILITY_IMPORTER_SAFARI_IMPORTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 #include <set> | 11 #include <set> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/macros.h" |
| 16 #include "chrome/common/importer/importer_url_row.h" | 18 #include "chrome/common/importer/importer_url_row.h" |
| 17 #include "chrome/utility/importer/importer.h" | 19 #include "chrome/utility/importer/importer.h" |
| 18 #include "components/favicon_base/favicon_usage_data.h" | 20 #include "components/favicon_base/favicon_usage_data.h" |
| 19 | 21 |
| 20 #if __OBJC__ | 22 #if __OBJC__ |
| 21 @class NSDictionary; | 23 @class NSDictionary; |
| 22 @class NSString; | 24 @class NSString; |
| 23 #else | 25 #else |
| 24 class NSDictionary; | 26 class NSDictionary; |
| 25 class NSString; | 27 class NSString; |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 28 class GURL; | 30 class GURL; |
| 29 struct ImportedBookmarkEntry; | 31 struct ImportedBookmarkEntry; |
| 30 | 32 |
| 31 namespace sql { | 33 namespace sql { |
| 32 class Connection; | 34 class Connection; |
| 33 } | 35 } |
| 34 | 36 |
| 35 // Importer for Safari on OS X. | 37 // Importer for Safari on OS X. |
| 36 class SafariImporter : public Importer { | 38 class SafariImporter : public Importer { |
| 37 public: | 39 public: |
| 38 // |library_dir| is the full path to the ~/Library directory, | 40 // |library_dir| is the full path to the ~/Library directory, |
| 39 // We pass it in as a parameter for testing purposes. | 41 // We pass it in as a parameter for testing purposes. |
| 40 explicit SafariImporter(const base::FilePath& library_dir); | 42 explicit SafariImporter(const base::FilePath& library_dir); |
| 41 | 43 |
| 42 // Importer: | 44 // Importer: |
| 43 void StartImport(const importer::SourceProfile& source_profile, | 45 void StartImport(const importer::SourceProfile& source_profile, |
| 44 uint16 items, | 46 uint16_t items, |
| 45 ImporterBridge* bridge) override; | 47 ImporterBridge* bridge) override; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, BookmarkImport); | 50 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, BookmarkImport); |
| 49 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, | 51 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, |
| 50 BookmarkImportWithEmptyBookmarksMenu); | 52 BookmarkImportWithEmptyBookmarksMenu); |
| 51 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, FaviconImport); | 53 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, FaviconImport); |
| 52 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, HistoryImport); | 54 FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, HistoryImport); |
| 53 | 55 |
| 54 ~SafariImporter() override; | 56 ~SafariImporter() override; |
| 55 | 57 |
| 56 // Multiple URLs can share the same favicon; this is a map | 58 // Multiple URLs can share the same favicon; this is a map |
| 57 // of URLs -> IconIDs that we load as a temporary step before | 59 // of URLs -> IconIDs that we load as a temporary step before |
| 58 // actually loading the icons. | 60 // actually loading the icons. |
| 59 typedef std::map<int64, std::set<GURL> > FaviconMap; | 61 typedef std::map<int64_t, std::set<GURL>> FaviconMap; |
| 60 | 62 |
| 61 void ImportBookmarks(); | 63 void ImportBookmarks(); |
| 62 void ImportPasswords(); | 64 void ImportPasswords(); |
| 63 void ImportHistory(); | 65 void ImportHistory(); |
| 64 | 66 |
| 65 // Parse Safari's stored bookmarks. | 67 // Parse Safari's stored bookmarks. |
| 66 void ParseBookmarks(const base::string16& toolbar_name, | 68 void ParseBookmarks(const base::string16& toolbar_name, |
| 67 std::vector<ImportedBookmarkEntry>* bookmarks); | 69 std::vector<ImportedBookmarkEntry>* bookmarks); |
| 68 | 70 |
| 69 // Function to recursively read Bookmarks out of Safari plist. | 71 // Function to recursively read Bookmarks out of Safari plist. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 95 void LoadFaviconData(sql::Connection* db, | 97 void LoadFaviconData(sql::Connection* db, |
| 96 const FaviconMap& favicon_map, | 98 const FaviconMap& favicon_map, |
| 97 favicon_base::FaviconUsageDataList* favicons); | 99 favicon_base::FaviconUsageDataList* favicons); |
| 98 | 100 |
| 99 base::FilePath library_dir_; | 101 base::FilePath library_dir_; |
| 100 | 102 |
| 101 DISALLOW_COPY_AND_ASSIGN(SafariImporter); | 103 DISALLOW_COPY_AND_ASSIGN(SafariImporter); |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 #endif // CHROME_UTILITY_IMPORTER_SAFARI_IMPORTER_H_ | 106 #endif // CHROME_UTILITY_IMPORTER_SAFARI_IMPORTER_H_ |
| OLD | NEW |