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 "chrome/common/pref_names.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 scoped_refptr
<ShortcutsBackend
> ShortcutsBackendFactory::GetForProfile(
16 return static_cast<ShortcutsBackend
*>(
17 GetInstance()->GetServiceForBrowserContext(profile
, true).get());
21 scoped_refptr
<ShortcutsBackend
> ShortcutsBackendFactory::GetForProfileIfExists(
23 return static_cast<ShortcutsBackend
*>(
24 GetInstance()->GetServiceForBrowserContext(profile
, false).get());
28 ShortcutsBackendFactory
* ShortcutsBackendFactory::GetInstance() {
29 return Singleton
<ShortcutsBackendFactory
>::get();
33 scoped_refptr
<RefcountedBrowserContextKeyedService
>
34 ShortcutsBackendFactory::BuildProfileForTesting(
35 content::BrowserContext
* profile
) {
36 scoped_refptr
<ShortcutsBackend
> backend(
37 new ShortcutsBackend(static_cast<Profile
*>(profile
), false));
44 scoped_refptr
<RefcountedBrowserContextKeyedService
>
45 ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting(
46 content::BrowserContext
* profile
) {
47 scoped_refptr
<ShortcutsBackend
> backend(
48 new ShortcutsBackend(static_cast<Profile
*>(profile
), true));
54 ShortcutsBackendFactory::ShortcutsBackendFactory()
55 : RefcountedBrowserContextKeyedServiceFactory(
57 BrowserContextDependencyManager::GetInstance()) {
60 ShortcutsBackendFactory::~ShortcutsBackendFactory() {}
62 scoped_refptr
<RefcountedBrowserContextKeyedService
>
63 ShortcutsBackendFactory::BuildServiceInstanceFor(
64 content::BrowserContext
* profile
) const {
65 scoped_refptr
<ShortcutsBackend
> backend(
66 new ShortcutsBackend(static_cast<Profile
*>(profile
), false));
72 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const {