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/history/history_service_factory.h"
10 #include "chrome/browser/profiles/profile.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
<RefcountedKeyedService
>
34 ShortcutsBackendFactory::BuildProfileForTesting(
35 content::BrowserContext
* profile
) {
36 scoped_refptr
<ShortcutsBackend
> backend(
37 new ShortcutsBackend(static_cast<Profile
*>(profile
), false));
44 scoped_refptr
<RefcountedKeyedService
>
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()) {
58 DependsOn(HistoryServiceFactory::GetInstance());
61 ShortcutsBackendFactory::~ShortcutsBackendFactory() {}
63 scoped_refptr
<RefcountedKeyedService
>
64 ShortcutsBackendFactory::BuildServiceInstanceFor(
65 content::BrowserContext
* profile
) const {
66 scoped_refptr
<ShortcutsBackend
> backend(
67 new ShortcutsBackend(static_cast<Profile
*>(profile
), false));
73 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const {