Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/renderer_host/data_reduction_proxy_resource_throttle_android.cc

Issue 2241673002: Make UnsafeResource hold a WebContents getter instead of RenderFrame ids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
111 info->GetChildID(), info->GetRenderFrameID()));
112 } 112 }
113 113
114 const char* DataReductionProxyResourceThrottle::GetNameForLogging() const { 114 const char* DataReductionProxyResourceThrottle::GetNameForLogging() const {
115 return "DataReductionProxyResourceThrottle"; 115 return "DataReductionProxyResourceThrottle";
116 } 116 }
117 117
118 // static 118 // static
119 void DataReductionProxyResourceThrottle::StartDisplayingBlockingPage( 119 void DataReductionProxyResourceThrottle::StartDisplayingBlockingPage(
120 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle, 120 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle,
121 scoped_refptr<SafeBrowsingUIManager> ui_manager, 121 scoped_refptr<SafeBrowsingUIManager> ui_manager,
122 const SafeBrowsingUIManager::UnsafeResource& resource) { 122 const SafeBrowsingUIManager::UnsafeResource& resource,
123 int child_id,
124 int render_frame_id) {
jam 2016/08/15 19:49:10 ditto
scottmg 2016/08/15 19:57:18 Done.
123 DCHECK_CURRENTLY_ON(BrowserThread::UI); 125 DCHECK_CURRENTLY_ON(BrowserThread::UI);
124 126
125 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( 127 content::RenderFrameHost* rfh =
126 resource.render_process_host_id, resource.render_frame_id); 128 content::RenderFrameHost::FromID(child_id, render_frame_id);
127 if (rfh) { 129 if (rfh) {
128 content::WebContents* web_contents = 130 content::WebContents* web_contents = resource.web_contents_getter.Run();
129 content::WebContents::FromRenderFrameHost(rfh);
130 prerender::PrerenderContents* prerender_contents = 131 prerender::PrerenderContents* prerender_contents =
131 prerender::PrerenderContents::FromWebContents(web_contents); 132 prerender::PrerenderContents::FromWebContents(web_contents);
132 if (prerender_contents) { 133 if (prerender_contents) {
133 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); 134 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING);
134 content::BrowserThread::PostTask( 135 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
135 content::BrowserThread::IO, 136 base::Bind(resource.callback, false));
136 FROM_HERE,
137 base::Bind(resource.callback, false));
138 return; 137 return;
139 } 138 }
140 } 139 }
141 ui_manager->DisplayBlockingPage(resource); 140 ui_manager->DisplayBlockingPage(resource);
142 } 141 }
143 142
144 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO 143 // SafeBrowsingService::UrlCheckCallback implementation, called on the IO
145 // thread when the user has decided to proceed with the current request, or 144 // thread when the user has decided to proceed with the current request, or
146 // go back. 145 // go back.
147 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) { 146 void DataReductionProxyResourceThrottle::OnBlockingPageComplete(bool proceed) {
(...skipping 29 matching lines...) Expand all
177 return result; 176 return result;
178 } 177 }
179 178
180 void DataReductionProxyResourceThrottle::ResumeRequest() { 179 void DataReductionProxyResourceThrottle::ResumeRequest() {
181 CHECK(state_ == STATE_NONE); 180 CHECK(state_ == STATE_NONE);
182 181
183 // Inject the header before resuming the request. 182 // Inject the header before resuming the request.
184 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true); 183 request_->SetExtraRequestHeaderByName(kUnsafeUrlProceedHeader, "1", true);
185 controller()->Resume(); 184 controller()->Resume();
186 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698