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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 30 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
31 #include "chrome/browser/signin/chrome_signin_helper.h" | 31 #include "chrome/browser/signin/chrome_signin_helper.h" |
32 #include "chrome/browser/tab_contents/tab_util.h" | 32 #include "chrome/browser/tab_contents/tab_util.h" |
33 #include "chrome/browser/ui/login/login_prompt.h" | 33 #include "chrome/browser/ui/login/login_prompt.h" |
34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
35 #include "chrome/common/features.h" | 35 #include "chrome/common/features.h" |
36 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
37 #include "components/content_settings/core/browser/host_content_settings_map.h" | 37 #include "components/content_settings/core/browser/host_content_settings_map.h" |
38 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 38 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
39 #include "components/google/core/browser/google_util.h" | 39 #include "components/google/core/browser/google_util.h" |
40 #include "components/variations/net/variations_http_header_provider.h" | 40 #include "components/variations/net/variations_http_headers.h" |
41 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
43 #include "content/public/browser/plugin_service.h" | 43 #include "content/public/browser/plugin_service.h" |
44 #include "content/public/browser/plugin_service_filter.h" | 44 #include "content/public/browser/plugin_service_filter.h" |
45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
47 #include "content/public/browser/resource_context.h" | 47 #include "content/public/browser/resource_context.h" |
48 #include "content/public/browser/resource_dispatcher_host.h" | 48 #include "content/public/browser/resource_dispatcher_host.h" |
49 #include "content/public/browser/resource_request_info.h" | 49 #include "content/public/browser/resource_request_info.h" |
50 #include "content/public/browser/service_worker_context.h" | 50 #include "content/public/browser/service_worker_context.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } // namespace | 278 } // namespace |
279 | 279 |
280 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() | 280 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() |
281 : download_request_limiter_(g_browser_process->download_request_limiter()), | 281 : download_request_limiter_(g_browser_process->download_request_limiter()), |
282 safe_browsing_(g_browser_process->safe_browsing_service()) | 282 safe_browsing_(g_browser_process->safe_browsing_service()) |
283 #if defined(ENABLE_EXTENSIONS) | 283 #if defined(ENABLE_EXTENSIONS) |
284 , user_script_listener_(new extensions::UserScriptListener()) | 284 , user_script_listener_(new extensions::UserScriptListener()) |
285 #endif | 285 #endif |
286 { | 286 { |
287 BrowserThread::PostTask( | 287 BrowserThread::PostTask( |
288 BrowserThread::IO, | 288 BrowserThread::IO, FROM_HERE, |
289 FROM_HERE, | |
290 base::Bind(content::ServiceWorkerContext::AddExcludedHeadersForFetchEvent, | 289 base::Bind(content::ServiceWorkerContext::AddExcludedHeadersForFetchEvent, |
291 variations::VariationsHttpHeaderProvider::GetInstance() | 290 variations::GetVariationHeaderNames())); |
292 ->GetVariationHeaderNames())); | |
293 } | 291 } |
294 | 292 |
295 ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() { | 293 ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() { |
296 #if defined(ENABLE_EXTENSIONS) | 294 #if defined(ENABLE_EXTENSIONS) |
297 CHECK(stream_target_info_.empty()); | 295 CHECK(stream_target_info_.empty()); |
298 #endif | 296 #endif |
299 } | 297 } |
300 | 298 |
301 bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest( | 299 bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest( |
302 const std::string& method, | 300 const std::string& method, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 362 } |
365 #endif | 363 #endif |
366 | 364 |
367 // Don't attempt to append headers to requests that have already started. | 365 // Don't attempt to append headers to requests that have already started. |
368 // TODO(stevet): Remove this once the request ordering issues are resolved | 366 // TODO(stevet): Remove this once the request ordering issues are resolved |
369 // in crbug.com/128048. | 367 // in crbug.com/128048. |
370 if (!request->is_pending()) { | 368 if (!request->is_pending()) { |
371 net::HttpRequestHeaders headers; | 369 net::HttpRequestHeaders headers; |
372 headers.CopyFrom(request->extra_request_headers()); | 370 headers.CopyFrom(request->extra_request_headers()); |
373 bool is_off_the_record = io_data->IsOffTheRecord(); | 371 bool is_off_the_record = io_data->IsOffTheRecord(); |
374 variations::VariationsHttpHeaderProvider::GetInstance()-> | 372 variations::AppendVariationHeaders( |
375 AppendHeaders(request->url(), | 373 request->url(), is_off_the_record, |
376 is_off_the_record, | 374 !is_off_the_record && io_data->GetMetricsEnabledStateOnIOThread(), |
377 !is_off_the_record && | 375 &headers); |
378 io_data->GetMetricsEnabledStateOnIOThread(), | |
379 &headers); | |
380 request->SetExtraRequestHeaders(headers); | 376 request->SetExtraRequestHeaders(headers); |
381 } | 377 } |
382 | 378 |
383 #if defined(ENABLE_CONFIGURATION_POLICY) | 379 #if defined(ENABLE_CONFIGURATION_POLICY) |
384 if (io_data->policy_header_helper()) | 380 if (io_data->policy_header_helper()) |
385 io_data->policy_header_helper()->AddPolicyHeaders(request->url(), request); | 381 io_data->policy_header_helper()->AddPolicyHeaders(request->url(), request); |
386 #endif | 382 #endif |
387 | 383 |
388 signin::AppendMirrorRequestHeaderHelper(request, GURL() /* redirect_url */, | 384 signin::AppendMirrorRequestHeaderHelper(request, GURL() /* redirect_url */, |
389 io_data, info->GetChildID(), | 385 io_data, info->GetChildID(), |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); | 739 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); |
744 return false; | 740 return false; |
745 } | 741 } |
746 | 742 |
747 // static | 743 // static |
748 void ChromeResourceDispatcherHostDelegate:: | 744 void ChromeResourceDispatcherHostDelegate:: |
749 SetExternalProtocolHandlerDelegateForTesting( | 745 SetExternalProtocolHandlerDelegateForTesting( |
750 ExternalProtocolHandler::Delegate* delegate) { | 746 ExternalProtocolHandler::Delegate* delegate) { |
751 g_external_protocol_handler_delegate = delegate; | 747 g_external_protocol_handler_delegate = delegate; |
752 } | 748 } |
OLD | NEW |