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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/download/download_controller.cc
diff --git a/chrome/browser/android/download/download_controller.cc b/chrome/browser/android/download/download_controller.cc
index c77b0f282df2296204a05c8ee2f9d44748d1b436..2d604abea4c7b5d6c778407259b3fd92e182ba46 100644
--- a/chrome/browser/android/download/download_controller.cc
+++ b/chrome/browser/android/download/download_controller.cc
@@ -219,6 +219,57 @@ void DownloadController::AcquireFileAccessPermission(
RequestFileAccess(callback_id);
}
+void DownloadController::CreateAndroidDownload(
+ const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
+ const DownloadInfo& info) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadController::StartAndroidDownload,
+ base::Unretained(this),
+ wc_getter, info));
+}
+
+void DownloadController::StartAndroidDownload(
+ const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
+ const DownloadInfo& info) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ WebContents* web_contents = wc_getter.Run();
+ if (!web_contents) {
+ // The view went away. Can't proceed.
+ LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec();
+ return;
+ }
+
+ AcquireFileAccessPermission(
+ web_contents,
+ base::Bind(&DownloadController::StartAndroidDownloadInternal,
+ base::Unretained(this), wc_getter, info));
+}
+
+void DownloadController::StartAndroidDownloadInternal(
+ const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
+ const DownloadInfo& info, bool allowed) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (!allowed)
+ return;
+
+ WebContents* web_contents = wc_getter.Run();
+ if (!web_contents) {
+ // The view went away. Can't proceed.
+ LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec();
+ return;
+ }
+
+ ChromeDownloadDelegate::FromWebContents(web_contents)->
+ EnqueueDownloadManagerRequest(
+ info.url.spec(), info.user_agent,
+ info.content_disposition, info.original_mime_type,
+ info.cookie, info.referer);
+}
+
bool DownloadController::HasFileAccessPermission(
ui::WindowAndroid* window_android) {
ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject();
« 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