blob: fb8aafdb700fa486d968b31bd075d02f0139f06d [file] [log] [blame]
[email protected]7b3941052013-02-13 01:21:591// 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
[email protected]1f6a9a62013-05-22 01:53:0610#include "base/memory/scoped_ptr.h"
[email protected]7b3941052013-02-13 01:21:5911#include "base/memory/weak_ptr.h"
[email protected]7b3941052013-02-13 01:21:5912#include "net/url_request/url_fetcher_delegate.h"
[email protected]a6483d22013-07-03 22:11:0013#include "url/gurl.h"
[email protected]7b3941052013-02-13 01:21:5914
15namespace base {
[email protected]1f6a9a62013-05-22 01:53:0616class Value;
[email protected]7b3941052013-02-13 01:21:5917}
18
19namespace net {
20class URLFetcher;
21class URLRequestContextGetter;
22}
23
24namespace extensions {
25
26class WebstoreDataFetcherDelegate;
27
28// WebstoreDataFetcher fetches web store data and parses it into a
29// DictionaryValue.
30class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher>,
31 public net::URLFetcherDelegate {
32 public:
33 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate,
34 net::URLRequestContextGetter* request_context,
35 const GURL& referrer_url,
36 const std::string webstore_item_id);
37 virtual ~WebstoreDataFetcher();
38
39 void Start();
40
41 private:
[email protected]1f6a9a62013-05-22 01:53:0642 void OnJsonParseSuccess(scoped_ptr<base::Value> parsed_json);
43 void OnJsonParseFailure(const std::string& error);
[email protected]7b3941052013-02-13 01:21:5944
45 // net::URLFetcherDelegate overrides:
46 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
47
48 WebstoreDataFetcherDelegate* delegate_;
49 net::URLRequestContextGetter* request_context_;
50 GURL referrer_url_;
51 std::string id_;
52
53 // For fetching webstore JSON data.
54 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_;
55
56 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher);
57};
58
59} // namespace extensions
60
61#endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_