OLD | NEW |
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" |
11 #include "chrome/browser/download/download_resource_throttle.h" | 11 #include "chrome/browser/download/download_resource_throttle.h" |
12 #include "chrome/browser/download/download_util.h" | 12 #include "chrome/browser/download/download_util.h" |
13 #include "chrome/browser/extensions/user_script_listener.h" | 13 #include "chrome/browser/extensions/user_script_listener.h" |
14 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 14 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
15 #include "chrome/browser/google/google_util.h" | |
16 #include "chrome/browser/instant/instant_loader.h" | 15 #include "chrome/browser/instant/instant_loader.h" |
17 #include "chrome/browser/net/load_timing_observer.h" | 16 #include "chrome/browser/net/load_timing_observer.h" |
18 #include "chrome/browser/prerender/prerender_manager.h" | 17 #include "chrome/browser/prerender/prerender_manager.h" |
19 #include "chrome/browser/prerender/prerender_manager_factory.h" | 18 #include "chrome/browser/prerender/prerender_manager_factory.h" |
20 #include "chrome/browser/prerender/prerender_tracker.h" | 19 #include "chrome/browser/prerender/prerender_tracker.h" |
21 #include "chrome/browser/profiles/profile_io_data.h" | 20 #include "chrome/browser/profiles/profile_io_data.h" |
22 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" | 21 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" |
23 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" | 22 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" |
24 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" | 23 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" |
25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 throttles->push_back(new TransferNavigationResourceThrottle(request)); | 156 throttles->push_back(new TransferNavigationResourceThrottle(request)); |
158 | 157 |
159 #if defined(OS_CHROMEOS) | 158 #if defined(OS_CHROMEOS) |
160 // We check offline first, then check safe browsing so that we still can | 159 // We check offline first, then check safe browsing so that we still can |
161 // block unsafe site after we remove offline page. | 160 // block unsafe site after we remove offline page. |
162 throttles->push_back(new OfflineResourceThrottle( | 161 throttles->push_back(new OfflineResourceThrottle( |
163 child_id, route_id, request, resource_context)); | 162 child_id, route_id, request, resource_context)); |
164 #endif | 163 #endif |
165 } | 164 } |
166 | 165 |
167 AppendChromeMetricsHeaders(request, resource_context, resource_type); | |
168 | |
169 AppendStandardResourceThrottles(request, | 166 AppendStandardResourceThrottles(request, |
170 resource_context, | 167 resource_context, |
171 child_id, | 168 child_id, |
172 route_id, | 169 route_id, |
173 resource_type, | 170 resource_type, |
174 throttles); | 171 throttles); |
175 } | 172 } |
176 | 173 |
177 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 174 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
178 net::URLRequest* request, | 175 net::URLRequest* request, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 286 } |
290 #endif | 287 #endif |
291 | 288 |
292 content::ResourceThrottle* throttle = | 289 content::ResourceThrottle* throttle = |
293 user_script_listener_->CreateResourceThrottle(request->url(), | 290 user_script_listener_->CreateResourceThrottle(request->url(), |
294 resource_type); | 291 resource_type); |
295 if (throttle) | 292 if (throttle) |
296 throttles->push_back(throttle); | 293 throttles->push_back(throttle); |
297 } | 294 } |
298 | 295 |
299 void ChromeResourceDispatcherHostDelegate::AppendChromeMetricsHeaders( | |
300 net::URLRequest* request, | |
301 content::ResourceContext* resource_context, | |
302 ResourceType::Type resource_type) { | |
303 // Note our criteria for attaching Chrome experiment headers: | |
304 // 1. We only transmit to *.google.<TLD> domains. NOTE that this use of | |
305 // google_util helpers to check this does not guarantee that the URL is | |
306 // Google-owned, only that it is of the form *.google.<TLD>. In the future | |
307 // we may choose to reinforce this check. | |
308 // 2. We only transmit for non-Incognito profiles. | |
309 // 3. For the X-Chrome-UMA-Enabled bit, we only set it if UMA is in fact | |
310 // enabled for this install of Chrome. | |
311 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | |
312 if (google_util::IsGoogleDomainUrl(request->url().spec(), | |
313 google_util::ALLOW_SUBDOMAIN) && | |
314 !io_data->is_incognito() && io_data->enable_metrics()->GetValue()) { | |
315 request->SetExtraRequestHeaderByName("X-Chrome-UMA-Enabled", | |
316 "1", | |
317 false); | |
318 } | |
319 } | |
320 | |
321 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( | 296 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( |
322 const GURL& url, const std::string& mime_type) { | 297 const GURL& url, const std::string& mime_type) { |
323 // Special-case user scripts to get downloaded instead of viewed. | 298 // Special-case user scripts to get downloaded instead of viewed. |
324 return UserScript::IsURLUserScript(url, mime_type); | 299 return UserScript::IsURLUserScript(url, mime_type); |
325 } | 300 } |
326 | 301 |
327 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 302 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
328 net::URLRequest* request, | 303 net::URLRequest* request, |
329 content::ResourceResponse* response, | 304 content::ResourceResponse* response, |
330 IPC::Message::Sender* sender) { | 305 IPC::Message::Sender* sender) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 337 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
363 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 338 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
364 | 339 |
365 // See if the response contains the Google-Accounts-SignIn header. If so, | 340 // See if the response contains the Google-Accounts-SignIn header. If so, |
366 // then the user has just finished signing in, and the server is allowing the | 341 // then the user has just finished signing in, and the server is allowing the |
367 // browser to suggest connecting the user's profile to the account. | 342 // browser to suggest connecting the user's profile to the account. |
368 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(), | 343 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(), |
369 info->GetRouteID()); | 344 info->GetRouteID()); |
370 #endif | 345 #endif |
371 } | 346 } |
OLD | NEW |