1 // Copyright 2013 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/file_manager/volume_manager_factory.h"
7 #include "base/basictypes.h"
9 #include "base/memory/singleton.h"
10 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
11 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
12 #include "chrome/browser/chromeos/file_system_provider/service_factory.h"
13 #include "chrome/browser/profiles/incognito_helpers.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/disks/disk_mount_manager.h"
17 #include "components/keyed_service/content/browser_context_dependency_manager.h"
18 #include "components/storage_monitor/storage_monitor.h"
19 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h"
21 namespace file_manager
{
23 VolumeManager
* VolumeManagerFactory::Get(content::BrowserContext
* context
) {
24 return static_cast<VolumeManager
*>(
25 GetInstance()->GetServiceForBrowserContext(context
, true));
28 VolumeManagerFactory
* VolumeManagerFactory::GetInstance() {
29 return Singleton
<VolumeManagerFactory
>::get();
32 content::BrowserContext
* VolumeManagerFactory::GetBrowserContextToUse(
33 content::BrowserContext
* context
) const {
34 // Explicitly allow this manager in guest login mode.
35 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);
38 bool VolumeManagerFactory::ServiceIsCreatedWithBrowserContext() const {
42 bool VolumeManagerFactory::ServiceIsNULLWhileTesting() const {
46 KeyedService
* VolumeManagerFactory::BuildServiceInstanceFor(
47 content::BrowserContext
* context
) const {
48 Profile
* const profile
= Profile::FromBrowserContext(context
);
49 VolumeManager
* instance
= new VolumeManager(
50 profile
, drive::DriveIntegrationServiceFactory::GetForProfile(profile
),
51 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
52 chromeos::disks::DiskMountManager::GetInstance(),
53 chromeos::file_system_provider::ServiceFactory::Get(context
),
54 VolumeManager::GetMtpStorageInfoCallback());
55 instance
->Initialize();
59 VolumeManagerFactory::VolumeManagerFactory()
60 : BrowserContextKeyedServiceFactory(
61 "VolumeManagerFactory",
62 BrowserContextDependencyManager::GetInstance()) {
63 DependsOn(drive::DriveIntegrationServiceFactory::GetInstance());
64 DependsOn(chromeos::file_system_provider::ServiceFactory::GetInstance());
67 VolumeManagerFactory::~VolumeManagerFactory() {
70 } // namespace file_manager