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" |
15 #include "chrome/browser/instant/instant_loader.h" | 16 #include "chrome/browser/instant/instant_loader.h" |
16 #include "chrome/browser/net/load_timing_observer.h" | 17 #include "chrome/browser/net/load_timing_observer.h" |
17 #include "chrome/browser/prerender/prerender_manager.h" | 18 #include "chrome/browser/prerender/prerender_manager.h" |
18 #include "chrome/browser/prerender/prerender_manager_factory.h" | 19 #include "chrome/browser/prerender/prerender_manager_factory.h" |
19 #include "chrome/browser/prerender/prerender_tracker.h" | 20 #include "chrome/browser/prerender/prerender_tracker.h" |
20 #include "chrome/browser/profiles/profile_io_data.h" | 21 #include "chrome/browser/profiles/profile_io_data.h" |
21 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" | 22 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" |
22 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" | 23 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" |
23 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" | 24 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" |
24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 throttles->push_back(new TransferNavigationResourceThrottle(request)); | 157 throttles->push_back(new TransferNavigationResourceThrottle(request)); |
157 | 158 |
158 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
159 // We check offline first, then check safe browsing so that we still can | 160 // We check offline first, then check safe browsing so that we still can |
160 // block unsafe site after we remove offline page. | 161 // block unsafe site after we remove offline page. |
161 throttles->push_back(new OfflineResourceThrottle( | 162 throttles->push_back(new OfflineResourceThrottle( |
162 child_id, route_id, request, resource_context)); | 163 child_id, route_id, request, resource_context)); |
163 #endif | 164 #endif |
164 } | 165 } |
165 | 166 |
| 167 AppendChromeMetricsHeaders(request, resource_context, resource_type); |
| 168 |
166 AppendStandardResourceThrottles(request, | 169 AppendStandardResourceThrottles(request, |
167 resource_context, | 170 resource_context, |
168 child_id, | 171 child_id, |
169 route_id, | 172 route_id, |
170 resource_type, | 173 resource_type, |
171 throttles); | 174 throttles); |
172 } | 175 } |
173 | 176 |
174 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 177 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
175 net::URLRequest* request, | 178 net::URLRequest* request, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 289 } |
287 #endif | 290 #endif |
288 | 291 |
289 content::ResourceThrottle* throttle = | 292 content::ResourceThrottle* throttle = |
290 user_script_listener_->CreateResourceThrottle(request->url(), | 293 user_script_listener_->CreateResourceThrottle(request->url(), |
291 resource_type); | 294 resource_type); |
292 if (throttle) | 295 if (throttle) |
293 throttles->push_back(throttle); | 296 throttles->push_back(throttle); |
294 } | 297 } |
295 | 298 |
| 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 |
296 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( | 321 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( |
297 const GURL& url, const std::string& mime_type) { | 322 const GURL& url, const std::string& mime_type) { |
298 // Special-case user scripts to get downloaded instead of viewed. | 323 // Special-case user scripts to get downloaded instead of viewed. |
299 return UserScript::IsURLUserScript(url, mime_type); | 324 return UserScript::IsURLUserScript(url, mime_type); |
300 } | 325 } |
301 | 326 |
302 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 327 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
303 net::URLRequest* request, | 328 net::URLRequest* request, |
304 content::ResourceResponse* response, | 329 content::ResourceResponse* response, |
305 IPC::Message::Sender* sender) { | 330 IPC::Message::Sender* sender) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 362 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
338 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 363 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
339 | 364 |
340 // See if the response contains the Google-Accounts-SignIn header. If so, | 365 // See if the response contains the Google-Accounts-SignIn header. If so, |
341 // then the user has just finished signing in, and the server is allowing the | 366 // then the user has just finished signing in, and the server is allowing the |
342 // browser to suggest connecting the user's profile to the account. | 367 // browser to suggest connecting the user's profile to the account. |
343 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(), | 368 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(), |
344 info->GetRouteID()); | 369 info->GetRouteID()); |
345 #endif | 370 #endif |
346 } | 371 } |
OLD | NEW |