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_CHROMEOS_NEARBY_NEARBY_PROCESS_MANAGER_FACTORY_H_ 6 #define CHROME_BROWSER_CHROMEOS_NEARBY_NEARBY_PROCESS_MANAGER_FACTORY_H_ 7 8 #include "base/memory/singleton.h" 9 #include "components/keyed_service/content/browser_context_keyed_service_factory.h" 10 11 class Profile; 12 13 namespace chromeos { 14 namespace nearby { 15 16 class NearbyProcessManager; 17 18 // Creates a NearbyProcessManager for the primary user. No instance is created 19 // any other profile. 20 class NearbyProcessManagerFactory : public BrowserContextKeyedServiceFactory { 21 public: 22 static NearbyProcessManager* GetForProfile(Profile* profile); 23 24 static NearbyProcessManagerFactory* GetInstance(); 25 26 // When true is passed, this factory will create a NearbyProcessManager even 27 // when it is not the primary profile. 28 static void SetBypassPrimaryUserCheckForTesting( 29 bool bypass_primary_user_check_for_testing); 30 31 private: 32 friend struct base::DefaultSingletonTraits<NearbyProcessManagerFactory>; 33 34 NearbyProcessManagerFactory(); 35 NearbyProcessManagerFactory(const NearbyProcessManagerFactory&) = delete; 36 NearbyProcessManagerFactory& operator=(const NearbyProcessManagerFactory&) = 37 delete; 38 ~NearbyProcessManagerFactory() override; 39 40 // BrowserContextKeyedServiceFactory: 41 KeyedService* BuildServiceInstanceFor( 42 content::BrowserContext* context) const override; 43 bool ServiceIsCreatedWithBrowserContext() const override; 44 }; 45 46 } // namespace nearby 47 } // namespace chromeos 48 49 #endif // CHROME_BROWSER_CHROMEOS_NEARBY_NEARBY_PROCESS_MANAGER_FACTORY_H_ 50