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)
523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#ifndef CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_FACTORY_H_
623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#define CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_FACTORY_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/singleton.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/refcounted_browser_context_keyed_service_factory.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile;
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ShortcutsBackend;
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Singleton that owns all instances of ShortcutsBackend and associates them
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// with Profiles.
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class ShortcutsBackendFactory
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    : public RefcountedBrowserContextKeyedServiceFactory {
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
2123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  static scoped_refptr<ShortcutsBackend> GetForProfile(Profile* profile);
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  static scoped_refptr<ShortcutsBackend> GetForProfileIfExists(
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      Profile* profile);
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static ShortcutsBackendFactory* GetInstance();
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates and returns a backend for testing purposes.
2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  static scoped_refptr<RefcountedBrowserContextKeyedService>
30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      BuildProfileForTesting(content::BrowserContext* profile);
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates and returns a backend but without creating its persistent database
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for testing purposes.
3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  static scoped_refptr<RefcountedBrowserContextKeyedService>
35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      BuildProfileNoDatabaseForTesting(content::BrowserContext* profile);
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend struct DefaultSingletonTraits<ShortcutsBackendFactory>;
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ShortcutsBackendFactory();
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~ShortcutsBackendFactory();
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // BrowserContextKeyedServiceFactory:
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual scoped_refptr<RefcountedBrowserContextKeyedService>
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      BuildServiceInstanceFor(content::BrowserContext* profile) const OVERRIDE;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#endif  // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_FACTORY_H_
50