summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_shelf.cc
diff options
context:
space:
mode:
authorbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 20:00:08 +0000
committerbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 20:00:08 +0000
commit423939db27e73f8fe4dd5402a31856932e52cedb (patch)
treee671c21f50e007d86b6866324b4f93b7edf371cd /chrome/browser/download/download_shelf.cc
parentb7f9bbd4e9c2d9835da8765471206f357efde2aa (diff)
downloadchromium_src-423939db27e73f8fe4dd5402a31856932e52cedb.zip
chromium_src-423939db27e73f8fe4dd5402a31856932e52cedb.tar.gz
chromium_src-423939db27e73f8fe4dd5402a31856932e52cedb.tar.bz2
chrome.downloads.setShelfEnabled(boolean)
Reviewers: meacer: basic idea and features sail: profiles sky: browser/ui/* jam: automation/testing_automation_provider.cc asanka: everything Closes and Disables the shelf for every browser window associated with the Profile associated with the extension. ExtensionDownloadsEventRouter manages a vector of Extensions that have disabled the shelf. When this vector is empty, the shelf is enabled. ExtensionDownloadsEventRouter listens for extension unload events so that the shelf will be re-enabled when the extension is disabled or uninstalled. DownloadShelf access this information through DownloadService, which owns ExtensionDownloadsEventRouter. Extensions need to call setShelfEnabled(false) every time the browser is started. There is no persistence. Requires permission "downloads.shelf" with no warning, as suggested by meacer. Changed DownloadServiceFactory::GetForProfile to GetForBrowserContext so that DownloadShelf can use DownloadItem::GetBrowserContext(). R=asanka@chromium.org, asargent@chromium.org, jam@chromium.org, meacer@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/20474002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_shelf.cc')
-rw-r--r--chrome/browser/download/download_shelf.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/chrome/browser/download/download_shelf.cc b/chrome/browser/download/download_shelf.cc
index d6b8fb6..f262e0a 100644
--- a/chrome/browser/download/download_shelf.cc
+++ b/chrome/browser/download/download_shelf.cc
@@ -8,6 +8,8 @@
#include "base/callback.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/download/download_item_model.h"
+#include "chrome/browser/download/download_service.h"
+#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_started_animation.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
@@ -96,15 +98,16 @@ base::TimeDelta DownloadShelf::GetTransientDownloadShowDelay() {
}
content::DownloadManager* DownloadShelf::GetDownloadManager() {
- DCHECK(browser());
return content::BrowserContext::GetDownloadManager(browser()->profile());
}
void DownloadShelf::ShowDownload(DownloadItem* download) {
if (download->GetState() == DownloadItem::COMPLETE &&
- DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete()) {
+ DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete())
+ return;
+ if (!DownloadServiceFactory::GetForBrowserContext(
+ download->GetBrowserContext())->IsShelfEnabled())
return;
- }
if (is_hidden_)
Unhide();