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.
5 #ifndef CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_
6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "content/public/common/resource_type.h"
11 class SafeBrowsingService
;
14 class ResourceContext
;
15 class ResourceThrottle
;
22 // Factory for creating a SafeBrowsingResourceThrottle. If a factory is
23 // registered, the factory's CreateResourceThrottle() is called. Otherwise,
24 // if SAFE_BROWSING_DB_LOCAL || SAFE_BROWSING_DB_REMOTE is enabled, a new
25 // SafeBrowsingResourceThrottle is returned, or NULL if only
26 // SAFE_BROWSING_SERVICE is enabled.
27 class SafeBrowsingResourceThrottleFactory
{
29 // Registers a factory. Does not take the ownership of the factory. The
30 // caller has to make sure the factory stays alive and properly destroyed.
31 static void RegisterFactory(SafeBrowsingResourceThrottleFactory
* factory
);
33 // Creates a new resource throttle for safe browsing, using the factory
34 // if there is one registered.
35 static content::ResourceThrottle
* Create(
36 net::URLRequest
* request
,
37 content::ResourceContext
* resource_context
,
38 content::ResourceType resource_type
,
39 SafeBrowsingService
* service
);
41 // Like above, but bypass the registered factory and create a true
42 // SafeBrowsingResourceThrottle.
43 static content::ResourceThrottle
* CreateWithoutRegisteredFactory(
44 net::URLRequest
* request
,
45 content::ResourceType resource_type
,
46 SafeBrowsingService
* service
);
49 SafeBrowsingResourceThrottleFactory() { }
50 virtual ~SafeBrowsingResourceThrottleFactory() { }
52 virtual content::ResourceThrottle
* CreateResourceThrottle(
53 net::URLRequest
* request
,
54 content::ResourceContext
* resource_context
,
55 content::ResourceType resource_type
,
56 SafeBrowsingService
* service
) = 0;
59 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory
);
62 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_