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/loader/data_reduction_proxy_resource_throttle_android.h
" | 5 #include "chrome/browser/loader/data_reduction_proxy_resource_throttle_android.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/profiles/profile_io_data.h" | 10 #include "chrome/browser/profiles/profile_io_data.h" |
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
14 #include "content/public/browser/resource_context.h" | 14 #include "content/public/browser/resource_context.h" |
15 #include "content/public/browser/resource_controller.h" | |
16 #include "content/public/browser/resource_request_info.h" | 15 #include "content/public/browser/resource_request_info.h" |
17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
18 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
19 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
20 #include "net/url_request/redirect_info.h" | 19 #include "net/url_request/redirect_info.h" |
21 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
22 | 21 |
23 using content::BrowserThread; | 22 using content::BrowserThread; |
24 using content::ResourceThrottle; | 23 using content::ResourceThrottle; |
25 using safe_browsing::SafeBrowsingService; | 24 using safe_browsing::SafeBrowsingService; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 73 |
75 // Save the redirect urls for possible malware detail reporting later. | 74 // Save the redirect urls for possible malware detail reporting later. |
76 redirect_urls_.push_back(redirect_info.new_url); | 75 redirect_urls_.push_back(redirect_info.new_url); |
77 | 76 |
78 // We need to check the new URL before following the redirect. | 77 // We need to check the new URL before following the redirect. |
79 SBThreatType threat_type = CheckUrl(); | 78 SBThreatType threat_type = CheckUrl(); |
80 if (threat_type == safe_browsing::SB_THREAT_TYPE_SAFE) | 79 if (threat_type == safe_browsing::SB_THREAT_TYPE_SAFE) |
81 return; | 80 return; |
82 | 81 |
83 if (request_->load_flags() & net::LOAD_PREFETCH) { | 82 if (request_->load_flags() & net::LOAD_PREFETCH) { |
84 controller()->Cancel(); | 83 Cancel(); |
85 return; | 84 return; |
86 } | 85 } |
87 const content::ResourceRequestInfo* info = | 86 const content::ResourceRequestInfo* info = |
88 content::ResourceRequestInfo::ForRequest(request_); | 87 content::ResourceRequestInfo::ForRequest(request_); |
89 | 88 |
90 state_ = STATE_DISPLAYING_BLOCKING_PAGE; | 89 state_ = STATE_DISPLAYING_BLOCKING_PAGE; |
91 security_interstitials::UnsafeResource unsafe_resource; | 90 security_interstitials::UnsafeResource unsafe_resource; |
92 unsafe_resource.url = redirect_info.new_url; | 91 unsafe_resource.url = redirect_info.new_url; |
93 unsafe_resource.original_url = request_->original_url(); | 92 unsafe_resource.original_url = request_->original_url(); |
94 unsafe_resource.redirect_urls = redirect_urls_; | 93 unsafe_resource.redirect_urls = redirect_urls_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO | 139 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO |
141 // thread when the user has decided to proceed with the current request, or | 140 // thread when the user has decided to proceed with the current request, or |
142 // go back. | 141 // go back. |
143 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) { | 142 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) { |
144 CHECK(state_ == STATE_DISPLAYING_BLOCKING_PAGE); | 143 CHECK(state_ == STATE_DISPLAYING_BLOCKING_PAGE); |
145 state_ = STATE_NONE; | 144 state_ = STATE_NONE; |
146 | 145 |
147 if (proceed) | 146 if (proceed) |
148 ResumeRequest(); | 147 ResumeRequest(); |
149 else | 148 else |
150 controller()->Cancel(); | 149 Cancel(); |
151 } | 150 } |
152 | 151 |
153 SBThreatType DataReductionProxyResourceThrottle::CheckUrl() { | 152 SBThreatType DataReductionProxyResourceThrottle::CheckUrl() { |
154 SBThreatType result = safe_browsing::SB_THREAT_TYPE_SAFE; | 153 SBThreatType result = safe_browsing::SB_THREAT_TYPE_SAFE; |
155 | 154 |
156 // TODO(sgurun) Check for spdy proxy origin. | 155 // TODO(sgurun) Check for spdy proxy origin. |
157 if (request_->response_headers() == NULL) | 156 if (request_->response_headers() == NULL) |
158 return result; | 157 return result; |
159 | 158 |
160 if (request_->response_headers()->HasHeader("X-Phishing-Url")) | 159 if (request_->response_headers()->HasHeader("X-Phishing-Url")) |
(...skipping 10 matching lines...) Expand all Loading... |
171 } | 170 } |
172 | 171 |
173 return result; | 172 return result; |
174 } | 173 } |
175 | 174 |
176 void DataReductionProxyResourceThrottle::ResumeRequest() { | 175 void DataReductionProxyResourceThrottle::ResumeRequest() { |
177 CHECK(state_ == STATE_NONE); | 176 CHECK(state_ == STATE_NONE); |
178 | 177 |
179 // Inject the header before resuming the request. | 178 // Inject the header before resuming the request. |
180 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); | 179 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); |
181 controller()->Resume(); | 180 Resume(); |
182 } | 181 } |
OLD | NEW |