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/chromeos/extensions/file_manager/file_browser_private_api_factory.h" 6 7 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 8 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h" 9 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" 10 #include "chrome/browser/profiles/incognito_helpers.h" 11 #include "chrome/browser/profiles/profile.h" 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" 13 #include "extensions/browser/extension_system_provider.h" 14 #include "extensions/browser/extensions_browser_client.h" 15 16 namespace file_manager { 17 18 // static 19 FileBrowserPrivateAPI* 20 FileBrowserPrivateAPIFactory::GetForProfile(Profile* profile) { 21 return static_cast<FileBrowserPrivateAPI*>( 22 GetInstance()->GetServiceForBrowserContext(profile, true)); 23 } 24 25 // static 26 FileBrowserPrivateAPIFactory* 27 FileBrowserPrivateAPIFactory::GetInstance() { 28 return Singleton<FileBrowserPrivateAPIFactory>::get(); 29 } 30 31 FileBrowserPrivateAPIFactory::FileBrowserPrivateAPIFactory() 32 : BrowserContextKeyedServiceFactory( 33 "FileBrowserPrivateAPI", 34 BrowserContextDependencyManager::GetInstance()) { 35 DependsOn(drive::DriveIntegrationServiceFactory::GetInstance()); 36 DependsOn( 37 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 38 DependsOn(VolumeManagerFactory::GetInstance()); 39 } 40 41 FileBrowserPrivateAPIFactory::~FileBrowserPrivateAPIFactory() { 42 } 43 44 KeyedService* FileBrowserPrivateAPIFactory::BuildServiceInstanceFor( 45 content::BrowserContext* context) const { 46 return new FileBrowserPrivateAPI(Profile::FromBrowserContext(context)); 47 } 48 49 content::BrowserContext* FileBrowserPrivateAPIFactory::GetBrowserContextToUse( 50 content::BrowserContext* context) const { 51 // Explicitly and always allow this router in guest login mode. 52 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 53 } 54 55 bool FileBrowserPrivateAPIFactory::ServiceIsCreatedWithBrowserContext() const { 56 return true; 57 } 58 59 bool FileBrowserPrivateAPIFactory::ServiceIsNULLWhileTesting() const { 60 return true; 61 } 62 63 } // namespace file_manager 64