| 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" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 info->limiter->CanDownload(info->web_contents_getter, info->url, | 36 info->limiter->CanDownload(info->web_contents_getter, info->url, |
| 37 info->request_method, info->continue_callback); | 37 info->request_method, info->continue_callback); |
| 38 } | 38 } |
| 39 | 39 |
| 40 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
| 41 void OnAcquireFileAccessPermissionDone( | 41 void OnAcquireFileAccessPermissionDone( |
| 42 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info, | 42 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info, |
| 43 bool granted) { | 43 bool granted) { |
| 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 45 if (granted) | 45 if (granted) |
| 46 CanDownload(info.Pass()); | 46 CanDownload(std::move(info)); |
| 47 else | 47 else |
| 48 info->continue_callback.Run(false); | 48 info->continue_callback.Run(false); |
| 49 } | 49 } |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 void CanDownloadOnUIThread( | 52 void CanDownloadOnUIThread( |
| 53 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { | 53 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { |
| 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 55 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
| 56 content::WebContents* contents = info->web_contents_getter.Run(); | 56 content::WebContents* contents = info->web_contents_getter.Run(); |
| 57 if (!contents) | 57 if (!contents) |
| 58 OnAcquireFileAccessPermissionDone(info.Pass(), false); | 58 OnAcquireFileAccessPermissionDone(std::move(info), false); |
| 59 content::DownloadControllerAndroid::Get()->AcquireFileAccessPermission( | 59 content::DownloadControllerAndroid::Get()->AcquireFileAccessPermission( |
| 60 contents, base::Bind(&OnAcquireFileAccessPermissionDone, | 60 contents, base::Bind(&OnAcquireFileAccessPermissionDone, |
| 61 base::Passed(info.Pass()))); | 61 base::Passed(std::move(info)))); |
| 62 #else | 62 #else |
| 63 CanDownload(std::move(info)); | 63 CanDownload(std::move(info)); |
| 64 #endif | 64 #endif |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 DownloadResourceThrottle::DownloadRequestInfo::DownloadRequestInfo( | 69 DownloadResourceThrottle::DownloadRequestInfo::DownloadRequestInfo( |
| 70 scoped_refptr<DownloadRequestLimiter> limiter, | 70 scoped_refptr<DownloadRequestLimiter> limiter, |
| 71 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 71 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 if (request_deferred_) { | 149 if (request_deferred_) { |
| 150 request_deferred_ = false; | 150 request_deferred_ = false; |
| 151 if (allow) { | 151 if (allow) { |
| 152 controller()->Resume(); | 152 controller()->Resume(); |
| 153 } else { | 153 } else { |
| 154 controller()->Cancel(); | 154 controller()->Cancel(); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |