1 // Copyright 2018 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_APPS_APP_SERVICE_APP_SERVICE_PROXY_FACTORY_H_ 6 #define CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_FACTORY_H_ 7 8 #include "base/macros.h" 9 #include "base/memory/singleton.h" 10 #include "components/keyed_service/content/browser_context_keyed_service_factory.h" 11 12 class Profile; 13 14 namespace apps { 15 16 class AppServiceProxy; 17 18 // Singleton that owns all AppServiceProxy's and associates them with Profile. 19 class AppServiceProxyFactory : public BrowserContextKeyedServiceFactory { 20 public: 21 static bool IsAppServiceAvailableForProfile(Profile* profile); 22 23 static AppServiceProxy* GetForProfile(Profile* profile); 24 25 // Explicitly avoids DumpWithoutCrashing() when App Service is not available 26 // for a Profile. Avoid using this unless you have spoken with App Service 27 // OWNERs. 28 static AppServiceProxy* GetForProfileRedirectInIncognito(Profile* profile); 29 30 static AppServiceProxyFactory* GetInstance(); 31 32 private: 33 friend struct base::DefaultSingletonTraits<AppServiceProxyFactory>; 34 35 AppServiceProxyFactory(); 36 ~AppServiceProxyFactory() override; 37 38 // BrowserContextKeyedServiceFactory overrides. 39 KeyedService* BuildServiceInstanceFor( 40 content::BrowserContext* context) const override; 41 content::BrowserContext* GetBrowserContextToUse( 42 content::BrowserContext* context) const override; 43 bool ServiceIsCreatedWithBrowserContext() const override; 44 45 DISALLOW_COPY_AND_ASSIGN(AppServiceProxyFactory); 46 }; 47 48 } // namespace apps 49 50 #endif // CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_FACTORY_H_ 51