app_list_syncable_service_factory.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright 2013 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/app_list_syncable_service_factory.h" 6 7#include "base/prefs/pref_service.h" 8#include "chrome/browser/profiles/incognito_helpers.h" 9#include "chrome/browser/profiles/profile.h" 10#include "chrome/browser/ui/app_list/app_list_syncable_service.h" 11#include "components/keyed_service/content/browser_context_dependency_manager.h" 12#include "extensions/browser/extension_system.h" 13#include "extensions/browser/extension_system_provider.h" 14#include "extensions/browser/extensions_browser_client.h" 15 16namespace app_list { 17 18// static 19AppListSyncableService* AppListSyncableServiceFactory::GetForProfile( 20 Profile* profile) { 21 return static_cast<AppListSyncableService*>( 22 GetInstance()->GetServiceForBrowserContext(profile, true)); 23} 24 25// static 26AppListSyncableServiceFactory* AppListSyncableServiceFactory::GetInstance() { 27 return Singleton<AppListSyncableServiceFactory>::get(); 28} 29 30AppListSyncableServiceFactory::AppListSyncableServiceFactory() 31 : BrowserContextKeyedServiceFactory( 32 "AppListSyncableService", 33 BrowserContextDependencyManager::GetInstance()) { 34 DependsOn( 35 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 36} 37 38AppListSyncableServiceFactory::~AppListSyncableServiceFactory() { 39} 40 41KeyedService* AppListSyncableServiceFactory::BuildServiceInstanceFor( 42 content::BrowserContext* browser_context) const { 43 Profile* profile = static_cast<Profile*>(browser_context); 44 return new AppListSyncableService(profile, 45 extensions::ExtensionSystem::Get(profile)); 46} 47 48void AppListSyncableServiceFactory::RegisterProfilePrefs( 49 user_prefs::PrefRegistrySyncable* registry) { 50} 51 52content::BrowserContext* AppListSyncableServiceFactory::GetBrowserContextToUse( 53 content::BrowserContext* context) const { 54 // In Guest session, off the record profile should not be redirected to the 55 // original one. 56 Profile* profile = static_cast<Profile*>(context); 57 if (profile->IsGuestSession()) 58 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 59 return chrome::GetBrowserContextRedirectedInIncognito(context); 60} 61 62} // namespace app_list 63