Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1519)

Unified Diff: chrome/browser/ui/download/download_tab_helper.cc

Issue 6871020: Added functionality to use "SaveAs..." from PDF plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}
+

Powered by Google App Engine
This is Rietveld 408576698