15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_FACTORY_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_FACTORY_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/singleton.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h" 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HistoryService; 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Singleton that owns all HistoryService and associates them with 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Profiles. 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class HistoryServiceFactory : public BrowserContextKeyedServiceFactory { 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static HistoryService* GetForProfile( 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile, Profile::ServiceAccessType sat); 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static HistoryService* GetForProfileIfExists( 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile, Profile::ServiceAccessType sat); 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static HistoryService* GetForProfileWithoutCreating( 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile); 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static HistoryServiceFactory* GetInstance(); 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // In the testing profile, we often clear the history before making a new 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // one. This takes care of that work. It should only be used in tests. 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note: This does not do any cleanup; it only destroys the service. The 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // calling test is expected to do the cleanup before calling this function. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void ShutdownForProfile(Profile* profile); 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend struct DefaultSingletonTraits<HistoryServiceFactory>; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) HistoryServiceFactory(); 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~HistoryServiceFactory(); 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // BrowserContextKeyedServiceFactory: 4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual BrowserContextKeyedService* BuildServiceInstanceFor( 43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::BrowserContext* context) const OVERRIDE; 44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual content::BrowserContext* GetBrowserContextToUse( 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::BrowserContext* context) const OVERRIDE; 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_FACTORY_H_ 50