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 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/string16.h" | 19 #include "base/string16.h" |
20 #include "chrome/browser/importer/importer.h" | 20 #include "chrome/browser/importer/importer.h" |
21 #include "chrome/browser/importer/profile_writer.h" | 21 #include "chrome/browser/importer/profile_writer.h" |
22 #include "content/public/common/url_fetcher_delegate.h" | 22 #include "net/url_request/url_fetcher_delegate.h" |
23 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
24 | 24 |
25 class ImporterBridge; | 25 class ImporterBridge; |
26 class XmlReader; | 26 class XmlReader; |
27 | 27 |
| 28 namespace net { |
| 29 class URLFetcher; |
| 30 } // namespace net |
| 31 |
28 // Toolbar5Importer is a class which exposes the functionality needed to | 32 // Toolbar5Importer is a class which exposes the functionality needed to |
29 // communicate with the Google Toolbar v5 front-end, negotiate the download of | 33 // communicate with the Google Toolbar v5 front-end, negotiate the download of |
30 // Toolbar bookmarks, parse them, and install them on the client. | 34 // Toolbar bookmarks, parse them, and install them on the client. |
31 // Toolbar5Importer should not have StartImport called more than once. Futher | 35 // Toolbar5Importer should not have StartImport called more than once. Futher |
32 // if StartImport is called, then the class must not be destroyed until it has | 36 // if StartImport is called, then the class must not be destroyed until it has |
33 // either completed or Toolbar5Importer->Cancel() has been called. | 37 // either completed or Toolbar5Importer->Cancel() has been called. |
34 class Toolbar5Importer : public content::URLFetcherDelegate, public Importer { | 38 class Toolbar5Importer : public net::URLFetcherDelegate, public Importer { |
35 public: | 39 public: |
36 Toolbar5Importer(); | 40 Toolbar5Importer(); |
37 | 41 |
38 // Importer: | 42 // Importer: |
39 // The importer view calls this method to begin the process. |items| should | 43 // The importer view calls this method to begin the process. |items| should |
40 // only either be NONE or FAVORITES, since as of right now these are the only | 44 // only either be NONE or FAVORITES, since as of right now these are the only |
41 // items this importer supports. | 45 // items this importer supports. |
42 virtual void StartImport(const importer::SourceProfile& source_profile, | 46 virtual void StartImport(const importer::SourceProfile& source_profile, |
43 uint16 items, | 47 uint16 items, |
44 ImporterBridge* bridge) OVERRIDE; | 48 ImporterBridge* bridge) OVERRIDE; |
45 | 49 |
46 // Importer view call this method when the user clicks the cancel button | 50 // Importer view call this method when the user clicks the cancel button |
47 // in the tabbed options UI. We need to post a message to our loop | 51 // in the tabbed options UI. We need to post a message to our loop |
48 // to cancel network retrieval. | 52 // to cancel network retrieval. |
49 virtual void Cancel() OVERRIDE; | 53 virtual void Cancel() OVERRIDE; |
50 | 54 |
51 // content::URLFetcherDelegate method called back from the URLFetcher object. | 55 // net::URLFetcherDelegate method called back from the URLFetcher object. |
52 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 56 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
53 | 57 |
54 private: | 58 private: |
55 FRIEND_TEST_ALL_PREFIXES(Toolbar5ImporterTest, BookmarkParse); | 59 FRIEND_TEST_ALL_PREFIXES(Toolbar5ImporterTest, BookmarkParse); |
56 | 60 |
57 virtual ~Toolbar5Importer(); | 61 virtual ~Toolbar5Importer(); |
58 | 62 |
59 // Internal states of the toolbar importer. | 63 // Internal states of the toolbar importer. |
60 enum InternalStateEnum { | 64 enum InternalStateEnum { |
61 NOT_USED = -1, | 65 NOT_USED = -1, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void AddBookmarksToChrome( | 152 void AddBookmarksToChrome( |
149 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks); | 153 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks); |
150 | 154 |
151 InternalStateEnum state_; | 155 InternalStateEnum state_; |
152 | 156 |
153 // Bitmask of Importer::ImportItem. | 157 // Bitmask of Importer::ImportItem. |
154 uint16 items_to_import_; | 158 uint16 items_to_import_; |
155 | 159 |
156 // The fetchers need to be available to cancel the network call on user cancel | 160 // The fetchers need to be available to cancel the network call on user cancel |
157 // hence they are stored as member variables. | 161 // hence they are stored as member variables. |
158 content::URLFetcher* token_fetcher_; | 162 net::URLFetcher* token_fetcher_; |
159 content::URLFetcher* data_fetcher_; | 163 net::URLFetcher* data_fetcher_; |
160 | 164 |
161 // Used to get correct login data for the toolbar server. | 165 // Used to get correct login data for the toolbar server. |
162 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 166 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
163 | 167 |
164 DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); | 168 DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); |
165 }; | 169 }; |
166 | 170 |
167 #endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ | 171 #endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ |
OLD | NEW |