1// Copyright (c) 2012 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_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ 6#define CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ 7 8#include "base/memory/ref_counted.h" 9#include "base/memory/singleton.h" 10#include "components/browser_context_keyed_service/refcounted_browser_context_keyed_service_factory.h" 11 12class Profile; 13 14namespace history { 15class ShortcutsBackend; 16} // namespace history 17 18// Singleton that owns all instances of ShortcutsBackend and associates them 19// with Profiles. 20class ShortcutsBackendFactory 21 : public RefcountedBrowserContextKeyedServiceFactory { 22 public: 23 static scoped_refptr<history::ShortcutsBackend> GetForProfile( 24 Profile* profile); 25 26 static scoped_refptr<history::ShortcutsBackend> GetForProfileIfExists( 27 Profile* profile); 28 29 static ShortcutsBackendFactory* GetInstance(); 30 31 // Creates and returns a backend for testing purposes. 32 static scoped_refptr<RefcountedBrowserContextKeyedService> 33 BuildProfileForTesting(content::BrowserContext* profile); 34 35 // Creates and returns a backend but without creating its persistent database 36 // for testing purposes. 37 static scoped_refptr<RefcountedBrowserContextKeyedService> 38 BuildProfileNoDatabaseForTesting(content::BrowserContext* profile); 39 40 private: 41 friend struct DefaultSingletonTraits<ShortcutsBackendFactory>; 42 43 ShortcutsBackendFactory(); 44 virtual ~ShortcutsBackendFactory(); 45 46 // BrowserContextKeyedServiceFactory: 47 virtual scoped_refptr<RefcountedBrowserContextKeyedService> 48 BuildServiceInstanceFor(content::BrowserContext* profile) const OVERRIDE; 49 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; 50}; 51 52#endif // CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ 53