OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
6 | 6 |
7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 806 |
807 rdh->BeginDownload(url, | 807 rdh->BeginDownload(url, |
808 referrer, | 808 referrer, |
809 save_info, | 809 save_info, |
810 true, // Show "Save as" UI. | 810 true, // Show "Save as" UI. |
811 render_process_host_id, | 811 render_process_host_id, |
812 render_view_id, | 812 render_view_id, |
813 context); | 813 context); |
814 } | 814 } |
815 | 815 |
816 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | 816 static void CancelDownloadRequestOnIOThread( |
817 int render_process_id, | 817 ResourceDispatcherHost* rdh, DownloadProcessHandle process_handle) { |
818 int request_id) { | |
819 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 818 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
820 // |rdh| may be NULL in unit tests. | 819 // |rdh| may be NULL in unit tests. |
821 if (rdh) | 820 if (!rdh) |
822 rdh->CancelRequest(render_process_id, request_id, false); | 821 return; |
| 822 |
| 823 rdh->CancelRequest(process_handle.child_id(), |
| 824 process_handle.request_id(), |
| 825 false); |
| 826 } |
| 827 |
| 828 void CancelDownloadRequest(ResourceDispatcherHost* rdh, |
| 829 DownloadProcessHandle process_handle) { |
| 830 BrowserThread::PostTask( |
| 831 BrowserThread::IO, FROM_HERE, |
| 832 NewRunnableFunction(&download_util::CancelDownloadRequestOnIOThread, |
| 833 rdh, process_handle)); |
823 } | 834 } |
824 | 835 |
825 void NotifyDownloadInitiated(int render_process_id, int render_view_id) { | 836 void NotifyDownloadInitiated(int render_process_id, int render_view_id) { |
826 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 837 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
827 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, | 838 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, |
828 render_view_id); | 839 render_view_id); |
829 if (!rvh) | 840 if (!rvh) |
830 return; | 841 return; |
831 | 842 |
832 NotificationService::current()->Notify(NotificationType::DOWNLOAD_INITIATED, | 843 NotificationService::current()->Notify(NotificationType::DOWNLOAD_INITIATED, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 // Extensions that are not from the gallery are considered dangerous. | 905 // Extensions that are not from the gallery are considered dangerous. |
895 ExtensionService* service = profile->GetExtensionService(); | 906 ExtensionService* service = profile->GetExtensionService(); |
896 if (!service || | 907 if (!service || |
897 !service->IsDownloadFromGallery(info->url(), info->referrer_url)) | 908 !service->IsDownloadFromGallery(info->url(), info->referrer_url)) |
898 return true; | 909 return true; |
899 } | 910 } |
900 return false; | 911 return false; |
901 } | 912 } |
902 | 913 |
903 } // namespace download_util | 914 } // namespace download_util |
OLD | NEW |