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/chrome_resource_dispatcher_host_delegate.cc

Issue 9369009: Make content::ResourceContext be a real interface like the rest of the Content API (i.e. don't ha... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 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 | Annotate | Revision Log
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/chrome_resource_dispatcher_host_delegate. h" 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. 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/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/download/download_request_limiter.h" 10 #include "chrome/browser/download/download_request_limiter.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() { 86 ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() {
87 } 87 }
88 88
89 bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest( 89 bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest(
90 int child_id, 90 int child_id,
91 int route_id, 91 int route_id,
92 const std::string& method, 92 const std::string& method,
93 const GURL& url, 93 const GURL& url,
94 ResourceType::Type resource_type, 94 ResourceType::Type resource_type,
95 const content::ResourceContext& resource_context, 95 content::ResourceContext* resource_context,
96 const content::Referrer& referrer) { 96 const content::Referrer& referrer) {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
98 98
99 // Handle a PREFETCH resource type. If prefetch is disabled, squelch the 99 // Handle a PREFETCH resource type. If prefetch is disabled, squelch the
100 // request. Otherwise, do a normal request to warm the cache. 100 // request. Otherwise, do a normal request to warm the cache.
101 if (resource_type == ResourceType::PREFETCH) { 101 if (resource_type == ResourceType::PREFETCH) {
102 // All PREFETCH requests should be GETs, but be defensive about it. 102 // All PREFETCH requests should be GETs, but be defensive about it.
103 if (method != "GET") 103 if (method != "GET")
104 return false; 104 return false;
105 105
(...skipping 19 matching lines...) Expand all
125 prerender_tracker_->TryCancelOnIOThread( 125 prerender_tracker_->TryCancelOnIOThread(
126 child_id, route_id, prerender::FINAL_STATUS_INVALID_HTTP_METHOD); 126 child_id, route_id, prerender::FINAL_STATUS_INVALID_HTTP_METHOD);
127 return false; 127 return false;
128 } 128 }
129 129
130 return true; 130 return true;
131 } 131 }
132 132
133 void ChromeResourceDispatcherHostDelegate::RequestBeginning( 133 void ChromeResourceDispatcherHostDelegate::RequestBeginning(
134 net::URLRequest* request, 134 net::URLRequest* request,
135 const content::ResourceContext& resource_context, 135 content::ResourceContext* resource_context,
136 ResourceType::Type resource_type, 136 ResourceType::Type resource_type,
137 int child_id, 137 int child_id,
138 int route_id, 138 int route_id,
139 bool is_continuation_of_transferred_request, 139 bool is_continuation_of_transferred_request,
140 ScopedVector<content::ResourceThrottle>* throttles) { 140 ScopedVector<content::ResourceThrottle>* throttles) {
141 if (is_continuation_of_transferred_request) 141 if (is_continuation_of_transferred_request)
142 ChromeURLRequestUserData::Delete(request); 142 ChromeURLRequestUserData::Delete(request);
143 143
144 ChromeURLRequestUserData* user_data = 144 ChromeURLRequestUserData* user_data =
145 ChromeURLRequestUserData::Create(request); 145 ChromeURLRequestUserData::Create(request);
146 if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) { 146 if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) {
147 user_data->set_is_prerender(true); 147 user_data->set_is_prerender(true);
148 request->set_priority(net::IDLE); 148 request->set_priority(net::IDLE);
149 } 149 }
150 150
151 if (resource_type == ResourceType::MAIN_FRAME) { 151 if (resource_type == ResourceType::MAIN_FRAME) {
152 throttles->push_back(new TransferNavigationResourceThrottle(request)); 152 throttles->push_back(new TransferNavigationResourceThrottle(request));
153 153
154 #if defined(OS_CHROMEOS) 154 #if defined(OS_CHROMEOS)
155 // We check offline first, then check safe browsing so that we still can 155 // We check offline first, then check safe browsing so that we still can
156 // block unsafe site after we remove offline page. 156 // block unsafe site after we remove offline page.
157 throttles->push_back(new OfflineResourceThrottle( 157 throttles->push_back(new OfflineResourceThrottle(
158 child_id, route_id, request, resource_context.appcache_service())); 158 child_id, route_id, request, resource_context->GetAppCacheService()));
159 #endif 159 #endif
160 } 160 }
161 161
162 #if defined(ENABLE_SAFE_BROWSING) 162 #if defined(ENABLE_SAFE_BROWSING)
163 // Insert safe browsing at the front of the chain, so it gets to decide 163 // Insert safe browsing at the front of the chain, so it gets to decide
164 // on policies first. 164 // on policies first.
165 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( 165 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
166 resource_context.GetUserData(NULL));
167 if (io_data->safe_browsing_enabled()->GetValue()) { 166 if (io_data->safe_browsing_enabled()->GetValue()) {
168 throttles->push_back(CreateSafeBrowsingResourceThrottle( 167 throttles->push_back(CreateSafeBrowsingResourceThrottle(
169 request, child_id, route_id, 168 request, child_id, route_id,
170 resource_type != ResourceType::MAIN_FRAME)); 169 resource_type != ResourceType::MAIN_FRAME));
171 } 170 }
172 #endif 171 #endif
173 } 172 }
174 173
175 void ChromeResourceDispatcherHostDelegate::DownloadStarting( 174 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
176 net::URLRequest* request, 175 net::URLRequest* request,
177 const content::ResourceContext& resource_context, 176 content::ResourceContext* resource_context,
178 int child_id, 177 int child_id,
179 int route_id, 178 int route_id,
180 int request_id, 179 int request_id,
181 bool is_new_request, 180 bool is_new_request,
182 ScopedVector<content::ResourceThrottle>* throttles) { 181 ScopedVector<content::ResourceThrottle>* throttles) {
183 BrowserThread::PostTask( 182 BrowserThread::PostTask(
184 BrowserThread::UI, FROM_HERE, 183 BrowserThread::UI, FROM_HERE,
185 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); 184 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id));
186 185
187 // If this isn't a new request, we've seen this before and added the safe 186 // If this isn't a new request, we've seen this before and added the safe
188 // browsing resource throttle already so no need to add it again. This code 187 // browsing resource throttle already so no need to add it again. This code
189 // path is only hit for requests initiated through the browser, and not the 188 // path is only hit for requests initiated through the browser, and not the
190 // web, so no need to add the download throttle. 189 // web, so no need to add the download throttle.
191 if (is_new_request) { 190 if (is_new_request) {
192 #if defined(ENABLE_SAFE_BROWSING) 191 #if defined(ENABLE_SAFE_BROWSING)
193 ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( 192 ProfileIOData* io_data =
194 resource_context.GetUserData(NULL)); 193 ProfileIOData::FromResourceContext(resource_context);
195 if (io_data->safe_browsing_enabled()->GetValue()) { 194 if (io_data->safe_browsing_enabled()->GetValue()) {
196 throttles->push_back(CreateSafeBrowsingResourceThrottle( 195 throttles->push_back(CreateSafeBrowsingResourceThrottle(
197 request, child_id, route_id, false)); 196 request, child_id, route_id, false));
198 } 197 }
199 #endif 198 #endif
200 } else { 199 } else {
201 throttles->push_back(new DownloadResourceThrottle( 200 throttles->push_back(new DownloadResourceThrottle(
202 download_request_limiter_, child_id, route_id, request_id)); 201 download_request_limiter_, child_id, route_id, request_id));
203 } 202 }
204 } 203 }
205 204
206 bool ChromeResourceDispatcherHostDelegate::ShouldDeferStart( 205 bool ChromeResourceDispatcherHostDelegate::ShouldDeferStart(
207 net::URLRequest* request, 206 net::URLRequest* request,
208 const content::ResourceContext& resource_context) { 207 content::ResourceContext* resource_context) {
209 ResourceDispatcherHostRequestInfo* info = 208 ResourceDispatcherHostRequestInfo* info =
210 resource_dispatcher_host_->InfoForRequest(request); 209 resource_dispatcher_host_->InfoForRequest(request);
211 return prerender_tracker_->PotentiallyDelayRequestOnIOThread( 210 return prerender_tracker_->PotentiallyDelayRequestOnIOThread(
212 request->url(), info->child_id(), info->route_id(), info->request_id()); 211 request->url(), info->child_id(), info->route_id(), info->request_id());
213 } 212 }
214 213
215 bool ChromeResourceDispatcherHostDelegate::AcceptSSLClientCertificateRequest( 214 bool ChromeResourceDispatcherHostDelegate::AcceptSSLClientCertificateRequest(
216 net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) { 215 net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) {
217 if (request->load_flags() & net::LOAD_PREFETCH) 216 if (request->load_flags() & net::LOAD_PREFETCH)
218 return false; 217 return false;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // suggest auto-login, if available. 323 // suggest auto-login, if available.
325 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->child_id(), 324 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->child_id(),
326 info->route_id()); 325 info->route_id());
327 } 326 }
328 327
329 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( 328 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected(
330 net::URLRequest* request, 329 net::URLRequest* request,
331 content::ResourceResponse* response) { 330 content::ResourceResponse* response) {
332 LoadTimingObserver::PopulateTimingInfo(request, response); 331 LoadTimingObserver::PopulateTimingInfo(request, response);
333 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698