From 59560e0ba999d5edc33453d4a0fbf44831025817 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Thu, 4 Jun 2009 03:30:22 +0000 Subject: Move download shelf from per-tab to per-window. Also disable auto-hiding of the shelf. BUG=9025 TEST=Download file in one tab, open new tab, and check that download shelf is still open. Also try the shelf's close button and the "show all downloads" link. When saving a file, the download animation should not show up. Review URL: http://codereview.chromium.org/115740 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17595 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/automation/automation_provider.cc | 24 +++++++++++++++++++++--- chrome/browser/automation/automation_provider.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'chrome/browser/automation') diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index c2e0877..7fce063 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -24,6 +24,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/dom_operation_notification_details.h" #include "chrome/browser/download/download_manager.h" +#include "chrome/browser/download/download_shelf.h" #include "chrome/browser/find_bar.h" #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/find_notification_details.h" @@ -1082,6 +1083,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, SetEnableExtensionAutomation) + IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) IPC_END_MESSAGE_MAP() } @@ -1956,11 +1958,27 @@ void AutomationProvider::ExecuteJavascript(int handle, void AutomationProvider::GetShelfVisibility(int handle, bool* visible) { *visible = false; - TabContents* tab_contents = GetTabContentsForHandle(handle, NULL); - if (tab_contents) - *visible = tab_contents->IsDownloadShelfVisible(); + if (browser_tracker_->ContainsHandle(handle)) { + Browser* browser = browser_tracker_->GetResource(handle); + if (browser) { + *visible = browser->window()->IsDownloadShelfVisible(); + } + } +} + +void AutomationProvider::SetShelfVisibility(int handle, bool visible) { + if (browser_tracker_->ContainsHandle(handle)) { + Browser* browser = browser_tracker_->GetResource(handle); + if (browser) { + if (visible) + browser->window()->GetDownloadShelf()->Show(); + else + browser->window()->GetDownloadShelf()->Close(); + } + } } + void AutomationProvider::GetConstrainedWindowCount(int handle, int* count) { *count = -1; // -1 is the error code if (tab_tracker_->ContainsHandle(handle)) { diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 1506868..8673bed 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -215,6 +215,7 @@ class AutomationProvider : public base::RefCounted, const std::wstring& script, IPC::Message* reply_message); void GetShelfVisibility(int handle, bool* visible); + void SetShelfVisibility(int handle, bool visible); void SetFilteredInet(const IPC::Message& message, bool enabled); void SetProxyConfig(const std::string& new_proxy_config); -- cgit v1.1