| 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 and create a true |
| 42 // SafeBrowsingResourceThrottle. |
| 43 static content::ResourceThrottle* CreateWithoutRegisteredFactory( |
| 44 net::URLRequest* request, |
| 45 content::ResourceType resource_type, |
| 46 SafeBrowsingService* service); |
| 47 |
| 40 protected: | 48 protected: |
| 41 SafeBrowsingResourceThrottleFactory() { } | 49 SafeBrowsingResourceThrottleFactory() { } |
| 42 virtual ~SafeBrowsingResourceThrottleFactory() { } | 50 virtual ~SafeBrowsingResourceThrottleFactory() { } |
| 43 | 51 |
| 44 virtual content::ResourceThrottle* CreateResourceThrottle( | 52 virtual content::ResourceThrottle* CreateResourceThrottle( |
| 45 net::URLRequest* request, | 53 net::URLRequest* request, |
| 46 content::ResourceContext* resource_context, | 54 content::ResourceContext* resource_context, |
| 47 content::ResourceType resource_type, | 55 content::ResourceType resource_type, |
| 48 SafeBrowsingService* service) = 0; | 56 SafeBrowsingService* service) = 0; |
| 49 | 57 |
| 50 private: | 58 private: |
| 51 static SafeBrowsingResourceThrottleFactory* factory_; | 59 static SafeBrowsingResourceThrottleFactory* factory_; |
| 52 | 60 |
| 53 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory); | 61 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory); |
| 54 }; | 62 }; |
| 55 | 63 |
| 56 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_
H_ | 64 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_
H_ |
| OLD | NEW |