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" |
11 #include "base/command_line.h" | |
11 #include "base/guid.h" | 12 #include "base/guid.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " | 16 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " |
16 #include "chrome/browser/download/download_request_limiter.h" | 17 #include "chrome/browser/download/download_request_limiter.h" |
17 #include "chrome/browser/download/download_resource_throttle.h" | 18 #include "chrome/browser/download/download_resource_throttle.h" |
18 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" | 19 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" |
19 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 20 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
20 #include "chrome/browser/plugins/plugin_prefs.h" | 21 #include "chrome/browser/plugins/plugin_prefs.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
43 #include "content/public/browser/plugin_service.h" | 44 #include "content/public/browser/plugin_service.h" |
44 #include "content/public/browser/plugin_service_filter.h" | 45 #include "content/public/browser/plugin_service_filter.h" |
45 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
47 #include "content/public/browser/resource_context.h" | 48 #include "content/public/browser/resource_context.h" |
48 #include "content/public/browser/resource_dispatcher_host.h" | 49 #include "content/public/browser/resource_dispatcher_host.h" |
49 #include "content/public/browser/resource_request_info.h" | 50 #include "content/public/browser/resource_request_info.h" |
50 #include "content/public/browser/service_worker_context.h" | 51 #include "content/public/browser/service_worker_context.h" |
51 #include "content/public/browser/stream_info.h" | 52 #include "content/public/browser/stream_info.h" |
52 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
54 #include "content/public/common/content_switches.h" | |
53 #include "content/public/common/resource_response.h" | 55 #include "content/public/common/resource_response.h" |
54 #include "net/base/load_flags.h" | 56 #include "net/base/load_flags.h" |
55 #include "net/base/load_timing_info.h" | 57 #include "net/base/load_timing_info.h" |
56 #include "net/base/request_priority.h" | 58 #include "net/base/request_priority.h" |
57 #include "net/http/http_response_headers.h" | 59 #include "net/http/http_response_headers.h" |
58 #include "net/url_request/url_request.h" | 60 #include "net/url_request/url_request.h" |
59 | 61 |
60 #if !defined(DISABLE_NACL) | 62 #if !defined(DISABLE_NACL) |
61 #include "chrome/browser/component_updater/pnacl_component_installer.h" | 63 #include "chrome/browser/component_updater/pnacl_component_installer.h" |
62 #endif | 64 #endif |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 if (prerender_contents) | 169 if (prerender_contents) |
168 prerender_contents->AddNetworkBytes(bytes); | 170 prerender_contents->AddNetworkBytes(bytes); |
169 | 171 |
170 prerender::PrerenderManager* prerender_manager = | 172 prerender::PrerenderManager* prerender_manager = |
171 GetPrerenderManager(render_process_id, render_view_id); | 173 GetPrerenderManager(render_process_id, render_view_id); |
172 if (prerender_manager) | 174 if (prerender_manager) |
173 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes); | 175 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes); |
174 } | 176 } |
175 | 177 |
176 #if defined(ENABLE_EXTENSIONS) | 178 #if defined(ENABLE_EXTENSIONS) |
177 void SendExecuteMimeTypeHandlerEvent(scoped_ptr<content::StreamInfo> stream, | 179 void SendExecuteMimeTypeHandlerEvent( |
178 int64 expected_content_size, | 180 scoped_ptr<content::StreamInfo> stream, |
179 int render_process_id, | 181 int64 expected_content_size, |
180 int render_frame_id, | 182 const ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
181 const std::string& extension_id, | 183 int render_process_id, |
182 const std::string& view_id, | 184 int render_frame_id, |
183 bool embedded) { | 185 const std::string& extension_id, |
186 const std::string& view_id, | |
187 bool embedded) { | |
184 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 188 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
185 | 189 |
186 content::WebContents* web_contents = | 190 content::WebContents* web_contents = web_contents_getter.Run(); |
187 tab_util::GetWebContentsByFrameID(render_process_id, render_frame_id); | |
188 if (!web_contents) | 191 if (!web_contents) |
189 return; | 192 return; |
190 | 193 |
194 // TODO(clamy): update this code for PlzNavigate when extensions have | |
195 // switched to FrameTreeNode IDs, so that unclaimed streams are not leaked. | |
davidben
2015/12/09 23:53:44
Probably worth a bug number?
| |
196 DCHECK((render_process_id != -1 && render_frame_id != -1) || | |
197 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
198 switches::kEnableBrowserSideNavigation)); | |
199 | |
191 // If the request was for a prerender, abort the prerender and do not | 200 // If the request was for a prerender, abort the prerender and do not |
192 // continue. | 201 // continue. |
193 prerender::PrerenderContents* prerender_contents = | 202 prerender::PrerenderContents* prerender_contents = |
194 prerender::PrerenderContents::FromWebContents(web_contents); | 203 prerender::PrerenderContents::FromWebContents(web_contents); |
195 if (prerender_contents) { | 204 if (prerender_contents) { |
196 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD); | 205 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD); |
197 return; | 206 return; |
198 } | 207 } |
199 | 208 |
200 Profile* profile = | 209 Profile* profile = |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 scoped_ptr<content::StreamInfo> stream) { | 628 scoped_ptr<content::StreamInfo> stream) { |
620 #if defined(ENABLE_EXTENSIONS) | 629 #if defined(ENABLE_EXTENSIONS) |
621 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 630 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
622 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = | 631 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = |
623 stream_target_info_.find(request); | 632 stream_target_info_.find(request); |
624 CHECK(ix != stream_target_info_.end()); | 633 CHECK(ix != stream_target_info_.end()); |
625 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; | 634 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; |
626 content::BrowserThread::PostTask( | 635 content::BrowserThread::PostTask( |
627 content::BrowserThread::UI, FROM_HERE, | 636 content::BrowserThread::UI, FROM_HERE, |
628 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), | 637 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), |
629 request->GetExpectedContentSize(), info->GetChildID(), | 638 request->GetExpectedContentSize(), |
639 info->GetWebContentsGetterForRequest(), info->GetChildID(), | |
630 info->GetRenderFrameID(), ix->second.extension_id, | 640 info->GetRenderFrameID(), ix->second.extension_id, |
631 ix->second.view_id, embedded)); | 641 ix->second.view_id, embedded)); |
632 stream_target_info_.erase(request); | 642 stream_target_info_.erase(request); |
633 #endif | 643 #endif |
634 } | 644 } |
635 | 645 |
636 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 646 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
637 net::URLRequest* request, | 647 net::URLRequest* request, |
638 content::ResourceContext* resource_context, | 648 content::ResourceContext* resource_context, |
639 content::ResourceResponse* response, | 649 content::ResourceResponse* response, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); | 749 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); |
740 return false; | 750 return false; |
741 } | 751 } |
742 | 752 |
743 // static | 753 // static |
744 void ChromeResourceDispatcherHostDelegate:: | 754 void ChromeResourceDispatcherHostDelegate:: |
745 SetExternalProtocolHandlerDelegateForTesting( | 755 SetExternalProtocolHandlerDelegateForTesting( |
746 ExternalProtocolHandler::Delegate* delegate) { | 756 ExternalProtocolHandler::Delegate* delegate) { |
747 g_external_protocol_handler_delegate = delegate; | 757 g_external_protocol_handler_delegate = delegate; |
748 } | 758 } |
OLD | NEW |