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#include "extensions/browser/extension_registry_factory.h" 12 13// static 14AppSyncUIState* AppSyncUIStateFactory::GetForProfile(Profile* profile) { 15 if (!AppSyncUIState::ShouldObserveAppSyncForProfile(profile)) 16 return NULL; 17 18 return static_cast<AppSyncUIState*>( 19 GetInstance()->GetServiceForBrowserContext(profile, true)); 20} 21 22// static 23AppSyncUIStateFactory* AppSyncUIStateFactory::GetInstance() { 24 return Singleton<AppSyncUIStateFactory>::get(); 25} 26 27AppSyncUIStateFactory::AppSyncUIStateFactory() 28 : BrowserContextKeyedServiceFactory( 29 "AppSyncUIState", 30 BrowserContextDependencyManager::GetInstance()) { 31 DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); 32 DependsOn(ProfileSyncServiceFactory::GetInstance()); 33} 34 35AppSyncUIStateFactory::~AppSyncUIStateFactory() { 36} 37 38KeyedService* AppSyncUIStateFactory::BuildServiceInstanceFor( 39 content::BrowserContext* context) const { 40 Profile* profile = static_cast<Profile*>(context); 41 DCHECK(AppSyncUIState::ShouldObserveAppSyncForProfile(profile)); 42 return new AppSyncUIState(profile); 43} 44