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

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

Issue 6973035: Move download stuff to download tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, forgot to add tab watcher as delegate with CF. Created 9 years, 7 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
diff --git a/chrome/browser/ui/download/download_tab_helper.cc b/chrome/browser/ui/download/download_tab_helper.cc
index 505bbc1408c820311a235bf4c801477e55b0c9e8..54a95de7cb309ef8540421f3420cc00d67d88237 100644
--- a/chrome/browser/ui/download/download_tab_helper.cc
+++ b/chrome/browser/ui/download/download_tab_helper.cc
@@ -4,9 +4,14 @@
#include "chrome/browser/ui/download/download_tab_helper.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
+#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h"
+#include "chrome/browser/ui/download/download_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/render_messages.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -14,7 +19,8 @@
DownloadTabHelper::DownloadTabHelper(TabContentsWrapper* tab_contents)
: TabContentsObserver(tab_contents->tab_contents()),
- tab_contents_wrapper_(tab_contents) {
+ tab_contents_wrapper_(tab_contents),
+ delegate_(NULL) {
DCHECK(tab_contents);
}
@@ -62,6 +68,31 @@ bool DownloadTabHelper::SavePage(const FilePath& main_file,
return save_package_->Init();
}
+bool DownloadTabHelper::CanDownload(int request_id) {
+ if (delegate_)
+ return delegate_->CanDownload(request_id);
+ return true;
+}
+
+void DownloadTabHelper::OnStartDownload(DownloadItem* download) {
+ DCHECK(download);
+
+ BlockedContentTabHelperDelegate* blocked_content_delegate =
+ tab_contents_wrapper_->blocked_content_tab_helper()->delegate();
+ if (!blocked_content_delegate)
+ return;
+
+ // Download in a constrained popup is shown in the tab that opened it.
+ TabContentsWrapper* tab_contents =
+ blocked_content_delegate->GetConstrainingContentsWrapper(
+ tab_contents_wrapper_);
+
+ if (tab_contents && tab_contents->download_tab_helper()->delegate()) {
+ tab_contents->download_tab_helper()->delegate()->OnStartDownload(
+ download, tab_contents_wrapper_);
+ }
+}
+
bool DownloadTabHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DownloadTabHelper, message)
@@ -72,3 +103,9 @@ bool DownloadTabHelper::OnMessageReceived(const IPC::Message& message) {
return handled;
}
+void DownloadTabHelper::DidGetUserGesture() {
+ DownloadRequestLimiter* limiter =
+ g_browser_process->download_request_limiter();
+ if (limiter)
+ limiter->OnUserGesture(tab_contents());
+}
« no previous file with comments | « chrome/browser/ui/download/download_tab_helper.h ('k') | chrome/browser/ui/download/download_tab_helper_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698