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 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" | 5 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" |
6 | 6 |
7 #include "content/public/browser/resource_context.h" | 7 #include "content/public/browser/resource_context.h" |
8 | 8 |
9 // Compiling this file only makes sense if SAFE_BROWSING_SERVICE is enabled. | 9 // Compiling this file only makes sense if SAFE_BROWSING_SERVICE is enabled. |
10 // If the build is breaking here, it probably means that a gyp or gn file has | 10 // If the build is breaking here, it probably means that a gyp or gn file has |
11 // been modified to build this file with safe_browsing=0 (gn | 11 // been modified to build this file with safe_browsing=0 (gn |
12 // safe_browsing_mode=0). | 12 // safe_browsing_mode=0). |
13 #if !defined(SAFE_BROWSING_SERVICE) | 13 #if !defined(SAFE_BROWSING_SERVICE) |
14 #error Need to define safe_browsing mode. | 14 #error Need to define safe_browsing mode. |
15 #endif | 15 #endif |
16 | 16 |
17 #if defined(SAFE_BROWSING_DB_LOCAL) | 17 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
18 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" | 18 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" |
19 #endif | 19 #endif |
20 | 20 |
21 using content::ResourceThrottle; | 21 using content::ResourceThrottle; |
22 | 22 |
23 // static | 23 // static |
24 SafeBrowsingResourceThrottleFactory* | 24 SafeBrowsingResourceThrottleFactory* |
25 SafeBrowsingResourceThrottleFactory::factory_ = NULL; | 25 SafeBrowsingResourceThrottleFactory::factory_ = NULL; |
26 | 26 |
27 // static | 27 // static |
28 void SafeBrowsingResourceThrottleFactory::RegisterFactory( | 28 void SafeBrowsingResourceThrottleFactory::RegisterFactory( |
29 SafeBrowsingResourceThrottleFactory* factory) { | 29 SafeBrowsingResourceThrottleFactory* factory) { |
30 factory_ = factory; | 30 factory_ = factory; |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 ResourceThrottle* SafeBrowsingResourceThrottleFactory::Create( | 34 ResourceThrottle* SafeBrowsingResourceThrottleFactory::Create( |
35 net::URLRequest* request, | 35 net::URLRequest* request, |
36 content::ResourceContext* resource_context, | 36 content::ResourceContext* resource_context, |
37 content::ResourceType resource_type, | 37 content::ResourceType resource_type, |
38 SafeBrowsingService* service) { | 38 SafeBrowsingService* service) { |
39 if (factory_) | 39 if (factory_) |
40 return factory_->CreateResourceThrottle( | 40 return factory_->CreateResourceThrottle( |
41 request, resource_context, resource_type, service); | 41 request, resource_context, resource_type, service); |
42 | 42 |
43 #if defined(SAFE_BROWSING_DB_LOCAL) | 43 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
44 // Throttle consults a local database before proceeding. | 44 // Throttle consults a local or remote database before proceeding. |
45 return new SafeBrowsingResourceThrottle(request, resource_type, service); | 45 return new SafeBrowsingResourceThrottle(request, resource_type, service); |
46 #else | 46 #else |
47 return NULL; | 47 return NULL; |
48 #endif | 48 #endif |
49 } | 49 } |
OLD | NEW |