app_sync_ui_state_factory.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 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 22AppSyncUIStateFactory* AppSyncUIStateFactory::GetInstance() { 23 return Singleton<AppSyncUIStateFactory>::get(); 24} 25 26AppSyncUIStateFactory::AppSyncUIStateFactory() 27 : BrowserContextKeyedServiceFactory( 28 "AppSyncUIState", 29 BrowserContextDependencyManager::GetInstance()) { 30 DependsOn(ProfileSyncServiceFactory::GetInstance()); 31} 32 33AppSyncUIStateFactory::~AppSyncUIStateFactory() { 34} 35 36KeyedService* 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