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. 4 5 #include "chrome/browser/ui/ash/app_sync_ui_state_factory.h" 6 7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/sync/profile_sync_service_factory.h" 9 #include "chrome/browser/ui/ash/app_sync_ui_state.h" 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 12 // static GetForProfile(Profile * profile)13AppSyncUIState* AppSyncUIStateFactory::GetForProfile(Profile* profile) { 14 if (!AppSyncUIState::ShouldObserveAppSyncForProfile(profile)) 15 return NULL; 16 17 return static_cast<AppSyncUIState*>( 18 GetInstance()->GetServiceForBrowserContext(profile, true)); 19 } 20 21 // static GetInstance()22AppSyncUIStateFactory* AppSyncUIStateFactory::GetInstance() { 23 return Singleton<AppSyncUIStateFactory>::get(); 24 } 25 AppSyncUIStateFactory()26AppSyncUIStateFactory::AppSyncUIStateFactory() 27 : BrowserContextKeyedServiceFactory( 28 "AppSyncUIState", 29 BrowserContextDependencyManager::GetInstance()) { 30 DependsOn(ProfileSyncServiceFactory::GetInstance()); 31 } 32 ~AppSyncUIStateFactory()33AppSyncUIStateFactory::~AppSyncUIStateFactory() { 34 } 35 BuildServiceInstanceFor(content::BrowserContext * context) const36KeyedService* AppSyncUIStateFactory::BuildServiceInstanceFor( 37 content::BrowserContext* context) const { 38 Profile* profile = static_cast<Profile*>(context); 39 DCHECK(AppSyncUIState::ShouldObserveAppSyncForProfile(profile)); 40 return new AppSyncUIState(profile); 41 } 42