safe_browsing_resource_throttle_factory.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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 10class SafeBrowsingService; 11 12namespace content { 13class ResourceContext; 14class ResourceThrottle; 15} 16 17namespace net { 18class URLRequest; 19} 20 21// Factory for creating a SafeBrowsingResourceThrottle. When FULL_SAFE_BROWSING 22// is enabled, creates a SafeBrowsingResourceThrottle. When MOBILE_SAFE_BROWSING 23// is enabled, the default implementation creates a null resource throttle, 24// therefore, a factory has to be registered before using this. 25class SafeBrowsingResourceThrottleFactory { 26 public: 27#if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 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 factory_ = factory; 32 } 33#endif 34 35 // Creates a new resource throttle for safe browsing 36 static content::ResourceThrottle* Create( 37 net::URLRequest* request, 38 content::ResourceContext* resource_context, 39 bool is_subresource, 40 SafeBrowsingService* service); 41 42 protected: 43 SafeBrowsingResourceThrottleFactory() { } 44 virtual ~SafeBrowsingResourceThrottleFactory() { } 45 46 virtual content::ResourceThrottle* CreateResourceThrottle( 47 net::URLRequest* request, 48 content::ResourceContext* resource_context, 49 bool is_subresource, 50 SafeBrowsingService* service) = 0; 51 52 private: 53 static SafeBrowsingResourceThrottleFactory* factory_; 54 55 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottleFactory); 56}; 57 58#endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_FACTORY_H_ 59