blob: cf831f9b5ad871a20512a996294d2e916a183f27 [file] [log] [blame]
// Copyright 2017 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 IOS_CHROME_BROWSER_DOWNLOAD_BROWSER_DOWNLOAD_SERVICE_H_
#define IOS_CHROME_BROWSER_DOWNLOAD_BROWSER_DOWNLOAD_SERVICE_H_
#include <memory>
#include "base/macros.h"
#include "components/keyed_service/core/keyed_service.h"
#include "ios/web/public/download/download_controller_delegate.h"
namespace web {
class DownloadController;
class DownloadTask;
class WebState;
} // namespace web
// Keyed Service which acts as web::DownloadController delegate and routes
// download tasks to the appropriate TabHelper for download.
class BrowserDownloadService : public KeyedService,
public web::DownloadControllerDelegate {
public:
explicit BrowserDownloadService(web::DownloadController* download_controller);
~BrowserDownloadService() override;
private:
// web::DownloadControllerDelegate overrides:
void OnDownloadCreated(web::DownloadController*,
web::WebState*,
std::unique_ptr<web::DownloadTask>) override;
void OnDownloadControllerDestroyed(web::DownloadController*) override;
web::DownloadController* download_controller_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(BrowserDownloadService);
};
#endif // IOS_CHROME_BROWSER_DOWNLOAD_BROWSER_DOWNLOAD_SERVICE_H_