| 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 // The functionality provided here allows the user to import their bookmarks | 5 // The functionality provided here allows the user to import their bookmarks |
| 6 // (favorites) from Google Toolbar. | 6 // (favorites) from Google Toolbar. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ | 8 #ifndef CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ |
| 9 #define CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ | 9 #define CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "chrome/browser/importer/importer.h" | 19 #include "chrome/browser/importer/importer.h" |
| 20 #include "chrome/browser/importer/profile_writer.h" | |
| 21 #include "net/url_request/url_fetcher_delegate.h" | 20 #include "net/url_request/url_fetcher_delegate.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 23 | 22 |
| 23 struct ImportedBookmarkEntry; |
| 24 class ImporterBridge; | 24 class ImporterBridge; |
| 25 class XmlReader; | 25 class XmlReader; |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 class URLFetcher; | 28 class URLFetcher; |
| 29 } // namespace net | 29 } // namespace net |
| 30 | 30 |
| 31 // Toolbar5Importer is a class which exposes the functionality needed to | 31 // Toolbar5Importer is a class which exposes the functionality needed to |
| 32 // communicate with the Google Toolbar v5 front-end, negotiate the download of | 32 // communicate with the Google Toolbar v5 front-end, negotiate the download of |
| 33 // Toolbar bookmarks, parse them, and install them on the client. | 33 // Toolbar bookmarks, parse them, and install them on the client. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void GetAuthenticationFromServer(); | 111 void GetAuthenticationFromServer(); |
| 112 void GetBookmarkDataFromServer(const std::string& response); | 112 void GetBookmarkDataFromServer(const std::string& response); |
| 113 void GetBookmarksFromServerDataResponse(const std::string& response); | 113 void GetBookmarksFromServerDataResponse(const std::string& response); |
| 114 | 114 |
| 115 // XML Parsing is implemented with the methods below. | 115 // XML Parsing is implemented with the methods below. |
| 116 bool ParseAuthenticationTokenResponse(const std::string& response, | 116 bool ParseAuthenticationTokenResponse(const std::string& response, |
| 117 std::string* token); | 117 std::string* token); |
| 118 | 118 |
| 119 static bool ParseBookmarksFromReader( | 119 static bool ParseBookmarksFromReader( |
| 120 XmlReader* reader, | 120 XmlReader* reader, |
| 121 std::vector<ProfileWriter::BookmarkEntry>* bookmarks, | 121 std::vector<ImportedBookmarkEntry>* bookmarks, |
| 122 const string16& bookmark_group_string); | 122 const string16& bookmark_group_string); |
| 123 | 123 |
| 124 static bool LocateNextOpenTag(XmlReader* reader); | 124 static bool LocateNextOpenTag(XmlReader* reader); |
| 125 static bool LocateNextTagByName(XmlReader* reader, const std::string& tag); | 125 static bool LocateNextTagByName(XmlReader* reader, const std::string& tag); |
| 126 static bool LocateNextTagWithStopByName( | 126 static bool LocateNextTagWithStopByName( |
| 127 XmlReader* reader, | 127 XmlReader* reader, |
| 128 const std::string& tag, | 128 const std::string& tag, |
| 129 const std::string& stop); | 129 const std::string& stop); |
| 130 | 130 |
| 131 static bool ExtractBookmarkInformation( | 131 static bool ExtractBookmarkInformation( |
| 132 XmlReader* reader, | 132 XmlReader* reader, |
| 133 ProfileWriter::BookmarkEntry* bookmark_entry, | 133 ImportedBookmarkEntry* bookmark_entry, |
| 134 std::vector<BookmarkFolderType>* bookmark_folders, | 134 std::vector<BookmarkFolderType>* bookmark_folders, |
| 135 const string16& bookmark_group_string); | 135 const string16& bookmark_group_string); |
| 136 static bool ExtractNamedValueFromXmlReader(XmlReader* reader, | 136 static bool ExtractNamedValueFromXmlReader(XmlReader* reader, |
| 137 const std::string& name, | 137 const std::string& name, |
| 138 std::string* buffer); | 138 std::string* buffer); |
| 139 static bool ExtractTitleFromXmlReader(XmlReader* reader, | 139 static bool ExtractTitleFromXmlReader(XmlReader* reader, |
| 140 ProfileWriter::BookmarkEntry* entry); | 140 ImportedBookmarkEntry* entry); |
| 141 static bool ExtractUrlFromXmlReader(XmlReader* reader, | 141 static bool ExtractUrlFromXmlReader(XmlReader* reader, |
| 142 ProfileWriter::BookmarkEntry* entry); | 142 ImportedBookmarkEntry* entry); |
| 143 static bool ExtractTimeFromXmlReader(XmlReader* reader, | 143 static bool ExtractTimeFromXmlReader(XmlReader* reader, |
| 144 ProfileWriter::BookmarkEntry* entry); | 144 ImportedBookmarkEntry* entry); |
| 145 static bool ExtractFoldersFromXmlReader( | 145 static bool ExtractFoldersFromXmlReader( |
| 146 XmlReader* reader, | 146 XmlReader* reader, |
| 147 std::vector<BookmarkFolderType>* bookmark_folders, | 147 std::vector<BookmarkFolderType>* bookmark_folders, |
| 148 const string16& bookmark_group_string); | 148 const string16& bookmark_group_string); |
| 149 | 149 |
| 150 // Bookmark creation is done by the method below. | 150 // Bookmark creation is done by the method below. |
| 151 void AddBookmarksToChrome( | 151 void AddBookmarksToChrome( |
| 152 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks); | 152 const std::vector<ImportedBookmarkEntry>& bookmarks); |
| 153 | 153 |
| 154 InternalStateEnum state_; | 154 InternalStateEnum state_; |
| 155 | 155 |
| 156 // Bitmask of Importer::ImportItem. | 156 // Bitmask of Importer::ImportItem. |
| 157 uint16 items_to_import_; | 157 uint16 items_to_import_; |
| 158 | 158 |
| 159 // The fetchers need to be available to cancel the network call on user cancel | 159 // The fetchers need to be available to cancel the network call on user cancel |
| 160 // hence they are stored as member variables. | 160 // hence they are stored as member variables. |
| 161 net::URLFetcher* token_fetcher_; | 161 net::URLFetcher* token_fetcher_; |
| 162 net::URLFetcher* data_fetcher_; | 162 net::URLFetcher* data_fetcher_; |
| 163 | 163 |
| 164 // Used to get correct login data for the toolbar server. | 164 // Used to get correct login data for the toolbar server. |
| 165 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 165 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); | 167 DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 #endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ | 170 #endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ |
| OLD | NEW |