| 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 17 matching lines...) Expand all Loading... |
| 28 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 29 #include "chrome/browser/download/download_extensions.h" | 29 #include "chrome/browser/download/download_extensions.h" |
| 30 #include "chrome/browser/download/download_item.h" | 30 #include "chrome/browser/download/download_item.h" |
| 31 #include "chrome/browser/download/download_item_model.h" | 31 #include "chrome/browser/download/download_item_model.h" |
| 32 #include "chrome/browser/download/download_manager.h" | 32 #include "chrome/browser/download/download_manager.h" |
| 33 #include "chrome/browser/download/download_types.h" | 33 #include "chrome/browser/download/download_types.h" |
| 34 #include "chrome/browser/extensions/crx_installer.h" | 34 #include "chrome/browser/extensions/crx_installer.h" |
| 35 #include "chrome/browser/extensions/extension_install_ui.h" | 35 #include "chrome/browser/extensions/extension_install_ui.h" |
| 36 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
| 37 #include "chrome/browser/history/download_create_info.h" | 37 #include "chrome/browser/history/download_create_info.h" |
| 38 #include "chrome/browser/net/chrome_url_request_context.h" | |
| 39 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
| 40 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/common/chrome_paths.h" | 40 #include "chrome/common/chrome_paths.h" |
| 42 #include "chrome/common/time_format.h" | 41 #include "chrome/common/time_format.h" |
| 43 #include "content/browser/browser_thread.h" | 42 #include "content/browser/browser_thread.h" |
| 44 #include "content/browser/renderer_host/render_view_host.h" | 43 #include "content/browser/renderer_host/render_view_host.h" |
| 45 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 44 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 46 #include "content/browser/tab_contents/tab_contents.h" | 45 #include "content/browser/tab_contents/tab_contents.h" |
| 47 #include "content/common/notification_service.h" | 46 #include "content/common/notification_service.h" |
| 48 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 } | 790 } |
| 792 | 791 |
| 793 void DownloadUrl( | 792 void DownloadUrl( |
| 794 const GURL& url, | 793 const GURL& url, |
| 795 const GURL& referrer, | 794 const GURL& referrer, |
| 796 const std::string& referrer_charset, | 795 const std::string& referrer_charset, |
| 797 const DownloadSaveInfo& save_info, | 796 const DownloadSaveInfo& save_info, |
| 798 ResourceDispatcherHost* rdh, | 797 ResourceDispatcherHost* rdh, |
| 799 int render_process_host_id, | 798 int render_process_host_id, |
| 800 int render_view_id, | 799 int render_view_id, |
| 801 net::URLRequestContextGetter* request_context_getter) { | 800 const content::ResourceContext* context) { |
| 802 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 803 | 802 |
| 804 net::URLRequestContext* context = | |
| 805 request_context_getter->GetURLRequestContext(); | |
| 806 context->set_referrer_charset(referrer_charset); | |
| 807 | |
| 808 rdh->BeginDownload(url, | 803 rdh->BeginDownload(url, |
| 809 referrer, | 804 referrer, |
| 810 save_info, | 805 save_info, |
| 811 true, // Show "Save as" UI. | 806 true, // Show "Save as" UI. |
| 812 render_process_host_id, | 807 render_process_host_id, |
| 813 render_view_id, | 808 render_view_id, |
| 814 context); | 809 *context); |
| 815 } | 810 } |
| 816 | 811 |
| 817 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | 812 void CancelDownloadRequest(ResourceDispatcherHost* rdh, |
| 818 int render_process_id, | 813 int render_process_id, |
| 819 int request_id) { | 814 int request_id) { |
| 820 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 815 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 821 // |rdh| may be NULL in unit tests. | 816 // |rdh| may be NULL in unit tests. |
| 822 if (rdh) | 817 if (rdh) |
| 823 rdh->CancelRequest(render_process_id, request_id, false); | 818 rdh->CancelRequest(render_process_id, request_id, false); |
| 824 } | 819 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 // Extensions that are not from the gallery are considered dangerous. | 890 // Extensions that are not from the gallery are considered dangerous. |
| 896 ExtensionService* service = profile->GetExtensionService(); | 891 ExtensionService* service = profile->GetExtensionService(); |
| 897 if (!service || | 892 if (!service || |
| 898 !service->IsDownloadFromGallery(info->url(), info->referrer_url)) | 893 !service->IsDownloadFromGallery(info->url(), info->referrer_url)) |
| 899 return true; | 894 return true; |
| 900 } | 895 } |
| 901 return false; | 896 return false; |
| 902 } | 897 } |
| 903 | 898 |
| 904 } // namespace download_util | 899 } // namespace download_util |
| OLD | NEW |