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

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

Issue 3035: Move importer files into an importer subdirectory. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/firefox2_importer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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_FIREFOX2_IMPORTER_H_
6 #define CHROME_BROWSER_FIREFOX2_IMPORTER_H_
7
8 #include "chrome/browser/importer.h"
9
10 class TemplateURL;
11
12 // Importer for Mozilla Firefox 2.
13 class Firefox2Importer : public Importer {
14 public:
15 Firefox2Importer();
16 virtual ~Firefox2Importer();
17
18 // Importer methods.
19 virtual void StartImport(ProfileInfo profile_info,
20 uint16 items,
21 ProfileWriter* writer,
22 ImporterHost* host);
23
24 // Loads the default bookmarks in the Firefox installed at |firefox_app_path|,
25 // and stores their locations in |urls|.
26 static void LoadDefaultBookmarks(const std::wstring& firefox_app_path,
27 std::set<GURL> *urls);
28
29 // Creates a TemplateURL with the |keyword| and |url|. |title| may be empty.
30 // This function transfers ownership of the created TemplateURL to the caller.
31 static TemplateURL* CreateTemplateURL(const std::wstring& title,
32 const std::wstring& keyword,
33 const GURL& url);
34
35 private:
36 FRIEND_TEST(FirefoxImporterTest, Firefox2BookmarkParse);
37 FRIEND_TEST(FirefoxImporterTest, Firefox2CookesParse);
38
39 void ImportBookmarks();
40 void ImportPasswords();
41 void ImportHistory();
42 void ImportSearchEngines();
43 // Import the user's home page, unless it is set to default home page as
44 // defined in browserconfig.properties.
45 void ImportHomepage();
46
47 // Fills |files| with the paths to the files containing the search engine
48 // descriptions.
49 void GetSearchEnginesXMLFiles(std::vector<std::wstring>* files);
50
51 // Helper methods for parsing bookmark file.
52 // Firefox 2 saves its bookmarks in a html file. We are interested in the
53 // bookmarks and folders, and their hierarchy. A folder starts with a
54 // heading tag, which contains it title. All bookmarks and sub-folders is
55 // following, and bracketed by a <DL> tag:
56 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3>
57 // <DL><p>
58 // ... container ...
59 // </DL><p>
60 // And a bookmark is presented by a <A> tag:
61 // <DT><A HREF="url" SHORTCUTURL="shortcut" ADD_DATE="11213014"...>name</A>
62 // Reference: http://kb.mozillazine.org/Bookmarks.html
63 static bool ParseCharsetFromLine(const std::string& line,
64 std::string* charset);
65 static bool ParseFolderNameFromLine(const std::string& line,
66 const std::string& charset,
67 std::wstring* folder_name,
68 bool* is_toolbar_folder);
69 // See above, this will also put the data: URL of the favicon into *favicon
70 // if there is a favicon given. |post_data| is set for POST base keywords to
71 // the contents of the actual POST (with %s for the search term).
72 static bool ParseBookmarkFromLine(const std::string& line,
73 const std::string& charset,
74 std::wstring* title,
75 GURL* url,
76 GURL* favicon,
77 std::wstring* shortcut,
78 Time* add_date,
79 std::wstring* post_data);
80
81 // Fetches the given attribute value from the |tag|. Returns true if
82 // successful, and |value| will contain the value.
83 static bool GetAttribute(const std::string& tag,
84 const std::string& attribute,
85 std::string* value);
86
87 // There are some characters in html file will be escaped:
88 // '<', '>', '"', '\', '&'
89 // Un-escapes them if the bookmark name has those characters.
90 static void HTMLUnescape(std::wstring* text);
91
92 // Fills |xml_files| with the file with an xml extension found under |dir|.
93 static void FindXMLFilesInDir(const std::wstring& dir,
94 std::vector<std::wstring>* xml_files);
95
96 // Given the URL of a page and a favicon data URL, adds an appropriate record
97 // to the given favicon usage vector. Will do nothing if the favicon is not
98 // valid.
99 static void DataURLToFaviconUsage(
100 const GURL& link_url,
101 const GURL& favicon_data,
102 std::vector<history::ImportedFavIconUsage>* favicons);
103
104 ProfileWriter* writer_;
105 std::wstring source_path_;
106 std::wstring app_path_;
107
108 DISALLOW_EVIL_CONSTRUCTORS(Firefox2Importer);
109 };
110
111 #endif // CHROME_BROWSER_FIREFOX2_IMPORTER_H_
112
OLDNEW
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/firefox2_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698