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