1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_READ_LATER_READING_LIST_MODEL_FACTORY_H_
6 #define CHROME_BROWSER_UI_READ_LATER_READING_LIST_MODEL_FACTORY_H_
7 
8 #include "base/macros.h"
9 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
10 
11 namespace base {
12 template <typename T>
13 struct DefaultSingletonTraits;
14 }
15 
16 class ReadingListModel;
17 
18 // Singleton that owns all ReadingListModels and associates them with
19 // BrowserContexts.
20 class ReadingListModelFactory : public BrowserContextKeyedServiceFactory {
21  public:
22   ReadingListModelFactory(const ReadingListModelFactory&) = delete;
23   ReadingListModelFactory& operator=(const ReadingListModelFactory&) = delete;
24 
25   static ReadingListModel* GetForBrowserContext(
26       content::BrowserContext* browser_context);
27 
28   static ReadingListModelFactory* GetInstance();
29 
30   static BrowserContextKeyedServiceFactory::TestingFactory
31   GetDefaultFactoryForTesting();
32 
33  private:
34   friend struct base::DefaultSingletonTraits<ReadingListModelFactory>;
35 
36   ReadingListModelFactory();
37   ~ReadingListModelFactory() override;
38 
39   // BrowserContextKeyedServiceFactory:
40   KeyedService* BuildServiceInstanceFor(
41       content::BrowserContext* context) const override;
42   void RegisterProfilePrefs(
43       user_prefs::PrefRegistrySyncable* registry) override;
44   content::BrowserContext* GetBrowserContextToUse(
45       content::BrowserContext* context) const override;
46   bool ServiceIsNULLWhileTesting() const override;
47 };
48 
49 #endif  // CHROME_BROWSER_UI_READ_LATER_READING_LIST_MODEL_FACTORY_H_
50