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 3 // found in the LICENSE file. 4 5 #ifndef IOS_CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_ 6 #define IOS_CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_ 7 8 #include <memory> 9 10 #include "base/macros.h" 11 #include "base/no_destructor.h" 12 #include "components/keyed_service/ios/browser_state_keyed_service_factory.h" 13 14 class ChromeBrowserState; 15 enum class ServiceAccessType; 16 17 namespace favicon { 18 class FaviconService; 19 } 20 21 namespace ios { 22 // Singleton that owns all FaviconServices and associates them with 23 // ChromeBrowserState. 24 class FaviconServiceFactory : public BrowserStateKeyedServiceFactory { 25 public: 26 static favicon::FaviconService* GetForBrowserState( 27 ChromeBrowserState* browser_state, 28 ServiceAccessType access_type); 29 static FaviconServiceFactory* GetInstance(); 30 // Returns the default factory used to build FaviconService. Can be 31 // registered with SetTestingFactory to use real instances during testing. 32 static TestingFactory GetDefaultFactory(); 33 34 private: 35 friend class base::NoDestructor<FaviconServiceFactory>; 36 37 FaviconServiceFactory(); 38 ~FaviconServiceFactory() override; 39 40 // BrowserStateKeyedServiceFactory implementation. 41 std::unique_ptr<KeyedService> BuildServiceInstanceFor( 42 web::BrowserState* context) const override; 43 bool ServiceIsNULLWhileTesting() const override; 44 45 DISALLOW_COPY_AND_ASSIGN(FaviconServiceFactory); 46 }; 47 48 } // namespace ios 49 50 #endif // IOS_CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_ 51