Index: chrome/browser/ui/download/download_tab_helper.cc |
=================================================================== |
--- chrome/browser/ui/download/download_tab_helper.cc (revision 81782) |
+++ chrome/browser/ui/download/download_tab_helper.cc (working copy) |
@@ -7,11 +7,13 @@ |
#include "chrome/browser/download/download_manager.h" |
#include "chrome/browser/download/download_util.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/render_messages.h" |
#include "content/browser/tab_contents/tab_contents.h" |
+#include "content/common/view_messages.h" |
DownloadTabHelper::DownloadTabHelper(TabContents* tab_contents) |
- : tab_contents_(tab_contents) { |
- DCHECK(tab_contents_); |
+ : TabContentsObserver(tab_contents) { |
+ DCHECK(tab_contents); |
} |
DownloadTabHelper::~DownloadTabHelper() { |
@@ -19,23 +21,23 @@ |
void DownloadTabHelper::OnSavePage() { |
// If we can not save the page, try to download it. |
- if (!SavePackage::IsSavableContents(tab_contents_->contents_mime_type())) { |
- DownloadManager* dlm = tab_contents_->profile()->GetDownloadManager(); |
- const GURL& current_page_url = tab_contents_->GetURL(); |
+ if (!SavePackage::IsSavableContents(tab_contents()->contents_mime_type())) { |
+ DownloadManager* dlm = tab_contents()->profile()->GetDownloadManager(); |
+ const GURL& current_page_url = tab_contents()->GetURL(); |
if (dlm && current_page_url.is_valid()) { |
- dlm->DownloadUrl(current_page_url, GURL(), "", tab_contents_); |
+ dlm->DownloadUrl(current_page_url, GURL(), "", tab_contents()); |
download_util::RecordDownloadCount( |
download_util::INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT); |
} |
return; |
} |
- tab_contents_->Stop(); |
+ tab_contents()->Stop(); |
// Create the save package and possibly prompt the user for the name to save |
// the page as. The user prompt is an asynchronous operation that runs on |
// another thread. |
- save_package_ = new SavePackage(tab_contents_); |
+ save_package_ = new SavePackage(tab_contents()); |
save_package_->GetSaveInfo(); |
} |
@@ -46,9 +48,20 @@ |
const FilePath& dir_path, |
SavePackage::SavePackageType save_type) { |
// Stop the page from navigating. |
- tab_contents_->Stop(); |
+ tab_contents()->Stop(); |
save_package_ = |
- new SavePackage(tab_contents_, save_type, main_file, dir_path); |
+ new SavePackage(tab_contents(), save_type, main_file, dir_path); |
return save_package_->Init(); |
} |
+ |
+bool DownloadTabHelper::OnMessageReceived(const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(DownloadTabHelper, message) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SaveAs, OnSavePage) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ |
+ return handled; |
+} |
+ |