1// Copyright (c) 2012 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_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_
6#define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_
7
8#include "base/basictypes.h"
9#include "content/public/common/resource_type.h"
10
11class SafeBrowsingService;
12
13namespace content {
14class ResourceContext;
15class ResourceThrottle;
16}
17
18namespace net {
19class URLRequest;
20}
21
22// Factory for creating a SafeBrowsingResourceThrottle. If a factory is
23// registered, the factory's CreateResourceThrottle() is called.  Otherwise,
24// when FULL_SAFE_BROWSING is enabled, a new SafeBrowsingResourceThrottle is
25// returned, or NULL if MOBILE_SAFE_BROWSING is enabled.
26class SafeBrowsingResourceThrottleFactory {
27 public:
28  // Registers a factory. Does not take the ownership of the factory. The
29  // caller has to make sure the factory stays alive and properly destroyed.
30  static void RegisterFactory(SafeBrowsingResourceThrottleFactory* factory);
31
32  // Creates a new resource throttle for safe browsing
33  static content::ResourceThrottle* Create(
34      net::URLRequest* request,
35      content::ResourceContext* resource_context,
36      content::ResourceType resource_type,
37      SafeBrowsingService* service);
38
39 protected:
40  SafeBrowsingResourceThrottleFactory() { }
41  virtual ~SafeBrowsingResourceThrottleFactory() { }
42
43  virtual content::ResourceThrottle* CreateResourceThrottle(
44      net::URLRequest* request,
45      content::ResourceContext* resource_context,
46      content::ResourceType resource_type,
47      SafeBrowsingService* service) = 0;
48
49 private:
50  static SafeBrowsingResourceThrottleFactory* factory_;
51
52  DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory);
53};
54
55#endif  // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_
56