OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "content/public/common/resource_type.h" | 9 #include "content/public/common/resource_type.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // registered, the factory's CreateResourceThrottle() is called. Otherwise, | 23 // registered, the factory's CreateResourceThrottle() is called. Otherwise, |
24 // if SAFE_BROWSING_DB_LOCAL || SAFE_BROWSING_DB_REMOTE is enabled, a new | 24 // if SAFE_BROWSING_DB_LOCAL || SAFE_BROWSING_DB_REMOTE is enabled, a new |
25 // SafeBrowsingResourceThrottle is returned, or NULL if only | 25 // SafeBrowsingResourceThrottle is returned, or NULL if only |
26 // SAFE_BROWSING_SERVICE is enabled. | 26 // SAFE_BROWSING_SERVICE is enabled. |
27 class SafeBrowsingResourceThrottleFactory { | 27 class SafeBrowsingResourceThrottleFactory { |
28 public: | 28 public: |
29 // Registers a factory. Does not take the ownership of the factory. The | 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. | 30 // caller has to make sure the factory stays alive and properly destroyed. |
31 static void RegisterFactory(SafeBrowsingResourceThrottleFactory* factory); | 31 static void RegisterFactory(SafeBrowsingResourceThrottleFactory* factory); |
32 | 32 |
33 // Creates a new resource throttle for safe browsing | 33 // Creates a new resource throttle for safe browsing, using the factory |
| 34 // if there is one registered. |
34 static content::ResourceThrottle* Create( | 35 static content::ResourceThrottle* Create( |
35 net::URLRequest* request, | 36 net::URLRequest* request, |
36 content::ResourceContext* resource_context, | 37 content::ResourceContext* resource_context, |
37 content::ResourceType resource_type, | 38 content::ResourceType resource_type, |
38 SafeBrowsingService* service); | 39 SafeBrowsingService* service); |
39 | 40 |
| 41 // Like above, but bypass the registered factory. |
| 42 static content::ResourceThrottle* CreateWithoutFactory( |
| 43 net::URLRequest* request, |
| 44 content::ResourceType resource_type, |
| 45 SafeBrowsingService* service); |
| 46 |
40 protected: | 47 protected: |
41 SafeBrowsingResourceThrottleFactory() { } | 48 SafeBrowsingResourceThrottleFactory() { } |
42 virtual ~SafeBrowsingResourceThrottleFactory() { } | 49 virtual ~SafeBrowsingResourceThrottleFactory() { } |
43 | 50 |
44 virtual content::ResourceThrottle* CreateResourceThrottle( | 51 virtual content::ResourceThrottle* CreateResourceThrottle( |
45 net::URLRequest* request, | 52 net::URLRequest* request, |
46 content::ResourceContext* resource_context, | 53 content::ResourceContext* resource_context, |
47 content::ResourceType resource_type, | 54 content::ResourceType resource_type, |
48 SafeBrowsingService* service) = 0; | 55 SafeBrowsingService* service) = 0; |
49 | 56 |
50 private: | 57 private: |
51 static SafeBrowsingResourceThrottleFactory* factory_; | 58 static SafeBrowsingResourceThrottleFactory* factory_; |
52 | 59 |
53 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory); | 60 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory); |
54 }; | 61 }; |
55 | 62 |
56 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_
H_ | 63 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_
H_ |
OLD | NEW |