1 // Copyright 2013 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_SEARCH_INSTANT_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_FACTORY_H_ 7 8 #include "base/macros.h" 9 #include "base/memory/singleton.h" 10 #include "build/build_config.h" 11 #include "components/keyed_service/content/browser_context_keyed_service_factory.h" 12 13 #if defined(OS_ANDROID) 14 #error "Instant is only used on desktop"; 15 #endif 16 17 class InstantService; 18 class Profile; 19 20 // Singleton that owns all InstantServices and associates them with Profiles. 21 class InstantServiceFactory : public BrowserContextKeyedServiceFactory { 22 public: 23 // Returns the InstantService for |profile|. 24 static InstantService* GetForProfile(Profile* profile); 25 26 static InstantServiceFactory* GetInstance(); 27 28 private: 29 friend struct base::DefaultSingletonTraits<InstantServiceFactory>; 30 31 InstantServiceFactory(); 32 ~InstantServiceFactory() override; 33 34 // Overridden from BrowserContextKeyedServiceFactory: 35 content::BrowserContext* GetBrowserContextToUse( 36 content::BrowserContext* context) const override; 37 KeyedService* BuildServiceInstanceFor( 38 content::BrowserContext* context) const override; 39 40 DISALLOW_COPY_AND_ASSIGN(InstantServiceFactory); 41 }; 42 43 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_FACTORY_H_ 44