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