1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_H_
#include <memory>
#include "chrome/browser/download/download_history.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/buildflags/buildflags.h"
class ChromeDownloadManagerDelegate;
class DownloadUIController;
namespace content {
class DownloadManager;
}
namespace extensions {
class ExtensionDownloadsEventRouter;
}
// Abstract base class for the download core service; see
// DownloadCoreServiceImpl for implementation.
class DownloadCoreService : public KeyedService {
public:
// This enum represents when `CancelDownloads` is called.
enum class CancelDownloadsTrigger {
kShutdown = 0,
kProfileDeletion = 1,
};
DownloadCoreService();
DownloadCoreService(const DownloadCoreService&) = delete;
DownloadCoreService& operator=(const DownloadCoreService&) = delete;
~DownloadCoreService() override;
// Get the download manager delegate, creating it if it doesn't already exist.
virtual ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() = 0;
// Get the download UI controller, return nullptr if it doesn't already exist.
virtual DownloadUIController* GetDownloadUIController() = 0;
// Get the interface to the history system. Returns NULL if profile is
// incognito or if the DownloadManager hasn't been created yet or if there is
// no HistoryService for profile. Virtual for testing.
virtual DownloadHistory* GetDownloadHistory() = 0;
#if BUILDFLAG(ENABLE_EXTENSIONS)
virtual extensions::ExtensionDownloadsEventRouter*
GetExtensionEventRouter() = 0;
#endif
// Has a download manager been created?
virtual bool HasCreatedDownloadManager() = 0;
// Number of downloads blocking shutdown associated with this instance of the
// service.
virtual int BlockingShutdownCount() const = 0;
// Cancels all in-progress downloads for this profile.
virtual void CancelDownloads(CancelDownloadsTrigger trigger) = 0;
// Number of downloads blocking shutdown associated with all profiles.
static int BlockingShutdownCountAllProfiles();
// Cancels all in-progress downloads for all profiles.
static void CancelAllDownloads(CancelDownloadsTrigger trigger);
// Sets the DownloadManagerDelegate associated with this object and
// its DownloadManager. Takes ownership of |delegate|, and destroys
// the previous delegate. For testing.
virtual void SetDownloadManagerDelegateForTesting(
std::unique_ptr<ChromeDownloadManagerDelegate> delegate) = 0;
// Sets the DownloadHistory associated with this object and
// its DownloadManager. Takes ownership of |download_history|, and destroys
// the previous delegate. For testing.
virtual void SetDownloadHistoryForTesting(
std::unique_ptr<DownloadHistory> download_history) {}
// Returns false if at least one extension has disabled the UI, true
// otherwise.
virtual bool IsDownloadUiEnabled() = 0;
};
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_H_
|