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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/download/download_stats.h" | 8 #include "chrome/browser/download/download_stats.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/resource_controller.h" | 10 #include "content/public/browser/resource_controller.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 void CanDownload( | 30 void CanDownload( |
31 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { | 31 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { |
32 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 32 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
33 info->limiter->CanDownload(info->render_process_id, info->render_view_id, | 33 info->limiter->CanDownload(info->render_process_id, info->render_view_id, |
34 info->url, info->request_method, | 34 info->url, info->request_method, |
35 info->continue_callback); | 35 info->continue_callback); |
36 } | 36 } |
37 | 37 |
38 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) && !defined(USE_AURA) |
39 void OnAcquireFileAccessPermissionDone( | 39 void OnAcquireFileAccessPermissionDone( |
40 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info, | 40 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info, |
41 bool granted) { | 41 bool granted) { |
42 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
43 if (granted) | 43 if (granted) |
44 CanDownload(info.Pass()); | 44 CanDownload(info.Pass()); |
45 else | 45 else |
46 info->continue_callback.Run(false); | 46 info->continue_callback.Run(false); |
47 } | 47 } |
48 #endif | 48 #endif |
49 | 49 |
50 void CanDownloadOnUIThread( | 50 void CanDownloadOnUIThread( |
51 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { | 51 scoped_ptr<DownloadResourceThrottle::DownloadRequestInfo> info) { |
52 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 52 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
53 #if defined(OS_ANDROID) | 53 #if defined(OS_ANDROID) && !defined(USE_AURA) |
54 int process_id = info->render_process_id; | 54 int process_id = info->render_process_id; |
55 int render_view_id = info->render_view_id; | 55 int render_view_id = info->render_view_id; |
56 content::DownloadControllerAndroid::Get()->AcquireFileAccessPermission( | 56 content::DownloadControllerAndroid::Get()->AcquireFileAccessPermission( |
57 process_id, render_view_id, base::Bind(&OnAcquireFileAccessPermissionDone, | 57 process_id, render_view_id, base::Bind(&OnAcquireFileAccessPermissionDone, |
58 base::Passed(info.Pass()))); | 58 base::Passed(info.Pass()))); |
59 #else | 59 #else |
60 CanDownload(info.Pass()); | 60 CanDownload(info.Pass()); |
61 #endif | 61 #endif |
62 } | 62 } |
63 | 63 |
(...skipping 84 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 |