OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/data_reduction_proxy_resource_throttle_an
droid.h" | 5 #include "chrome/browser/renderer_host/data_reduction_proxy_resource_throttle_an
droid.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/prerender/prerender_contents.h" | 9 #include "chrome/browser/prerender/prerender_contents.h" |
10 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" | 10 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" |
(...skipping 25 matching lines...) Expand all Loading... |
36 const char* DataReductionProxyResourceThrottle::kUnsafeUrlProceedHeader = | 36 const char* DataReductionProxyResourceThrottle::kUnsafeUrlProceedHeader = |
37 "X-Unsafe-Url-Proceed"; | 37 "X-Unsafe-Url-Proceed"; |
38 | 38 |
39 ResourceThrottle* | 39 ResourceThrottle* |
40 DataReductionProxyResourceThrottleFactory::CreateResourceThrottle( | 40 DataReductionProxyResourceThrottleFactory::CreateResourceThrottle( |
41 net::URLRequest* request, | 41 net::URLRequest* request, |
42 content::ResourceContext* resource_context, | 42 content::ResourceContext* resource_context, |
43 content::ResourceType resource_type, | 43 content::ResourceType resource_type, |
44 SafeBrowsingService* service) { | 44 SafeBrowsingService* service) { |
45 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) | 45 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
| 46 // Send requests through Safe Browsing if we can't process them. |
46 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 47 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
47 if (io_data->IsOffTheRecord() || !io_data->IsDataReductionProxyEnabled() || | 48 if (io_data->IsOffTheRecord() || !io_data->IsDataReductionProxyEnabled() || |
48 request->url().SchemeIsSecure()) | 49 request->url().SchemeIsSecure()) { |
49 return new SafeBrowsingResourceThrottle(request, resource_type, service); | 50 // *this is already registered as the SafeBrowsingResourceThrottleFactory, |
| 51 // so need to bypass that and use its base implementation. |
| 52 return SafeBrowsingResourceThrottleFactory::CreateWithoutRegisteredFactory( |
| 53 request, resource_type, service); |
| 54 } |
50 #endif | 55 #endif |
51 return new DataReductionProxyResourceThrottle(request, resource_type, | 56 return new DataReductionProxyResourceThrottle(request, resource_type, |
52 service); | 57 service); |
53 } | 58 } |
54 | 59 |
55 DataReductionProxyResourceThrottle::DataReductionProxyResourceThrottle( | 60 DataReductionProxyResourceThrottle::DataReductionProxyResourceThrottle( |
56 net::URLRequest* request, | 61 net::URLRequest* request, |
57 content::ResourceType resource_type, | 62 content::ResourceType resource_type, |
58 SafeBrowsingService* safe_browsing) | 63 SafeBrowsingService* safe_browsing) |
59 : state_(STATE_NONE), | 64 : state_(STATE_NONE), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return result; | 177 return result; |
173 } | 178 } |
174 | 179 |
175 void DataReductionProxyResourceThrottle::ResumeRequest() { | 180 void DataReductionProxyResourceThrottle::ResumeRequest() { |
176 CHECK(state_ == STATE_NONE); | 181 CHECK(state_ == STATE_NONE); |
177 | 182 |
178 // Inject the header before resuming the request. | 183 // Inject the header before resuming the request. |
179 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); | 184 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); |
180 controller()->Resume(); | 185 controller()->Resume(); |
181 } | 186 } |
OLD | NEW |