// Copyright 2015 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_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_FACTORY_H_
#define CHROME_BROWSER_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_FACTORY_H_
#include <memory>
#include "components/keyed_service/core/simple_keyed_service_factory.h"
namespace base {
template <typename T>
class NoDestructor;
} // namespace base
namespace content {
class BrowserContext;
} // namespace content
namespace offline_pages {
class OfflinePageModel;
// A factory to create one unique OfflinePageModel. Offline pages are not
// supported in incognito, and this class uses default implementation of
// |GetBrowserContextToUse|.
// TODO(fgorski): Add an integration test that ensures incognito users don't
// save or open offline pages.
class OfflinePageModelFactory : public SimpleKeyedServiceFactory {
public:
static OfflinePageModelFactory* GetInstance();
static OfflinePageModel* GetForKey(SimpleFactoryKey* key);
// Helper method that calls GetForKey(). Extracts the SimpleFactoryKey
// from |browser_context|, which is assumed to be a Profile.
static OfflinePageModel* GetForBrowserContext(
content::BrowserContext* browser_context);
OfflinePageModelFactory(const OfflinePageModelFactory&) = delete;
OfflinePageModelFactory& operator=(const OfflinePageModelFactory&) = delete;
private:
friend base::NoDestructor<OfflinePageModelFactory>;
OfflinePageModelFactory();
~OfflinePageModelFactory() override {}
std::unique_ptr<KeyedService> BuildServiceInstanceFor(
SimpleFactoryKey* key) const override;
};
} // namespace offline_pages
#endif // CHROME_BROWSER_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_FACTORY_H_