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.
5 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/autocomplete/shortcuts_backend.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 scoped_refptr
<ShortcutsBackend
> ShortcutsBackendFactory::GetForProfile(
15 return static_cast<ShortcutsBackend
*>(
16 GetInstance()->GetServiceForBrowserContext(profile
, true).get());
20 scoped_refptr
<ShortcutsBackend
> ShortcutsBackendFactory::GetForProfileIfExists(
22 return static_cast<ShortcutsBackend
*>(
23 GetInstance()->GetServiceForBrowserContext(profile
, false).get());
27 ShortcutsBackendFactory
* ShortcutsBackendFactory::GetInstance() {
28 return Singleton
<ShortcutsBackendFactory
>::get();
32 scoped_refptr
<RefcountedKeyedService
>
33 ShortcutsBackendFactory::BuildProfileForTesting(
34 content::BrowserContext
* profile
) {
35 scoped_refptr
<ShortcutsBackend
> backend(
36 new ShortcutsBackend(static_cast<Profile
*>(profile
), false));
43 scoped_refptr
<RefcountedKeyedService
>
44 ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting(
45 content::BrowserContext
* profile
) {
46 scoped_refptr
<ShortcutsBackend
> backend(
47 new ShortcutsBackend(static_cast<Profile
*>(profile
), true));
53 ShortcutsBackendFactory::ShortcutsBackendFactory()
54 : RefcountedBrowserContextKeyedServiceFactory(
56 BrowserContextDependencyManager::GetInstance()) {
59 ShortcutsBackendFactory::~ShortcutsBackendFactory() {}
61 scoped_refptr
<RefcountedKeyedService
>
62 ShortcutsBackendFactory::BuildServiceInstanceFor(
63 content::BrowserContext
* profile
) const {
64 scoped_refptr
<ShortcutsBackend
> backend(
65 new ShortcutsBackend(static_cast<Profile
*>(profile
), false));
71 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const {