start_page_service_factory.cc revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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 "components/keyed_service/content/browser_context_dependency_manager.h" 13#include "extensions/browser/extension_system_provider.h" 14#include "extensions/browser/extensions_browser_client.h" 15#include "ui/app_list/app_list_switches.h" 16 17namespace app_list { 18 19// static 20StartPageService* StartPageServiceFactory::GetForProfile(Profile* profile) { 21 if (!app_list::switches::IsExperimentalAppListEnabled() && 22 !app_list::switches::IsVoiceSearchEnabled()) { 23 return NULL; 24 } 25 26 return static_cast<StartPageService*>( 27 GetInstance()->GetServiceForBrowserContext(profile, true)); 28} 29 30// static 31StartPageServiceFactory* StartPageServiceFactory::GetInstance() { 32 return Singleton<StartPageServiceFactory>::get(); 33} 34 35StartPageServiceFactory::StartPageServiceFactory() 36 : BrowserContextKeyedServiceFactory( 37 "AppListStartPageService", 38 BrowserContextDependencyManager::GetInstance()) { 39 DependsOn( 40 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 41 DependsOn(extensions::InstallTrackerFactory::GetInstance()); 42} 43 44StartPageServiceFactory::~StartPageServiceFactory() {} 45 46KeyedService* StartPageServiceFactory::BuildServiceInstanceFor( 47 content::BrowserContext* context) const { 48 Profile* profile = static_cast<Profile*>(context); 49 return new StartPageService(profile); 50} 51 52} // namespace app_list 53