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

Side by Side Diff: chrome/browser/android/download/download_controller.cc

Issue 2642683005: reintroduce InterceptDownloadResourceThrottle for some OMA DRM downloads (Closed)
Patch Set: function name change to avoid findbugs confusion Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/android/download/download_controller.h" 5 #include "chrome/browser/android/download/download_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/context_utils.h" 10 #include "base/android/context_utils.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 BrowserThread::UI, FROM_HERE, base::Bind(cb, true)); 212 BrowserThread::UI, FROM_HERE, base::Bind(cb, true));
213 return; 213 return;
214 } 214 }
215 // Make copy on the heap so we can pass the pointer through JNI. 215 // Make copy on the heap so we can pass the pointer through JNI.
216 intptr_t callback_id = reinterpret_cast<intptr_t>( 216 intptr_t callback_id = reinterpret_cast<intptr_t>(
217 new DownloadControllerBase::AcquireFileAccessPermissionCallback(cb)); 217 new DownloadControllerBase::AcquireFileAccessPermissionCallback(cb));
218 ChromeDownloadDelegate::FromWebContents(web_contents)-> 218 ChromeDownloadDelegate::FromWebContents(web_contents)->
219 RequestFileAccess(callback_id); 219 RequestFileAccess(callback_id);
220 } 220 }
221 221
222 void DownloadController::CreateAndroidDownload(
223 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
224 const DownloadInfo& info) {
225 DCHECK_CURRENTLY_ON(BrowserThread::IO);
226
227 BrowserThread::PostTask(
228 BrowserThread::UI, FROM_HERE,
229 base::Bind(&DownloadController::StartAndroidDownload,
230 base::Unretained(this),
231 wc_getter, info));
232 }
233
234 void DownloadController::StartAndroidDownload(
235 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
236 const DownloadInfo& info) {
237 DCHECK_CURRENTLY_ON(BrowserThread::UI);
238
239 WebContents* web_contents = wc_getter.Run();
240 if (!web_contents) {
241 // The view went away. Can't proceed.
242 LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec();
243 return;
244 }
245
246 AcquireFileAccessPermission(
247 web_contents,
248 base::Bind(&DownloadController::StartAndroidDownloadInternal,
249 base::Unretained(this), wc_getter, info));
250 }
251
252 void DownloadController::StartAndroidDownloadInternal(
253 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
254 const DownloadInfo& info, bool allowed) {
255 DCHECK_CURRENTLY_ON(BrowserThread::UI);
256 if (!allowed)
257 return;
258
259 WebContents* web_contents = wc_getter.Run();
260 if (!web_contents) {
261 // The view went away. Can't proceed.
262 LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec();
263 return;
264 }
265
266 ChromeDownloadDelegate::FromWebContents(web_contents)->
267 EnqueueDownloadManagerRequest(
268 info.url.spec(), info.user_agent,
269 info.content_disposition, info.original_mime_type,
270 info.cookie, info.referer);
271 }
272
222 bool DownloadController::HasFileAccessPermission( 273 bool DownloadController::HasFileAccessPermission(
223 ui::WindowAndroid* window_android) { 274 ui::WindowAndroid* window_android) {
224 ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject(); 275 ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject();
225 276
226 DCHECK_CURRENTLY_ON(BrowserThread::UI); 277 DCHECK_CURRENTLY_ON(BrowserThread::UI);
227 DCHECK(!jwindow_android.is_null()); 278 DCHECK(!jwindow_android.is_null());
228 279
229 JNIEnv* env = base::android::AttachCurrentThread(); 280 JNIEnv* env = base::android::AttachCurrentThread();
230 return Java_DownloadController_hasFileAccess( 281 return Java_DownloadController_hasFileAccess(
231 env, GetJavaObject()->Controller(env), jwindow_android); 282 env, GetJavaObject()->Controller(env), jwindow_android);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 void DownloadController::StartContextMenuDownload( 380 void DownloadController::StartContextMenuDownload(
330 const ContextMenuParams& params, WebContents* web_contents, bool is_link, 381 const ContextMenuParams& params, WebContents* web_contents, bool is_link,
331 const std::string& extra_headers) { 382 const std::string& extra_headers) {
332 int process_id = web_contents->GetRenderProcessHost()->GetID(); 383 int process_id = web_contents->GetRenderProcessHost()->GetID();
333 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); 384 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID();
334 AcquireFileAccessPermission( 385 AcquireFileAccessPermission(
335 web_contents, base::Bind(&CreateContextMenuDownload, process_id, 386 web_contents, base::Bind(&CreateContextMenuDownload, process_id,
336 routing_id, params, is_link, extra_headers)); 387 routing_id, params, is_link, extra_headers));
337 } 388 }
338 389
OLDNEW
« no previous file with comments | « chrome/browser/android/download/download_controller.h ('k') | chrome/browser/android/download/download_controller_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698