Chromium Code Reviews| Index: chrome/browser/ui/download/download_tab_helper.cc |
| =================================================================== |
| --- chrome/browser/ui/download/download_tab_helper.cc (revision 81013) |
| +++ chrome/browser/ui/download/download_tab_helper.cc (working copy) |
| @@ -6,11 +6,13 @@ |
| #include "chrome/browser/download/download_manager.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" |
|
jam
2011/04/15 18:53:23
you only need one of these message headers
|
| DownloadTabHelper::DownloadTabHelper(TabContents* tab_contents) |
| - : tab_contents_(tab_contents) { |
| - DCHECK(tab_contents_); |
| + : TabContentsObserver(tab_contents) { |
| + DCHECK(tab_contents); |
| } |
| DownloadTabHelper::~DownloadTabHelper() { |
| @@ -18,20 +20,20 @@ |
| 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()); |
| 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(); |
| } |
| @@ -42,10 +44,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; |
| +} |
| + |