| OLD | NEW |
| 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 // 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/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" | 20 #include "chrome/browser/importer/profile_writer.h" |
| 21 #include "content/common/net/url_fetcher.h" | 21 #include "content/public/common/url_fetcher_delegate.h" |
| 22 | 22 |
| 23 class ImporterBridge; | 23 class ImporterBridge; |
| 24 class XmlReader; | 24 class XmlReader; |
| 25 | 25 |
| 26 // Toolbar5Importer is a class which exposes the functionality needed to | 26 // Toolbar5Importer is a class which exposes the functionality needed to |
| 27 // communicate with the Google Toolbar v5 front-end, negotiate the download of | 27 // communicate with the Google Toolbar v5 front-end, negotiate the download of |
| 28 // Toolbar bookmarks, parse them, and install them on the client. | 28 // Toolbar bookmarks, parse them, and install them on the client. |
| 29 // Toolbar5Importer should not have StartImport called more than once. Futher | 29 // Toolbar5Importer should not have StartImport called more than once. Futher |
| 30 // if StartImport is called, then the class must not be destroyed until it has | 30 // if StartImport is called, then the class must not be destroyed until it has |
| 31 // either completed or Toolbar5Importer->Cancel() has been called. | 31 // either completed or Toolbar5Importer->Cancel() has been called. |
| 32 class Toolbar5Importer : public URLFetcher::Delegate, public Importer { | 32 class Toolbar5Importer : public content::URLFetcherDelegate, public Importer { |
| 33 public: | 33 public: |
| 34 Toolbar5Importer(); | 34 Toolbar5Importer(); |
| 35 | 35 |
| 36 // Importer: | 36 // Importer: |
| 37 // The importer view calls this method to begin the process. |items| should | 37 // The importer view calls this method to begin the process. |items| should |
| 38 // only either be NONE or FAVORITES, since as of right now these are the only | 38 // only either be NONE or FAVORITES, since as of right now these are the only |
| 39 // items this importer supports. | 39 // items this importer supports. |
| 40 virtual void StartImport(const importer::SourceProfile& source_profile, | 40 virtual void StartImport(const importer::SourceProfile& source_profile, |
| 41 uint16 items, | 41 uint16 items, |
| 42 ImporterBridge* bridge) OVERRIDE; | 42 ImporterBridge* bridge) OVERRIDE; |
| 43 | 43 |
| 44 // Importer view call this method when the user clicks the cancel button | 44 // Importer view call this method when the user clicks the cancel button |
| 45 // in the tabbed options UI. We need to post a message to our loop | 45 // in the tabbed options UI. We need to post a message to our loop |
| 46 // to cancel network retrieval. | 46 // to cancel network retrieval. |
| 47 virtual void Cancel(); | 47 virtual void Cancel(); |
| 48 | 48 |
| 49 // URLFetcher::Delegate method called back from the URLFetcher object. | 49 // content::URLFetcherDelegate method called back from the URLFetcher object. |
| 50 virtual void OnURLFetchComplete(const URLFetcher* source, | 50 virtual void OnURLFetchComplete(const URLFetcher* source); |
| 51 const GURL& url, | |
| 52 const net::URLRequestStatus& status, | |
| 53 int response_code, | |
| 54 const net::ResponseCookies& cookies, | |
| 55 const std::string& data); | |
| 56 | 51 |
| 57 private: | 52 private: |
| 58 FRIEND_TEST_ALL_PREFIXES(Toolbar5ImporterTest, BookmarkParse); | 53 FRIEND_TEST_ALL_PREFIXES(Toolbar5ImporterTest, BookmarkParse); |
| 59 | 54 |
| 60 virtual ~Toolbar5Importer(); | 55 virtual ~Toolbar5Importer(); |
| 61 | 56 |
| 62 // Internal states of the toolbar importer. | 57 // Internal states of the toolbar importer. |
| 63 enum InternalStateEnum { | 58 enum InternalStateEnum { |
| 64 NOT_USED = -1, | 59 NOT_USED = -1, |
| 65 INITIALIZED, | 60 INITIALIZED, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 153 |
| 159 // The fetchers need to be available to cancel the network call on user cancel | 154 // The fetchers need to be available to cancel the network call on user cancel |
| 160 // hence they are stored as member variables. | 155 // hence they are stored as member variables. |
| 161 URLFetcher* token_fetcher_; | 156 URLFetcher* token_fetcher_; |
| 162 URLFetcher* data_fetcher_; | 157 URLFetcher* data_fetcher_; |
| 163 | 158 |
| 164 DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); | 159 DISALLOW_COPY_AND_ASSIGN(Toolbar5Importer); |
| 165 }; | 160 }; |
| 166 | 161 |
| 167 #endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ | 162 #endif // CHROME_BROWSER_IMPORTER_TOOLBAR_IMPORTER_H_ |
| OLD | NEW |