| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/data_reduction_proxy_resource_throttle_an
droid.h" | 5 #include "chrome/browser/renderer_host/data_reduction_proxy_resource_throttle_an
droid.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/prerender/prerender_contents.h" | 9 #include "chrome/browser/prerender/prerender_contents.h" |
| 10 #include "chrome/browser/profiles/profile_io_data.h" | 10 #include "chrome/browser/profiles/profile_io_data.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 unsafe_resource.original_url = request_->original_url(); | 91 unsafe_resource.original_url = request_->original_url(); |
| 92 unsafe_resource.redirect_urls = redirect_urls_; | 92 unsafe_resource.redirect_urls = redirect_urls_; |
| 93 unsafe_resource.is_subresource = is_subresource_; | 93 unsafe_resource.is_subresource = is_subresource_; |
| 94 unsafe_resource.is_subframe = is_subframe_; | 94 unsafe_resource.is_subframe = is_subframe_; |
| 95 unsafe_resource.threat_type = threat_type; | 95 unsafe_resource.threat_type = threat_type; |
| 96 unsafe_resource.callback = base::Bind( | 96 unsafe_resource.callback = base::Bind( |
| 97 &DataReductionProxyResourceThrottle::OnBlockingPageComplete, AsWeakPtr()); | 97 &DataReductionProxyResourceThrottle::OnBlockingPageComplete, AsWeakPtr()); |
| 98 unsafe_resource.callback_thread = | 98 unsafe_resource.callback_thread = |
| 99 content::BrowserThread::GetTaskRunnerForThread( | 99 content::BrowserThread::GetTaskRunnerForThread( |
| 100 content::BrowserThread::IO); | 100 content::BrowserThread::IO); |
| 101 unsafe_resource.render_process_host_id = info->GetChildID(); | 101 unsafe_resource.web_contents_getter = info->GetWebContentsGetterForRequest(); |
| 102 unsafe_resource.render_frame_id = info->GetRenderFrameID(); | |
| 103 unsafe_resource.threat_source = safe_browsing::ThreatSource::DATA_SAVER; | 102 unsafe_resource.threat_source = safe_browsing::ThreatSource::DATA_SAVER; |
| 104 | 103 |
| 105 *defer = true; | 104 *defer = true; |
| 106 | 105 |
| 107 content::BrowserThread::PostTask( | 106 content::BrowserThread::PostTask( |
| 108 content::BrowserThread::UI, FROM_HERE, | 107 content::BrowserThread::UI, FROM_HERE, |
| 109 base::Bind( | 108 base::Bind( |
| 110 &DataReductionProxyResourceThrottle::StartDisplayingBlockingPage, | 109 &DataReductionProxyResourceThrottle::StartDisplayingBlockingPage, |
| 111 AsWeakPtr(), safe_browsing_->ui_manager(), unsafe_resource)); | 110 AsWeakPtr(), safe_browsing_->ui_manager(), unsafe_resource)); |
| 112 } | 111 } |
| 113 | 112 |
| 114 const char* DataReductionProxyResourceThrottle::GetNameForLogging() const { | 113 const char* DataReductionProxyResourceThrottle::GetNameForLogging() const { |
| 115 return "DataReductionProxyResourceThrottle"; | 114 return "DataReductionProxyResourceThrottle"; |
| 116 } | 115 } |
| 117 | 116 |
| 118 // static | 117 // static |
| 119 void DataReductionProxyResourceThrottle::StartDisplayingBlockingPage( | 118 void DataReductionProxyResourceThrottle::StartDisplayingBlockingPage( |
| 120 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle, | 119 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle, |
| 121 scoped_refptr<SafeBrowsingUIManager> ui_manager, | 120 scoped_refptr<SafeBrowsingUIManager> ui_manager, |
| 122 const SafeBrowsingUIManager::UnsafeResource& resource) { | 121 const SafeBrowsingUIManager::UnsafeResource& resource) { |
| 123 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 122 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 124 | 123 |
| 125 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 124 content::WebContents* web_contents = resource.web_contents_getter.Run(); |
| 126 resource.render_process_host_id, resource.render_frame_id); | 125 if (web_contents) { |
| 127 if (rfh) { | |
| 128 content::WebContents* web_contents = | |
| 129 content::WebContents::FromRenderFrameHost(rfh); | |
| 130 prerender::PrerenderContents* prerender_contents = | 126 prerender::PrerenderContents* prerender_contents = |
| 131 prerender::PrerenderContents::FromWebContents(web_contents); | 127 prerender::PrerenderContents::FromWebContents(web_contents); |
| 132 if (prerender_contents) { | 128 if (prerender_contents) { |
| 133 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); | 129 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); |
| 134 content::BrowserThread::PostTask( | 130 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 135 content::BrowserThread::IO, | 131 base::Bind(resource.callback, false)); |
| 136 FROM_HERE, | |
| 137 base::Bind(resource.callback, false)); | |
| 138 return; | 132 return; |
| 139 } | 133 } |
| 140 } | 134 } |
| 141 ui_manager->DisplayBlockingPage(resource); | 135 ui_manager->DisplayBlockingPage(resource); |
| 142 } | 136 } |
| 143 | 137 |
| 144 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO | 138 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO |
| 145 // thread when the user has decided to proceed with the current request, or | 139 // thread when the user has decided to proceed with the current request, or |
| 146 // go back. | 140 // go back. |
| 147 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) { | 141 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 177 return result; | 171 return result; |
| 178 } | 172 } |
| 179 | 173 |
| 180 void DataReductionProxyResourceThrottle::ResumeRequest() { | 174 void DataReductionProxyResourceThrottle::ResumeRequest() { |
| 181 CHECK(state_ == STATE_NONE); | 175 CHECK(state_ == STATE_NONE); |
| 182 | 176 |
| 183 // Inject the header before resuming the request. | 177 // Inject the header before resuming the request. |
| 184 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); | 178 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); |
| 185 controller()->Resume(); | 179 controller()->Resume(); |
| 186 } | 180 } |
| OLD | NEW |