Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: chrome/browser/importer/firefox2_importer.h

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test cleanup Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BROWSER_IMPORTER_FIREFOX2_IMPORTER_H_ 5 #ifndef CHROME_BROWSER_IMPORTER_FIREFOX2_IMPORTER_H_
6 #define CHROME_BROWSER_IMPORTER_FIREFOX2_IMPORTER_H_ 6 #define CHROME_BROWSER_IMPORTER_FIREFOX2_IMPORTER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "chrome/browser/importer/importer.h" 15 #include "chrome/browser/importer/importer.h"
16 #include "chrome/browser/importer/profile_writer.h"
17 16
18 class GURL; 17 class GURL;
18 struct ImportedBookmarkEntry;
19 struct ImportedFaviconUsage;
19 class TemplateURL; 20 class TemplateURL;
20 21
22 namespace base {
23 class Time;
24 }
25
21 // Importer for Mozilla Firefox 2. 26 // Importer for Mozilla Firefox 2.
22 class Firefox2Importer : public Importer { 27 class Firefox2Importer : public Importer {
23 public: 28 public:
24 Firefox2Importer(); 29 Firefox2Importer();
25 30
26 // Importer: 31 // Importer:
27 virtual void StartImport(const importer::SourceProfile& source_profile, 32 virtual void StartImport(const importer::SourceProfile& source_profile,
28 uint16 items, 33 uint16 items,
29 ImporterBridge* bridge) OVERRIDE; 34 ImporterBridge* bridge) OVERRIDE;
30 35
31 // Loads the default bookmarks in the Firefox installed at |firefox_app_path|, 36 // Loads the default bookmarks in the Firefox installed at |firefox_app_path|,
32 // and stores their locations in |urls|. 37 // and stores their locations in |urls|.
33 static void LoadDefaultBookmarks(const base::FilePath& firefox_app_path, 38 static void LoadDefaultBookmarks(const base::FilePath& firefox_app_path,
34 std::set<GURL>* urls); 39 std::set<GURL>* urls);
35 40
36 // Creates a TemplateURL with the |keyword| and |url|. |title| may be empty. 41 // Creates a TemplateURL with the |keyword| and |url|. |title| may be empty.
37 // This function transfers ownership of the created TemplateURL to the caller. 42 // This function transfers ownership of the created TemplateURL to the caller.
38 static TemplateURL* CreateTemplateURL(const string16& title, 43 static TemplateURL* CreateTemplateURL(const string16& title,
39 const string16& keyword, 44 const string16& keyword,
40 const GURL& url); 45 const GURL& url);
41 46
42 // Imports the bookmarks from the specified file. |template_urls| and 47 // Imports the bookmarks from the specified file. |template_urls| and
43 // |favicons| may be null, in which case TemplateURLs and favicons are 48 // |favicons| may be null, in which case TemplateURLs and favicons are
44 // not parsed. Any bookmarks in |default_urls| are ignored. 49 // not parsed. Any bookmarks in |default_urls| are ignored.
45 static void ImportBookmarksFile( 50 static void ImportBookmarksFile(
46 const base::FilePath& file_path, 51 const base::FilePath& file_path,
47 const std::set<GURL>& default_urls, 52 const std::set<GURL>& default_urls,
48 Importer* importer, 53 Importer* importer,
49 std::vector<ProfileWriter::BookmarkEntry>* bookmarks, 54 std::vector<ImportedBookmarkEntry>* bookmarks,
50 std::vector<TemplateURL*>* template_urls, 55 std::vector<TemplateURL*>* template_urls,
51 std::vector<history::ImportedFaviconUsage>* favicons); 56 std::vector<ImportedFaviconUsage>* favicons);
52 57
53 private: 58 private:
54 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, Firefox2BookmarkParse); 59 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, Firefox2BookmarkParse);
55 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, Firefox2CookesParse); 60 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, Firefox2CookesParse);
56 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, Firefox2BookmarkFileImport); 61 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, Firefox2BookmarkFileImport);
57 62
58 virtual ~Firefox2Importer(); 63 virtual ~Firefox2Importer();
59 64
60 void ImportBookmarks(); 65 void ImportBookmarks();
61 void ImportPasswords(); 66 void ImportPasswords();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Fills |xml_files| with the file with an xml extension found under |dir|. 131 // Fills |xml_files| with the file with an xml extension found under |dir|.
127 static void FindXMLFilesInDir(const base::FilePath& dir, 132 static void FindXMLFilesInDir(const base::FilePath& dir,
128 std::vector<base::FilePath>* xml_files); 133 std::vector<base::FilePath>* xml_files);
129 134
130 // Given the URL of a page and a favicon data URL, adds an appropriate record 135 // Given the URL of a page and a favicon data URL, adds an appropriate record
131 // to the given favicon usage vector. Will do nothing if the favicon is not 136 // to the given favicon usage vector. Will do nothing if the favicon is not
132 // valid. 137 // valid.
133 static void DataURLToFaviconUsage( 138 static void DataURLToFaviconUsage(
134 const GURL& link_url, 139 const GURL& link_url,
135 const GURL& favicon_data, 140 const GURL& favicon_data,
136 std::vector<history::ImportedFaviconUsage>* favicons); 141 std::vector<ImportedFaviconUsage>* favicons);
137 142
138 base::FilePath source_path_; 143 base::FilePath source_path_;
139 base::FilePath app_path_; 144 base::FilePath app_path_;
140 // If true, we only parse the bookmarks.html file specified as source_path_. 145 // If true, we only parse the bookmarks.html file specified as source_path_.
141 bool parsing_bookmarks_html_file_; 146 bool parsing_bookmarks_html_file_;
142 147
143 DISALLOW_COPY_AND_ASSIGN(Firefox2Importer); 148 DISALLOW_COPY_AND_ASSIGN(Firefox2Importer);
144 }; 149 };
145 150
146 #endif // CHROME_BROWSER_IMPORTER_FIREFOX2_IMPORTER_H_ 151 #endif // CHROME_BROWSER_IMPORTER_FIREFOX2_IMPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698