OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_FACTORY_H_ |
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_FACTORY_H_ | 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_FACTORY_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "components/keyed_service/content/refcounted_browser_context_keyed_serv
ice_factory.h" | 11 #include "components/keyed_service/content/refcounted_browser_context_keyed_serv
ice_factory.h" |
12 | 12 |
13 class Profile; | 13 class Profile; |
14 | 14 |
| 15 namespace base { |
15 template <typename T> | 16 template <typename T> |
16 struct DefaultSingletonTraits; | 17 struct DefaultSingletonTraits; |
| 18 } |
17 | 19 |
18 namespace history { | 20 namespace history { |
19 struct PrepopulatedPage; | 21 struct PrepopulatedPage; |
20 class TopSites; | 22 class TopSites; |
21 } | 23 } |
22 | 24 |
23 class Profile; | 25 class Profile; |
24 | 26 |
25 // Used for creating and fetching a per-profile instance of the | 27 // Used for creating and fetching a per-profile instance of the |
26 // TopSites. | 28 // TopSites. |
27 class TopSitesFactory : public RefcountedBrowserContextKeyedServiceFactory { | 29 class TopSitesFactory : public RefcountedBrowserContextKeyedServiceFactory { |
28 public: | 30 public: |
29 // Get the TopSites service for |profile|, creating one if needed. | 31 // Get the TopSites service for |profile|, creating one if needed. |
30 static scoped_refptr<history::TopSites> GetForProfile(Profile* profile); | 32 static scoped_refptr<history::TopSites> GetForProfile(Profile* profile); |
31 | 33 |
32 // Get the singleton instance of the factory. | 34 // Get the singleton instance of the factory. |
33 static TopSitesFactory* GetInstance(); | 35 static TopSitesFactory* GetInstance(); |
34 | 36 |
35 // Creates a TopSites service for |context| with |prepopulated_page_list|. | 37 // Creates a TopSites service for |context| with |prepopulated_page_list|. |
36 // Public for testing. | 38 // Public for testing. |
37 static scoped_refptr<history::TopSites> BuildTopSites( | 39 static scoped_refptr<history::TopSites> BuildTopSites( |
38 content::BrowserContext* context, | 40 content::BrowserContext* context, |
39 const std::vector<history::PrepopulatedPage>& prepopulated_page_list); | 41 const std::vector<history::PrepopulatedPage>& prepopulated_page_list); |
40 | 42 |
41 private: | 43 private: |
42 friend struct DefaultSingletonTraits<TopSitesFactory>; | 44 friend struct base::DefaultSingletonTraits<TopSitesFactory>; |
43 | 45 |
44 TopSitesFactory(); | 46 TopSitesFactory(); |
45 ~TopSitesFactory() override; | 47 ~TopSitesFactory() override; |
46 | 48 |
47 // Overridden from BrowserContextKeyedServiceFactory. | 49 // Overridden from BrowserContextKeyedServiceFactory. |
48 scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( | 50 scoped_refptr<RefcountedKeyedService> BuildServiceInstanceFor( |
49 content::BrowserContext* context) const override; | 51 content::BrowserContext* context) const override; |
50 void RegisterProfilePrefs( | 52 void RegisterProfilePrefs( |
51 user_prefs::PrefRegistrySyncable* registry) override; | 53 user_prefs::PrefRegistrySyncable* registry) override; |
52 bool ServiceIsNULLWhileTesting() const override; | 54 bool ServiceIsNULLWhileTesting() const override; |
53 | 55 |
54 DISALLOW_COPY_AND_ASSIGN(TopSitesFactory); | 56 DISALLOW_COPY_AND_ASSIGN(TopSitesFactory); |
55 }; | 57 }; |
56 | 58 |
57 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_FACTORY_H_ | 59 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_FACTORY_H_ |
OLD | NEW |