diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-16 16:07:46 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-16 16:07:46 +0000 |
commit | 357284ba336a2fe71a84bc9456c71a169bad4c6e (patch) | |
tree | 74a27b413bec45038f3f3c2bf5f71a88b86126c8 /chrome | |
parent | b0e459c0b93cd47911ff126ebd78495e1f92383f (diff) | |
download | chromium_src-357284ba336a2fe71a84bc9456c71a169bad4c6e.zip chromium_src-357284ba336a2fe71a84bc9456c71a169bad4c6e.tar.gz chromium_src-357284ba336a2fe71a84bc9456c71a169bad4c6e.tar.bz2 |
Revert 85486 - Move download stuff to download tab helper.
BUG=71097
TEST=zero visible change in how the download system works
Review URL: http://codereview.chromium.org/6973035
TBR=avi@chromium.org
Review URL: http://codereview.chromium.org/7030015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 13 | ||||
-rw-r--r-- | chrome/browser/download/download_request_limiter.cc | 6 | ||||
-rw-r--r-- | chrome/browser/download/download_request_limiter_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/download/save_package.cc | 3 | ||||
-rw-r--r-- | chrome/browser/external_tab_container_win.cc | 48 | ||||
-rw-r--r-- | chrome/browser/external_tab_container_win.h | 9 | ||||
-rw-r--r-- | chrome/browser/instant/instant_loader.cc | 31 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 96 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 9 | ||||
-rw-r--r-- | chrome/browser/ui/download/download_tab_helper.cc | 39 | ||||
-rw-r--r-- | chrome/browser/ui/download/download_tab_helper.h | 17 | ||||
-rw-r--r-- | chrome/browser/ui/download/download_tab_helper_delegate.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/download/download_tab_helper_delegate.h | 27 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
14 files changed, 88 insertions, 230 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 54d937b..fb9fb7b 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -33,8 +33,6 @@ #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/download/download_tab_helper.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_paths.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_process_host.h" @@ -1071,23 +1069,20 @@ void DownloadManager::ShowDownloadInBrowser( // get this start completion event. If it does, tell the origin TabContents // to display its download shelf. TabContents* contents = process_handle->GetTabContents(); - TabContentsWrapper* wrapper = NULL; - if (contents) - wrapper = TabContentsWrapper::GetCurrentWrapperForContents(contents); // If the contents no longer exists, we start the download in the last active // browser. This is not ideal but better than fully hiding the download from // the user. - if (!wrapper) { + if (!contents) { Browser* last_active = BrowserList::GetLastActive(); if (last_active) - wrapper = last_active->GetSelectedTabContentsWrapper(); + contents = last_active->GetSelectedTabContents(); } - if (!wrapper) + if (!contents) return; - wrapper->download_tab_helper()->OnStartDownload(download); + contents->OnStartDownload(download); } // Clears the last download path, used to initialize "save as" dialogs. diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index b39e1f6..579c172 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -12,8 +12,6 @@ #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_delegate.h" -#include "chrome/browser/ui/download/download_tab_helper.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/common/notification_source.h" // TabDownloadState ------------------------------------------------------------ @@ -258,9 +256,7 @@ void DownloadRequestLimiter::CanDownloadImpl( // FYI: Chrome Frame overrides CanDownload in ExternalTabContainer in order // to cancel the download operation in chrome and let the host browser // take care of it. - TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(originating_tab); - if (!wrapper->download_tab_helper()->CanDownload(request_id)) { + if (!originating_tab->CanDownload(request_id)) { ScheduleNotification(callback, false); return; } diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc index 9cdb3c3..d4422d1 100644 --- a/chrome/browser/download/download_request_limiter_unittest.cc +++ b/chrome/browser/download/download_request_limiter_unittest.cc @@ -1,23 +1,23 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/download/download_request_limiter.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/testing_profile.h" #include "content/browser/browser_thread.h" +#include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/tab_contents/navigation_controller.h" #include "testing/gtest/include/gtest/gtest.h" class DownloadRequestLimiterTest - : public TabContentsWrapperTestHarness, + : public RenderViewHostTestHarness, public DownloadRequestLimiter::Callback { public: DownloadRequestLimiterTest() : io_thread_(BrowserThread::IO, &message_loop_) { } virtual void SetUp() { - TabContentsWrapperTestHarness::SetUp(); + RenderViewHostTestHarness::SetUp(); allow_download_ = true; ask_allow_count_ = cancel_count_ = continue_count_ = 0; @@ -30,7 +30,7 @@ class DownloadRequestLimiterTest virtual void TearDown() { DownloadRequestLimiter::SetTestingDelegate(NULL); - TabContentsWrapperTestHarness::TearDown(); + RenderViewHostTestHarness::TearDown(); } virtual void ContinueDownload() { diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index d18099c..cf9d4dc 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -34,7 +34,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_util.h" -#include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/pref_names.h" @@ -327,7 +326,7 @@ bool SavePackage::Init() { // to be alive as long as the Profile is alive. download_manager->SavePageAsDownloadStarted(download_); - wrapper_->download_tab_helper()->OnStartDownload(download_); + tab_contents()->OnStartDownload(download_); // Check save type and process the save page job. if (save_type_ == SAVE_AS_COMPLETE_HTML) { diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index b2726f9..b3787d7 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -539,6 +539,26 @@ bool ExternalTabContainer::TakeFocus(bool reverse) { return true; } +bool ExternalTabContainer::CanDownload(int request_id) { + if (load_requests_via_automation_) { + if (automation_) { + // In case the host needs to show UI that needs to take the focus. + ::AllowSetForegroundWindow(ASFW_ANY); + + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + NewRunnableMethod(automation_resource_message_filter_.get(), + &AutomationResourceMessageFilter::SendDownloadRequestToHost, + 0, tab_handle_, request_id)); + } + } else { + DLOG(WARNING) << "Downloads are only supported with host browser network " + "stack enabled."; + } + + // Never allow downloads. + return false; +} + void ExternalTabContainer::ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, @@ -764,34 +784,6 @@ void ExternalTabContainer::Observe(NotificationType type, } //////////////////////////////////////////////////////////////////////////////// -// ExternalTabContainer, DownloadTabHelperDelegate overrides: - -bool ExternalTabContainer::CanDownload(int request_id) { - if (load_requests_via_automation_) { - if (automation_) { - // In case the host needs to show UI that needs to take the focus. - ::AllowSetForegroundWindow(ASFW_ANY); - - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - NewRunnableMethod(automation_resource_message_filter_.get(), - &AutomationResourceMessageFilter::SendDownloadRequestToHost, - 0, tab_handle_, request_id)); - } - } else { - DLOG(WARNING) << "Downloads are only supported with host browser network " - "stack enabled."; - } - - // Never allow downloads. - return false; -} - -void ExternalTabContainer::OnStartDownload(DownloadItem* download, - TabContentsWrapper* tab) { -} - - -//////////////////////////////////////////////////////////////////////////////// // ExternalTabContainer, views::WidgetWin overrides: LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index d6c73c0..2e82237 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -14,7 +14,6 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/automation/automation_resource_message_filter.h" #include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/ui/download/download_tab_helper_delegate.h" #include "chrome/browser/ui/views/frame/browser_bubble_host.h" #include "chrome/browser/ui/views/infobars/infobar_container.h" #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" @@ -42,7 +41,6 @@ class ViewProp; // external process. This class provides the FocusManger needed by the // TabContents as well as an implementation of TabContentsDelegate. class ExternalTabContainer : public TabContentsDelegate, - public DownloadTabHelperDelegate, public NotificationObserver, public views::WidgetWin, public base::RefCounted<ExternalTabContainer>, @@ -144,6 +142,8 @@ class ExternalTabContainer : public TabContentsDelegate, virtual bool TakeFocus(bool reverse); + virtual bool CanDownload(int request_id); + virtual bool OnGoToEntryOffset(int offset); virtual void ShowPageInfo(Profile* profile, @@ -173,11 +173,6 @@ class ExternalTabContainer : public TabContentsDelegate, const NotificationSource& source, const NotificationDetails& details); - // Overridden from DownloadTabHelperDelegate: - virtual bool CanDownload(int request_id) OVERRIDE; - virtual void OnStartDownload(DownloadItem* download, - TabContentsWrapper* tab) OVERRIDE; - // Returns the ExternalTabContainer instance associated with the cookie // passed in. It also erases the corresponding reference from the map. // Returns NULL if we fail to find the cookie in the map. diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index f686ecb..ca99bea 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -21,8 +21,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" -#include "chrome/browser/ui/download/download_tab_helper.h" -#include "chrome/browser/ui/download/download_tab_helper_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" @@ -144,8 +142,7 @@ void InstantLoader::FrameLoadObserver::Observe( class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate, public NotificationObserver, - public TabContentsObserver, - public DownloadTabHelperDelegate { + public TabContentsObserver { public: explicit TabContentsDelegateImpl(InstantLoader* loader); @@ -211,6 +208,7 @@ class InstantLoader::TabContentsDelegateImpl // instant result when the drag ends, so that during the drag the page won't // move around. virtual void DragEnded() OVERRIDE; + virtual bool CanDownload(int request_id) OVERRIDE; virtual void HandleMouseUp() OVERRIDE; virtual void HandleMouseActivate() OVERRIDE; virtual bool OnGoToEntryOffset(int offset) OVERRIDE; @@ -222,11 +220,6 @@ class InstantLoader::TabContentsDelegateImpl // TabContentsObserver: virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - // DownloadTabHelperDelegate: - virtual bool CanDownload(int request_id) OVERRIDE; - virtual void OnStartDownload(DownloadItem* download, - TabContentsWrapper* tab) OVERRIDE; - private: typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > AddPageVector; @@ -518,6 +511,11 @@ void InstantLoader::TabContentsDelegateImpl::DragEnded() { CommitFromMouseReleaseIfNecessary(); } +bool InstantLoader::TabContentsDelegateImpl::CanDownload(int request_id) { + // Downloads are disabled. + return false; +} + void InstantLoader::TabContentsDelegateImpl::HandleMouseUp() { CommitFromMouseReleaseIfNecessary(); } @@ -562,16 +560,6 @@ bool InstantLoader::TabContentsDelegateImpl::OnMessageReceived( return handled; } -bool InstantLoader::TabContentsDelegateImpl::CanDownload(int request_id) { - // Downloads are disabled. - return false; -} - -void InstantLoader::TabContentsDelegateImpl::OnStartDownload( - DownloadItem* download, TabContentsWrapper* tab) { - // Downloads are disabled. -} - void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( int32 page_id, const std::vector<std::string>& suggestions, @@ -822,7 +810,6 @@ TabContentsWrapper* InstantLoader::ReleasePreviewContents( #endif } preview_contents_->tab_contents()->set_delegate(NULL); - preview_contents_->download_tab_helper()->set_delegate(NULL); ready_ = false; } update_bounds_timer_.Stop(); @@ -985,7 +972,7 @@ void InstantLoader::SendBoundsToPage(bool force_if_waiting) { if (preview_contents_.get() && is_showing_instant() && (force_if_waiting || !is_waiting_for_load())) { last_omnibox_bounds_ = omnibox_bounds_; - RenderViewHost* host = preview_contents_->render_view_host(); + RenderViewHost*host = preview_contents_->render_view_host(); host->Send(new ViewMsg_SearchBoxResize( host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); } @@ -1006,8 +993,6 @@ void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); new_contents->set_delegate(preview_tab_contents_delegate_.get()); - preview_contents_->download_tab_helper()->set_delegate( - preview_tab_contents_delegate_.get()); gfx::Rect tab_bounds; tab_contents->view()->GetContainerBounds(&tab_bounds); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 9d77927..d560e48 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -3299,6 +3299,51 @@ int Browser::GetExtraRenderViewHeight() const { return window_->GetExtraRenderViewHeight(); } +void Browser::OnStartDownload(DownloadItem* download, TabContents* tab) { + if (!window()) + return; + +#if defined(OS_CHROMEOS) + // Don't show content browser for extension/theme downloads from gallery. + if (download->is_extension_install()) { + ExtensionService* service = profile_->GetExtensionService(); + if (service && service->IsDownloadFromGallery(download->url(), + download->referrer_url())) { + return; + } + } + // Open the Active Downloads ui for chromeos. + ActiveDownloadsUI::OpenPopup(profile_); +#else + // GetDownloadShelf creates the download shelf if it was not yet created. + window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); + + // Don't show the animation for "Save file" downloads. + if (download->total_bytes() <= 0) + return; + + // For non-theme extensions, we don't show the download animation. + if (download->is_extension_install() && + !ExtensionService::IsDownloadFromMiniGallery(download->url())) + return; + + TabContents* current_tab = GetSelectedTabContents(); + // We make this check for the case of minimized windows, unit tests, etc. + if (platform_util::IsVisible(current_tab->GetNativeView()) && + ui::Animation::ShouldRenderRichAnimation()) { + DownloadStartedAnimation::Show(current_tab); + } +#endif + + // If the download occurs in a new tab, close it. + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(tab); + if (tab->controller().IsInitialNavigation() && + GetConstrainingContentsWrapper(wrapper) == wrapper && tab_count() > 1) { + CloseContents(tab); + } +} + void Browser::ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, @@ -3438,56 +3483,6 @@ void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { } /////////////////////////////////////////////////////////////////////////////// -// Browser, DownloadTabHelperDelegate implementation: - -bool Browser::CanDownload(int request_id) { - return true; -} - -void Browser::OnStartDownload(DownloadItem* download, TabContentsWrapper* tab) { - if (!window()) - return; - -#if defined(OS_CHROMEOS) - // Don't show content browser for extension/theme downloads from gallery. - if (download->is_extension_install()) { - ExtensionService* service = profile_->GetExtensionService(); - if (service && service->IsDownloadFromGallery(download->url(), - download->referrer_url())) { - return; - } - } - // Open the Active Downloads ui for chromeos. - ActiveDownloadsUI::OpenPopup(profile_); -#else - // GetDownloadShelf creates the download shelf if it was not yet created. - window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); - - // Don't show the animation for "Save file" downloads. - if (download->total_bytes() <= 0) - return; - - // For non-theme extensions, we don't show the download animation. - if (download->is_extension_install() && - !ExtensionService::IsDownloadFromMiniGallery(download->url())) - return; - - TabContents* current_tab = GetSelectedTabContents(); - // We make this check for the case of minimized windows, unit tests, etc. - if (platform_util::IsVisible(current_tab->GetNativeView()) && - ui::Animation::ShouldRenderRichAnimation()) { - DownloadStartedAnimation::Show(current_tab); - } -#endif - - // If the download occurs in a new tab, close it. - if (tab->tab_contents()->controller().IsInitialNavigation() && - GetConstrainingContentsWrapper(tab) == tab && tab_count() > 1) { - CloseContents(tab->tab_contents()); - } -} - -/////////////////////////////////////////////////////////////////////////////// // Browser, SelectFileDialog::Listener implementation: void Browser::FileSelected(const FilePath& path, int index, void* params) { @@ -4397,7 +4392,6 @@ void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { // ...and all the helpers. tab->blocked_content_tab_helper()->set_delegate(delegate); tab->bookmark_tab_helper()->set_delegate(delegate); - tab->download_tab_helper()->set_delegate(delegate); tab->search_engine_tab_helper()->set_delegate(delegate); } diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 17296a1..9406d68 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -31,7 +31,6 @@ #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h" #include "chrome/browser/ui/browser_navigator.h" -#include "chrome/browser/ui/download/download_tab_helper_delegate.h" #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" #include "chrome/browser/ui/shell_dialogs.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" @@ -69,7 +68,6 @@ class Browser : public TabHandlerDelegate, public SearchEngineTabHelperDelegate, public BlockedContentTabHelperDelegate, public BookmarkTabHelperDelegate, - public DownloadTabHelperDelegate, public PageNavigator, public CommandUpdater::CommandUpdaterDelegate, public NotificationObserver, @@ -813,6 +811,7 @@ class Browser : public TabHandlerDelegate, virtual void SetFocusToLocationBar(bool select_all); virtual void RenderWidgetShowing(); virtual int GetExtraRenderViewHeight() const; + virtual void OnStartDownload(DownloadItem* download, TabContents* tab); virtual void ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, @@ -859,12 +858,6 @@ class Browser : public TabHandlerDelegate, virtual void URLStarredChanged(TabContentsWrapper* source, bool starred) OVERRIDE; - // Overridden from DownloadTabHelperDelegate: - virtual bool CanDownload(int request_id) OVERRIDE; - virtual void OnStartDownload(DownloadItem* download, - TabContentsWrapper* tab) OVERRIDE; - - // Overridden from SelectFileDialog::Listener: virtual void FileSelected(const FilePath& path, int index, void* params); diff --git a/chrome/browser/ui/download/download_tab_helper.cc b/chrome/browser/ui/download/download_tab_helper.cc index 54a95de..505bbc1 100644 --- a/chrome/browser/ui/download/download_tab_helper.cc +++ b/chrome/browser/ui/download/download_tab_helper.cc @@ -4,14 +4,9 @@ #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" @@ -19,8 +14,7 @@ DownloadTabHelper::DownloadTabHelper(TabContentsWrapper* tab_contents) : TabContentsObserver(tab_contents->tab_contents()), - tab_contents_wrapper_(tab_contents), - delegate_(NULL) { + tab_contents_wrapper_(tab_contents) { DCHECK(tab_contents); } @@ -68,31 +62,6 @@ 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) @@ -103,9 +72,3 @@ 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()); -} diff --git a/chrome/browser/ui/download/download_tab_helper.h b/chrome/browser/ui/download/download_tab_helper.h index ac55913..24ab7fc 100644 --- a/chrome/browser/ui/download/download_tab_helper.h +++ b/chrome/browser/ui/download/download_tab_helper.h @@ -10,8 +10,6 @@ #include "chrome/browser/download/save_package.h" #include "content/browser/tab_contents/tab_contents_observer.h" -class DownloadItem; -class DownloadTabHelperDelegate; class TabContentsWrapper; // Per-tab download controller. Handles dealing with various per-tab download @@ -21,9 +19,6 @@ class DownloadTabHelper : public TabContentsObserver { explicit DownloadTabHelper(TabContentsWrapper* tab_contents); virtual ~DownloadTabHelper(); - DownloadTabHelperDelegate* delegate() const { return delegate_; } - void set_delegate(DownloadTabHelperDelegate* d) { delegate_ = d; } - // Prepare for saving the current web page to disk. void OnSavePage(); @@ -40,17 +35,9 @@ class DownloadTabHelper : public TabContentsObserver { // Returns the SavePackage which manages the page saving job. May be NULL. SavePackage* save_package() const { return save_package_.get(); } - // Notifies the delegate that a download is about to be started. - // This notification is fired before a local temporary file has been created. - bool CanDownload(int request_id); - - // Notifies the delegate that a download started. - void OnStartDownload(DownloadItem* download); - private: // TabContentsObserver overrides. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void DidGetUserGesture() OVERRIDE; // SavePackage, lazily created. scoped_refptr<SavePackage> save_package_; @@ -58,10 +45,6 @@ class DownloadTabHelper : public TabContentsObserver { // Owning TabContentsWrapper. TabContentsWrapper* tab_contents_wrapper_; - // Delegate for notifying our owner (usually Browser) about stuff. Not owned - // by us. - DownloadTabHelperDelegate* delegate_; - DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); }; diff --git a/chrome/browser/ui/download/download_tab_helper_delegate.cc b/chrome/browser/ui/download/download_tab_helper_delegate.cc deleted file mode 100644 index 1a37873..0000000 --- a/chrome/browser/ui/download/download_tab_helper_delegate.cc +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/download/download_tab_helper_delegate.h" - -DownloadTabHelperDelegate::~DownloadTabHelperDelegate() { -} diff --git a/chrome/browser/ui/download/download_tab_helper_delegate.h b/chrome/browser/ui/download/download_tab_helper_delegate.h deleted file mode 100644 index 88adaec..0000000 --- a/chrome/browser/ui/download/download_tab_helper_delegate.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_DELEGATE_H_ -#define CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_DELEGATE_H_ -#pragma once - -#include "base/basictypes.h" - -class DownloadItem; -class TabContentsWrapper; - -// Objects implement this interface to get notified about changes in the -// DownloadTabHelper and to provide necessary functionality. -class DownloadTabHelperDelegate { - public: - virtual bool CanDownload(int request_id) = 0; - - virtual void OnStartDownload(DownloadItem* download, - TabContentsWrapper* tab) = 0; - - protected: - virtual ~DownloadTabHelperDelegate(); -}; - -#endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_DELEGATE_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 876f13d..6e63639 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2561,8 +2561,6 @@ 'browser/ui/crypto_module_password_dialog_openssl.cc', 'browser/ui/download/download_tab_helper.cc', 'browser/ui/download/download_tab_helper.h', - 'browser/ui/download/download_tab_helper_delegate.cc', - 'browser/ui/download/download_tab_helper_delegate.h', 'browser/ui/find_bar/find_bar.h', 'browser/ui/find_bar/find_bar_controller.cc', 'browser/ui/find_bar/find_bar_controller.h', |