Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/loader/data_reduction_proxy_resource_throttle_android.cc

Issue 2535723005: Stop using ResourceController in ResourceThrottle (Closed)
Patch Set: Addressed #48 Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/render_frame_host.h" 12 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/resource_context.h" 13 #include "content/public/browser/resource_context.h"
14 #include "content/public/browser/resource_controller.h"
15 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
18 #include "net/http/http_response_headers.h" 17 #include "net/http/http_response_headers.h"
19 #include "net/url_request/redirect_info.h" 18 #include "net/url_request/redirect_info.h"
20 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
21 20
22 using content::BrowserThread; 21 using content::BrowserThread;
23 using content::ResourceThrottle; 22 using content::ResourceThrottle;
24 using safe_browsing::SafeBrowsingService; 23 using safe_browsing::SafeBrowsingService;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 71
73 // Save the redirect urls for possible malware detail reporting later. 72 // Save the redirect urls for possible malware detail reporting later.
74 redirect_urls_.push_back(redirect_info.new_url); 73 redirect_urls_.push_back(redirect_info.new_url);
75 74
76 // We need to check the new URL before following the redirect. 75 // We need to check the new URL before following the redirect.
77 SBThreatType threat_type = CheckUrl(); 76 SBThreatType threat_type = CheckUrl();
78 if (threat_type == safe_browsing::SB_THREAT_TYPE_SAFE) 77 if (threat_type == safe_browsing::SB_THREAT_TYPE_SAFE)
79 return; 78 return;
80 79
81 if (request_->load_flags() & net::LOAD_PREFETCH) { 80 if (request_->load_flags() & net::LOAD_PREFETCH) {
82 controller()->Cancel(); 81 Cancel();
83 return; 82 return;
84 } 83 }
85 const content::ResourceRequestInfo* info = 84 const content::ResourceRequestInfo* info =
86 content::ResourceRequestInfo::ForRequest(request_); 85 content::ResourceRequestInfo::ForRequest(request_);
87 86
88 state_ = STATE_DISPLAYING_BLOCKING_PAGE; 87 state_ = STATE_DISPLAYING_BLOCKING_PAGE;
89 security_interstitials::UnsafeResource unsafe_resource; 88 security_interstitials::UnsafeResource unsafe_resource;
90 unsafe_resource.url = redirect_info.new_url; 89 unsafe_resource.url = redirect_info.new_url;
91 unsafe_resource.original_url = request_->original_url(); 90 unsafe_resource.original_url = request_->original_url();
92 unsafe_resource.redirect_urls = redirect_urls_; 91 unsafe_resource.redirect_urls = redirect_urls_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO 137 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO
139 // thread when the user has decided to proceed with the current request, or 138 // thread when the user has decided to proceed with the current request, or
140 // go back. 139 // go back.
141 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) { 140 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) {
142 CHECK(state_ == STATE_DISPLAYING_BLOCKING_PAGE); 141 CHECK(state_ == STATE_DISPLAYING_BLOCKING_PAGE);
143 state_ = STATE_NONE; 142 state_ = STATE_NONE;
144 143
145 if (proceed) 144 if (proceed)
146 ResumeRequest(); 145 ResumeRequest();
147 else 146 else
148 controller()->Cancel(); 147 Cancel();
149 } 148 }
150 149
151 SBThreatType DataReductionProxyResourceThrottle::CheckUrl() { 150 SBThreatType DataReductionProxyResourceThrottle::CheckUrl() {
152 SBThreatType result = safe_browsing::SB_THREAT_TYPE_SAFE; 151 SBThreatType result = safe_browsing::SB_THREAT_TYPE_SAFE;
153 152
154 // TODO(sgurun) Check for spdy proxy origin. 153 // TODO(sgurun) Check for spdy proxy origin.
155 if (request_->response_headers() == NULL) 154 if (request_->response_headers() == NULL)
156 return result; 155 return result;
157 156
158 if (request_->response_headers()->HasHeader("X-Phishing-Url")) 157 if (request_->response_headers()->HasHeader("X-Phishing-Url"))
(...skipping 10 matching lines...) Expand all
169 } 168 }
170 169
171 return result; 170 return result;
172 } 171 }
173 172
174 void DataReductionProxyResourceThrottle::ResumeRequest() { 173 void DataReductionProxyResourceThrottle::ResumeRequest() {
175 CHECK(state_ == STATE_NONE); 174 CHECK(state_ == STATE_NONE);
176 175
177 // Inject the header before resuming the request. 176 // Inject the header before resuming the request.
178 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); 177 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true);
179 controller()->Resume(); 178 Resume();
180 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698