OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/url_request/url_fetcher_delegate.h" |
| 13 |
| 14 namespace base { |
| 15 class DictionaryValue; |
| 16 } |
| 17 |
| 18 namespace net { |
| 19 class URLFetcher; |
| 20 class URLRequestContextGetter; |
| 21 } |
| 22 |
| 23 namespace extensions { |
| 24 |
| 25 class WebstoreDataFetcherDelegate; |
| 26 |
| 27 // WebstoreDataFetcher fetches web store data and parses it into a |
| 28 // DictionaryValue. |
| 29 class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher>, |
| 30 public net::URLFetcherDelegate { |
| 31 public: |
| 32 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate, |
| 33 net::URLRequestContextGetter* request_context, |
| 34 const GURL& referrer_url, |
| 35 const std::string webstore_item_id); |
| 36 virtual ~WebstoreDataFetcher(); |
| 37 |
| 38 void Start(); |
| 39 |
| 40 private: |
| 41 class SafeWebstoreResponseParser; |
| 42 |
| 43 // Client callbacks for SafeWebstoreResponseParser when parsing is complete. |
| 44 void OnWebstoreResponseParseSuccess(base::DictionaryValue* webstore_data); |
| 45 void OnWebstoreResponseParseFailure(const std::string& error); |
| 46 |
| 47 // net::URLFetcherDelegate overrides: |
| 48 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 49 |
| 50 WebstoreDataFetcherDelegate* delegate_; |
| 51 net::URLRequestContextGetter* request_context_; |
| 52 GURL referrer_url_; |
| 53 std::string id_; |
| 54 |
| 55 // For fetching webstore JSON data. |
| 56 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher); |
| 59 }; |
| 60 |
| 61 } // namespace extensions |
| 62 |
| 63 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
OLD | NEW |