| 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 #include "chrome/browser/ui/download/download_tab_helper.h" | 5 #include "chrome/browser/ui/download/download_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/download/download_manager.h" | 8 #include "chrome/browser/download/download_manager.h" |
| 9 #include "chrome/browser/download/download_request_limiter.h" | 9 #include "chrome/browser/download/download_request_limiter.h" |
| 10 #include "chrome/browser/download/download_util.h" | 10 #include "chrome/browser/download/download_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 const FilePath& dir_path, | 61 const FilePath& dir_path, |
| 62 SavePackage::SavePackageType save_type) { | 62 SavePackage::SavePackageType save_type) { |
| 63 // Stop the page from navigating. | 63 // Stop the page from navigating. |
| 64 tab_contents()->Stop(); | 64 tab_contents()->Stop(); |
| 65 | 65 |
| 66 save_package_ = | 66 save_package_ = |
| 67 new SavePackage(tab_contents_wrapper_, save_type, main_file, dir_path); | 67 new SavePackage(tab_contents_wrapper_, save_type, main_file, dir_path); |
| 68 return save_package_->Init(); | 68 return save_package_->Init(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Used in automated testing to check the folder where an HTML is saved. |
| 72 string16 DownloadTabHelper::SavePageToProperDirectory( |
| 73 const FilePath& website_save_dir, |
| 74 const FilePath& download_save_dir, |
| 75 SavePackage::SavePackageType save_type) { |
| 76 tab_contents()->Stop(); |
| 77 |
| 78 save_package_ = new SavePackage(tab_contents_wrapper_); |
| 79 save_package_->SetShouldPromptUser(false); |
| 80 save_package_->GetSaveInfo(website_save_dir, download_save_dir, save_type); |
| 81 return tab_contents()->GetTitle(); |
| 82 } |
| 83 |
| 71 bool DownloadTabHelper::CanDownload(int request_id) { | 84 bool DownloadTabHelper::CanDownload(int request_id) { |
| 72 if (delegate_) | 85 if (delegate_) |
| 73 return delegate_->CanDownload(request_id); | 86 return delegate_->CanDownload(request_id); |
| 74 return true; | 87 return true; |
| 75 } | 88 } |
| 76 | 89 |
| 77 void DownloadTabHelper::OnStartDownload(DownloadItem* download) { | 90 void DownloadTabHelper::OnStartDownload(DownloadItem* download) { |
| 78 DCHECK(download); | 91 DCHECK(download); |
| 79 | 92 |
| 80 BlockedContentTabHelperDelegate* blocked_content_delegate = | 93 BlockedContentTabHelperDelegate* blocked_content_delegate = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 102 | 115 |
| 103 return handled; | 116 return handled; |
| 104 } | 117 } |
| 105 | 118 |
| 106 void DownloadTabHelper::DidGetUserGesture() { | 119 void DownloadTabHelper::DidGetUserGesture() { |
| 107 DownloadRequestLimiter* limiter = | 120 DownloadRequestLimiter* limiter = |
| 108 g_browser_process->download_request_limiter(); | 121 g_browser_process->download_request_limiter(); |
| 109 if (limiter) | 122 if (limiter) |
| 110 limiter->OnUserGesture(tab_contents()); | 123 limiter->OnUserGesture(tab_contents()); |
| 111 } | 124 } |
| OLD | NEW |