Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / start_page_service_factory.cc
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.
4
5 #include "chrome/browser/ui/app_list/start_page_service_factory.h"
6
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"
18
19 namespace app_list {
20
21 // static
22 StartPageService* StartPageServiceFactory::GetForProfile(Profile* profile) {
23   if (!CommandLine::ForCurrentProcess()->HasSwitch(
24           ::switches::kShowAppListStartPage) &&
25       !app_list::switches::IsVoiceSearchEnabled()) {
26       return NULL;
27     }
28
29   return static_cast<StartPageService*>(
30       GetInstance()->GetServiceForBrowserContext(profile, true));
31 }
32
33 // static
34 StartPageServiceFactory* StartPageServiceFactory::GetInstance() {
35   return Singleton<StartPageServiceFactory>::get();
36 }
37
38 StartPageServiceFactory::StartPageServiceFactory()
39     : BrowserContextKeyedServiceFactory(
40         "AppListStartPageService",
41         BrowserContextDependencyManager::GetInstance()) {
42   DependsOn(
43       extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
44   DependsOn(extensions::InstallTrackerFactory::GetInstance());
45 }
46
47 StartPageServiceFactory::~StartPageServiceFactory() {}
48
49 BrowserContextKeyedService* StartPageServiceFactory::BuildServiceInstanceFor(
50     content::BrowserContext* context) const {
51   Profile* profile = static_cast<Profile*>(context);
52   return new StartPageService(profile);
53 }
54
55 void StartPageServiceFactory::RegisterProfilePrefs(
56     user_prefs::PrefRegistrySyncable* registry) {
57 #if defined(OS_CHROMEOS)
58   registry->RegisterBooleanPref(
59       prefs::kHotwordAppListEnabled,
60       true,
61       user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
62 #endif
63 }
64
65 }  // namespace app_list