| 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/download/download_resource_throttle.h" | 5 #include "chrome/browser/download/download_resource_throttle.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/download/download_stats.h" | 11 #include "chrome/browser/download/download_stats.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/resource_controller.h" | 13 #include "content/public/browser/resource_controller.h" |
| 14 | 14 |
| 15 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
| 16 #include "content/public/browser/android/download_controller_android.h" | 16 #include "chrome/browser/android/download/download_controller_base.h" |
| 17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 18 | |
| 19 using content::DownloadControllerAndroid; | |
| 20 #endif | 18 #endif |
| 21 | 19 |
| 22 using content::BrowserThread; | 20 using content::BrowserThread; |
| 23 | 21 |
| 24 namespace { | 22 namespace { |
| 25 | 23 |
| 26 void OnCanDownloadDecided(base::WeakPtr<DownloadResourceThrottle> throttle, | 24 void OnCanDownloadDecided(base::WeakPtr<DownloadResourceThrottle> throttle, |
| 27 bool allow) { | 25 bool allow) { |
| 28 BrowserThread::PostTask( | 26 BrowserThread::PostTask( |
| 29 BrowserThread::IO, FROM_HERE, | 27 BrowserThread::IO, FROM_HERE, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 info->continue_callback.Run(false); | 46 info->continue_callback.Run(false); |
| 49 } | 47 } |
| 50 #endif | 48 #endif |
| 51 | 49 |
| 52 void CanDownloadOnUIThread( | 50 void CanDownloadOnUIThread( |
| 53 std::unique_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { | 51 std::unique_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { |
| 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 52 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 55 #if defined(OS_ANDROID) | 53 #if defined(OS_ANDROID) |
| 56 content::WebContents* contents = info->web_contents_getter.Run(); | 54 content::WebContents* contents = info->web_contents_getter.Run(); |
| 57 if (contents) { | 55 if (contents) { |
| 58 content::DownloadControllerAndroid::Get()->AcquireFileAccessPermission( | 56 DownloadControllerBase::Get()->AcquireFileAccessPermission( |
| 59 contents, base::Bind(&OnAcquireFileAccessPermissionDone, | 57 contents, base::Bind(&OnAcquireFileAccessPermissionDone, |
| 60 base::Passed(std::move(info)))); | 58 base::Passed(std::move(info)))); |
| 61 } else { | 59 } else { |
| 62 OnAcquireFileAccessPermissionDone(std::move(info), false); | 60 OnAcquireFileAccessPermissionDone(std::move(info), false); |
| 63 } | 61 } |
| 64 #else | 62 #else |
| 65 CanDownload(std::move(info)); | 63 CanDownload(std::move(info)); |
| 66 #endif | 64 #endif |
| 67 } | 65 } |
| 68 | 66 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 148 |
| 151 if (request_deferred_) { | 149 if (request_deferred_) { |
| 152 request_deferred_ = false; | 150 request_deferred_ = false; |
| 153 if (allow) { | 151 if (allow) { |
| 154 controller()->Resume(); | 152 controller()->Resume(); |
| 155 } else { | 153 } else { |
| 156 controller()->Cancel(); | 154 controller()->Cancel(); |
| 157 } | 155 } |
| 158 } | 156 } |
| 159 } | 157 } |
| OLD | NEW |