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

Side by Side Diff: chrome/browser/renderer_host/safe_browsing_resource_throttle.cc

Issue 893843003: Add RedirectInfo as a redirect parameter to ResourceThrottles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document ResourceThrottle Created 5 years, 10 months 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 (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.h" 5 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.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/safe_browsing/safe_browsing_service.h" 10 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/resource_controller.h" 13 #include "content/public/browser/resource_controller.h"
14 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/url_request/redirect_info.h"
17 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
18 19
19 // Maximum time in milliseconds to wait for the safe browsing service to 20 // Maximum time in milliseconds to wait for the safe browsing service to
20 // verify a URL. After this amount of time the outstanding check will be 21 // verify a URL. After this amount of time the outstanding check will be
21 // aborted, and the URL will be treated as if it were safe. 22 // aborted, and the URL will be treated as if it were safe.
22 static const int kCheckUrlTimeoutMs = 5000; 23 static const int kCheckUrlTimeoutMs = 5000;
23 24
24 // TODO(eroman): Downgrade these CHECK()s to DCHECKs once there is more 25 // TODO(eroman): Downgrade these CHECK()s to DCHECKs once there is more
25 // unit test coverage. 26 // unit test coverage.
26 27
(...skipping 20 matching lines...) Expand all
47 // We need to check the new URL before starting the request. 48 // We need to check the new URL before starting the request.
48 if (CheckUrl(request_->url())) 49 if (CheckUrl(request_->url()))
49 return; 50 return;
50 51
51 // If the URL couldn't be verified synchronously, defer starting the 52 // If the URL couldn't be verified synchronously, defer starting the
52 // request until the check has completed. 53 // request until the check has completed.
53 defer_state_ = DEFERRED_START; 54 defer_state_ = DEFERRED_START;
54 *defer = true; 55 *defer = true;
55 } 56 }
56 57
57 void SafeBrowsingResourceThrottle::WillRedirectRequest(const GURL& new_url, 58 void SafeBrowsingResourceThrottle::WillRedirectRequest(
58 bool* defer) { 59 const net::RedirectInfo& redirect_info,
60 bool* defer) {
59 CHECK(state_ == STATE_NONE); 61 CHECK(state_ == STATE_NONE);
60 CHECK(defer_state_ == DEFERRED_NONE); 62 CHECK(defer_state_ == DEFERRED_NONE);
61 63
62 // Save the redirect urls for possible malware detail reporting later. 64 // Save the redirect urls for possible malware detail reporting later.
63 redirect_urls_.push_back(new_url); 65 redirect_urls_.push_back(redirect_info.new_url);
64 66
65 // We need to check the new URL before following the redirect. 67 // We need to check the new URL before following the redirect.
66 if (CheckUrl(new_url)) 68 if (CheckUrl(redirect_info.new_url))
67 return; 69 return;
68 70
69 // If the URL couldn't be verified synchronously, defer following the 71 // If the URL couldn't be verified synchronously, defer following the
70 // redirect until the SafeBrowsing check is complete. Store the redirect 72 // redirect until the SafeBrowsing check is complete. Store the redirect
71 // context so we can pass it on to other handlers once we have completed 73 // context so we can pass it on to other handlers once we have completed
72 // our check. 74 // our check.
73 defer_state_ = DEFERRED_REDIRECT; 75 defer_state_ = DEFERRED_REDIRECT;
74 *defer = true; 76 *defer = true;
75 } 77 }
76 78
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 url_being_checked_, SB_THREAT_TYPE_SAFE, std::string()); 224 url_being_checked_, SB_THREAT_TYPE_SAFE, std::string());
223 } 225 }
224 226
225 void SafeBrowsingResourceThrottle::ResumeRequest() { 227 void SafeBrowsingResourceThrottle::ResumeRequest() {
226 CHECK(state_ == STATE_NONE); 228 CHECK(state_ == STATE_NONE);
227 CHECK(defer_state_ != DEFERRED_NONE); 229 CHECK(defer_state_ != DEFERRED_NONE);
228 230
229 defer_state_ = DEFERRED_NONE; 231 defer_state_ = DEFERRED_NONE;
230 controller()->Resume(); 232 controller()->Resume();
231 } 233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698