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_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_FACTORY_H_ 7 8 #include "base/memory/singleton.h" 9 #include "components/keyed_service/content/browser_context_keyed_service_factory.h" 10 11 class KeyedService; 12 class Profile; 13 14 namespace safe_browsing { 15 class ClientSideDetectionService; 16 17 // Singleton that owns ClientSideDetectionService objects, one for each active 18 // Profile. It listens to profile destroy events and destroy its associated 19 // service. It returns a separate instance if the profile is in Incognito 20 // mode. 21 class ClientSideDetectionServiceFactory 22 : public BrowserContextKeyedServiceFactory { 23 public: 24 // Creates the service if it doesn't exist already for the given |profile|. 25 // If the service already exists, return its pointer. 26 static ClientSideDetectionService* GetForProfile(Profile* profile); 27 28 // Get the singleton instance. 29 static ClientSideDetectionServiceFactory* GetInstance(); 30 31 private: 32 friend struct base::DefaultSingletonTraits<ClientSideDetectionServiceFactory>; 33 34 ClientSideDetectionServiceFactory(); 35 ~ClientSideDetectionServiceFactory() override = default; 36 37 // BrowserContextKeyedServiceFactory: 38 KeyedService* BuildServiceInstanceFor( 39 content::BrowserContext* context) const override; 40 content::BrowserContext* GetBrowserContextToUse( 41 content::BrowserContext* context) const override; 42 43 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionServiceFactory); 44 }; 45 46 } // namespace safe_browsing 47 48 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_FACTORY_H_ 49