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