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.
5 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_factory.h"
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/browser_context_keyed_service/browser_context_dependency_manager.h"
13 #include "extensions/browser/extension_system_provider.h"
14 #include "extensions/browser/extensions_browser_client.h"
16 namespace file_manager {
19 FileBrowserPrivateAPI*
20 FileBrowserPrivateAPIFactory::GetForProfile(Profile* profile) {
21 return static_cast<FileBrowserPrivateAPI*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
26 FileBrowserPrivateAPIFactory*
27 FileBrowserPrivateAPIFactory::GetInstance() {
28 return Singleton<FileBrowserPrivateAPIFactory>::get();
31 FileBrowserPrivateAPIFactory::FileBrowserPrivateAPIFactory()
32 : BrowserContextKeyedServiceFactory(
33 "FileBrowserPrivateAPI",
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(drive::DriveIntegrationServiceFactory::GetInstance());
37 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
38 DependsOn(VolumeManagerFactory::GetInstance());
41 FileBrowserPrivateAPIFactory::~FileBrowserPrivateAPIFactory() {
44 BrowserContextKeyedService*
45 FileBrowserPrivateAPIFactory::BuildServiceInstanceFor(
46 content::BrowserContext* context) const {
47 return new FileBrowserPrivateAPI(Profile::FromBrowserContext(context));
50 content::BrowserContext* FileBrowserPrivateAPIFactory::GetBrowserContextToUse(
51 content::BrowserContext* context) const {
52 // Explicitly and always allow this router in guest login mode.
53 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
56 bool FileBrowserPrivateAPIFactory::ServiceIsCreatedWithBrowserContext() const {
60 bool FileBrowserPrivateAPIFactory::ServiceIsNULLWhileTesting() const {
64 } // namespace file_manager