Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_ | |
| 6 #define CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/gtest_prod_util.h" | |
| 14 #include "chrome/browser/importer/importer.h" | |
| 15 #include "chrome/browser/importer/profile_writer.h" | |
|
gab
2013/05/07 17:47:54
This include is only for ProfileWriter::BookmarkEn
Avi (use Gerrit)
2013/05/07 18:29:39
We forward-declare whenever possible.
history:: i
| |
| 16 | |
| 17 class GURL; | |
| 18 | |
| 19 namespace base { | |
| 20 class FilePath; | |
| 21 } | |
| 22 | |
| 23 namespace history { | |
| 24 struct ImportedFaviconUsage; | |
| 25 } | |
| 26 | |
| 27 // Importer for bookmarks files. | |
| 28 class BookmarksFileImporter : public Importer { | |
| 29 public: | |
| 30 BookmarksFileImporter(); | |
| 31 | |
| 32 // Importer: | |
| 33 virtual void StartImport(const importer::SourceProfile& source_profile, | |
|
gab
2013/05/07 17:47:54
#include "chrome/browser/importer/importer_data_ty
| |
| 34 uint16 items, | |
| 35 ImporterBridge* bridge) OVERRIDE; | |
|
gab
2013/05/07 17:47:54
#include "chrome/browser/importer/importer_bridge.
| |
| 36 | |
| 37 // Imports the bookmarks from the specified file. |favicons| may be null, in | |
| 38 // which case favicons are not parsed. |cancellation_callback| is polled to | |
| 39 // query if the import should be cancelled; if it returns |true| at any time | |
| 40 // the import will be cancelled. If |cancellation_callback| is NULL the | |
| 41 // import will run to completion. | |
| 42 static void ImportBookmarksFile( | |
|
gab
2013/05/07 17:47:54
Seems the only reason this is static is to be used
Avi (use Gerrit)
2013/05/07 18:29:39
A future CL that makes the FF3 importer not depend
gab
2013/05/08 16:24:34
Sounds like a case for a common virtual parent cla
Avi (use Gerrit)
2013/05/08 18:30:27
That points to something that tfarina asked, where
| |
| 43 const base::FilePath& file_path, | |
| 44 base::Callback<bool(void)>* cancellation_callback, | |
| 45 std::vector<ProfileWriter::BookmarkEntry>* bookmarks, | |
| 46 std::vector<history::ImportedFaviconUsage>* favicons); | |
| 47 | |
| 48 private: | |
| 49 FRIEND_TEST_ALL_PREFIXES(BookmarksFileImporterTest, ParseTests); | |
| 50 | |
| 51 virtual ~BookmarksFileImporter(); | |
| 52 | |
| 53 // Helper methods exposed for testing. | |
| 54 | |
| 55 // The file format that BookmarksFileImporter parses starts with a heading | |
| 56 // tag, which contains its title. All bookmarks and sub-folders follow, | |
| 57 // bracketed by a <DL> tag: | |
| 58 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> | |
| 59 // <DL><p> | |
| 60 // ... container ... | |
| 61 // </DL><p> | |
| 62 // And a bookmark is presented by a <A> tag: | |
| 63 // <DT><A HREF="url" SHORTCUTURL="shortcut" ADD_DATE="11213014"...>name</A> | |
| 64 // Reference: http://kb.mozillazine.org/Bookmarks.html | |
| 65 | |
| 66 static bool ParseCharsetFromLine(const std::string& line, | |
| 67 std::string* charset); | |
|
gab
2013/05/07 17:47:54
#include <string>
for this
| |
| 68 static bool ParseFolderNameFromLine(const std::string& line, | |
| 69 const std::string& charset, | |
| 70 string16* folder_name, | |
|
tfarina
2013/05/07 16:08:15
base::string16
Avi (use Gerrit)
2013/05/07 16:46:13
Good point; will update those in the next patch.
gab
2013/05/07 17:47:54
#include "base/string16.h"
for this
| |
| 71 bool* is_toolbar_folder, | |
| 72 base::Time* add_date); | |
| 73 // See above, this will also put the data: URL of the favicon into |*favicon| | |
| 74 // if there is a favicon given. |post_data| is set for POST base keywords to | |
| 75 // the contents of the actual POST (with %s for the search term). | |
| 76 static bool ParseBookmarkFromLine(const std::string& line, | |
| 77 const std::string& charset, | |
| 78 string16* title, | |
| 79 GURL* url, | |
| 80 GURL* favicon, | |
| 81 string16* shortcut, | |
| 82 base::Time* add_date, | |
|
gab
2013/05/07 17:47:54
#include "base/time.h"
for this
| |
| 83 string16* post_data); | |
| 84 // Save bookmarks imported from browsers with Firefox 2 compatible bookmark | |
| 85 // systems such as Epiphany. This bookmark format is the same as that of the | |
| 86 // basic Firefox 2 bookmark, but it misses additional properties and uses | |
| 87 // lower-case tag: | |
| 88 // ...<h1>Bookmarks</h1><dl> | |
| 89 // <dt><a href="url">name</a></dt> | |
| 90 // <dt><a href="url">name</a></dt> | |
| 91 // </dl> | |
| 92 static bool ParseMinimumBookmarkFromLine(const std::string& line, | |
| 93 const std::string& charset, | |
| 94 string16* title, | |
| 95 GURL* url); | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(BookmarksFileImporter); | |
| 98 }; | |
| 99 | |
| 100 #endif // CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_ | |
| OLD | NEW |