Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / extensions / blacklist_state_fetcher.h
blob26244eaaeab14f2defc39f8ee165de11d20b3c0e
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_
8 #include <set>
9 #include <string>
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/safe_browsing/protocol_manager_helper.h"
15 #include "extensions/browser/blacklist_state.h"
16 #include "net/url_request/url_fetcher.h"
17 #include "net/url_request/url_fetcher_delegate.h"
19 namespace net {
20 class URLRequestContextGetter;
23 namespace extensions {
25 class BlacklistStateFetcher : public net::URLFetcherDelegate {
26 public:
27 typedef base::Callback<void(BlacklistState)> RequestCallback;
29 BlacklistStateFetcher();
31 ~BlacklistStateFetcher() override;
33 virtual void Request(const std::string& id, const RequestCallback& callback);
35 void SetSafeBrowsingConfig(const SafeBrowsingProtocolConfig& config);
37 void SetURLRequestContextForTest(
38 net::URLRequestContextGetter* request_context);
40 protected:
41 // net::URLFetcherDelegate interface.
42 void OnURLFetchComplete(const net::URLFetcher* source) override;
44 private:
45 typedef std::multimap<std::string, RequestCallback> CallbackMultiMap;
47 GURL RequestUrl() const;
49 void SendRequest(const std::string& id);
51 // ID for URLFetchers for testing.
52 int url_fetcher_id_;
54 scoped_ptr<SafeBrowsingProtocolConfig> safe_browsing_config_;
55 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
56 scoped_refptr<net::URLRequestContextGetter> parent_request_context_for_test_;
58 // Extension id by URLFetcher.
59 std::map<const net::URLFetcher*, std::string> requests_;
61 // Callbacks by extension ID.
62 CallbackMultiMap callbacks_;
64 base::WeakPtrFactory<BlacklistStateFetcher> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(BlacklistStateFetcher);
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_