app_sync_ui_state_factory.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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_dependency_manager.h" 8#include "chrome/browser/sync/profile_sync_service_factory.h" 9#include "chrome/browser/ui/ash/app_sync_ui_state.h" 10 11// static 12AppSyncUIState* AppSyncUIStateFactory::GetForProfile(Profile* profile) { 13 if (!AppSyncUIState::ShouldObserveAppSyncForProfile(profile)) 14 return NULL; 15 16 return static_cast<AppSyncUIState*>( 17 GetInstance()->GetServiceForProfile(profile, true)); 18} 19 20// static 21AppSyncUIStateFactory* AppSyncUIStateFactory::GetInstance() { 22 return Singleton<AppSyncUIStateFactory>::get(); 23} 24 25AppSyncUIStateFactory::AppSyncUIStateFactory() 26 : ProfileKeyedServiceFactory("AppSyncUIState", 27 ProfileDependencyManager::GetInstance()) { 28 DependsOn(ProfileSyncServiceFactory::GetInstance()); 29} 30 31AppSyncUIStateFactory::~AppSyncUIStateFactory() { 32} 33 34ProfileKeyedService* AppSyncUIStateFactory::BuildServiceInstanceFor( 35 Profile* profile) const { 36 DCHECK(AppSyncUIState::ShouldObserveAppSyncForProfile(profile)); 37 return new AppSyncUIState(profile); 38} 39