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_
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/blacklist_state.h"
14 #include "chrome/browser/safe_browsing/protocol_manager_helper.h"
15 #include "net/url_request/url_fetcher.h"
16 #include "net/url_request/url_fetcher_delegate.h"
18 namespace extensions
{
20 class BlacklistStateFetcher
: public net::URLFetcherDelegate
{
22 BlacklistStateFetcher();
24 virtual ~BlacklistStateFetcher();
26 typedef base::Callback
<void(BlacklistState
)> RequestCallback
;
28 virtual void Request(const std::string
& id
, const RequestCallback
& callback
);
30 void SetSafeBrowsingConfig(const SafeBrowsingProtocolConfig
& config
);
33 // net::URLFetcherDelegate interface.
34 virtual void OnURLFetchComplete(const net::URLFetcher
* source
) OVERRIDE
;
37 GURL
RequestUrl() const;
39 SafeBrowsingProtocolConfig safe_browsing_config_
;
40 bool safe_browsing_config_initialized_
;
42 // ID for URLFetchers for testing.
45 // Extension id by URLFetcher.
46 std::map
<const net::URLFetcher
*, std::string
> requests_
;
48 typedef std::multimap
<std::string
, RequestCallback
> CallbackMultiMap
;
50 // Callbacks by extension ID.
51 CallbackMultiMap callbacks_
;
53 DISALLOW_COPY_AND_ASSIGN(BlacklistStateFetcher
);
56 } // namespace extensions
58 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_