1 // Copyright 2014 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/ui/app_list/start_page_service_factory.h"
7 #include "base/command_line.h"
8 #include "chrome/browser/extensions/install_tracker_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/app_list/start_page_service.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h"
13 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
14 #include "components/user_prefs/pref_registry_syncable.h"
15 #include "extensions/browser/extension_system_provider.h"
16 #include "extensions/browser/extensions_browser_client.h"
17 #include "ui/app_list/app_list_switches.h"
22 StartPageService* StartPageServiceFactory::GetForProfile(Profile* profile) {
23 if (!CommandLine::ForCurrentProcess()->HasSwitch(
24 ::switches::kShowAppListStartPage) &&
25 !app_list::switches::IsVoiceSearchEnabled()) {
29 return static_cast<StartPageService*>(
30 GetInstance()->GetServiceForBrowserContext(profile, true));
34 StartPageServiceFactory* StartPageServiceFactory::GetInstance() {
35 return Singleton<StartPageServiceFactory>::get();
38 StartPageServiceFactory::StartPageServiceFactory()
39 : BrowserContextKeyedServiceFactory(
40 "AppListStartPageService",
41 BrowserContextDependencyManager::GetInstance()) {
43 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
44 DependsOn(extensions::InstallTrackerFactory::GetInstance());
47 StartPageServiceFactory::~StartPageServiceFactory() {}
49 BrowserContextKeyedService* StartPageServiceFactory::BuildServiceInstanceFor(
50 content::BrowserContext* context) const {
51 Profile* profile = static_cast<Profile*>(context);
52 return new StartPageService(profile);
55 void StartPageServiceFactory::RegisterProfilePrefs(
56 user_prefs::PrefRegistrySyncable* registry) {
57 #if defined(OS_CHROMEOS)
58 registry->RegisterBooleanPref(
59 prefs::kHotwordAppListEnabled,
61 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
65 } // namespace app_list