Chromium Code Reviews| Index: chrome/browser/importer/bookmarks_file_importer.h |
| diff --git a/chrome/browser/importer/bookmarks_file_importer.h b/chrome/browser/importer/bookmarks_file_importer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1750301295a276c2d43e4a3608fac9572a276de8 |
| --- /dev/null |
| +++ b/chrome/browser/importer/bookmarks_file_importer.h |
| @@ -0,0 +1,100 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_ |
| +#define CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback_forward.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/gtest_prod_util.h" |
| +#include "chrome/browser/importer/importer.h" |
| +#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
|
| + |
| +class GURL; |
| + |
| +namespace base { |
| +class FilePath; |
| +} |
| + |
| +namespace history { |
| +struct ImportedFaviconUsage; |
| +} |
| + |
| +// Importer for bookmarks files. |
| +class BookmarksFileImporter : public Importer { |
| + public: |
| + BookmarksFileImporter(); |
| + |
| + // Importer: |
| + virtual void StartImport(const importer::SourceProfile& source_profile, |
|
gab
2013/05/07 17:47:54
#include "chrome/browser/importer/importer_data_ty
|
| + uint16 items, |
| + ImporterBridge* bridge) OVERRIDE; |
|
gab
2013/05/07 17:47:54
#include "chrome/browser/importer/importer_bridge.
|
| + |
| + // Imports the bookmarks from the specified file. |favicons| may be null, in |
| + // which case favicons are not parsed. |cancellation_callback| is polled to |
| + // query if the import should be cancelled; if it returns |true| at any time |
| + // the import will be cancelled. If |cancellation_callback| is NULL the |
| + // import will run to completion. |
| + 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
|
| + const base::FilePath& file_path, |
| + base::Callback<bool(void)>* cancellation_callback, |
| + std::vector<ProfileWriter::BookmarkEntry>* bookmarks, |
| + std::vector<history::ImportedFaviconUsage>* favicons); |
| + |
| + private: |
| + FRIEND_TEST_ALL_PREFIXES(BookmarksFileImporterTest, ParseTests); |
| + |
| + virtual ~BookmarksFileImporter(); |
| + |
| + // Helper methods exposed for testing. |
| + |
| + // The file format that BookmarksFileImporter parses starts with a heading |
| + // tag, which contains its title. All bookmarks and sub-folders follow, |
| + // bracketed by a <DL> tag: |
| + // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> |
| + // <DL><p> |
| + // ... container ... |
| + // </DL><p> |
| + // And a bookmark is presented by a <A> tag: |
| + // <DT><A HREF="url" SHORTCUTURL="shortcut" ADD_DATE="11213014"...>name</A> |
| + // Reference: http://kb.mozillazine.org/Bookmarks.html |
| + |
| + static bool ParseCharsetFromLine(const std::string& line, |
| + std::string* charset); |
|
gab
2013/05/07 17:47:54
#include <string>
for this
|
| + static bool ParseFolderNameFromLine(const std::string& line, |
| + const std::string& charset, |
| + 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
|
| + bool* is_toolbar_folder, |
| + base::Time* add_date); |
| + // See above, this will also put the data: URL of the favicon into |*favicon| |
| + // if there is a favicon given. |post_data| is set for POST base keywords to |
| + // the contents of the actual POST (with %s for the search term). |
| + static bool ParseBookmarkFromLine(const std::string& line, |
| + const std::string& charset, |
| + string16* title, |
| + GURL* url, |
| + GURL* favicon, |
| + string16* shortcut, |
| + base::Time* add_date, |
|
gab
2013/05/07 17:47:54
#include "base/time.h"
for this
|
| + string16* post_data); |
| + // Save bookmarks imported from browsers with Firefox 2 compatible bookmark |
| + // systems such as Epiphany. This bookmark format is the same as that of the |
| + // basic Firefox 2 bookmark, but it misses additional properties and uses |
| + // lower-case tag: |
| + // ...<h1>Bookmarks</h1><dl> |
| + // <dt><a href="url">name</a></dt> |
| + // <dt><a href="url">name</a></dt> |
| + // </dl> |
| + static bool ParseMinimumBookmarkFromLine(const std::string& line, |
| + const std::string& charset, |
| + string16* title, |
| + GURL* url); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BookmarksFileImporter); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_ |