Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / file_manager / volume_manager_factory.cc
blob0d0eb08d5c151fd61b8bcd2314b09390a3cf3e65
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"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
10 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
11 #include "chrome/browser/chromeos/file_system_provider/service_factory.h"
12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "chromeos/disks/disk_mount_manager.h"
16 #include "components/keyed_service/content/browser_context_dependency_manager.h"
18 namespace file_manager {
20 VolumeManager* VolumeManagerFactory::Get(content::BrowserContext* context) {
21 return static_cast<VolumeManager*>(
22 GetInstance()->GetServiceForBrowserContext(context, true));
25 VolumeManagerFactory* VolumeManagerFactory::GetInstance() {
26 return Singleton<VolumeManagerFactory>::get();
29 content::BrowserContext* VolumeManagerFactory::GetBrowserContextToUse(
30 content::BrowserContext* context) const {
31 // Explicitly allow this manager in guest login mode.
32 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
35 bool VolumeManagerFactory::ServiceIsCreatedWithBrowserContext() const {
36 return true;
39 bool VolumeManagerFactory::ServiceIsNULLWhileTesting() const {
40 return true;
43 KeyedService* VolumeManagerFactory::BuildServiceInstanceFor(
44 content::BrowserContext* context) const {
45 Profile* const profile = Profile::FromBrowserContext(context);
46 VolumeManager* instance = new VolumeManager(
47 profile,
48 drive::DriveIntegrationServiceFactory::GetForProfile(profile),
49 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
50 chromeos::disks::DiskMountManager::GetInstance(),
51 chromeos::file_system_provider::ServiceFactory::Get(context));
52 instance->Initialize();
53 return instance;
56 VolumeManagerFactory::VolumeManagerFactory()
57 : BrowserContextKeyedServiceFactory(
58 "VolumeManagerFactory",
59 BrowserContextDependencyManager::GetInstance()) {
60 DependsOn(drive::DriveIntegrationServiceFactory::GetInstance());
61 DependsOn(chromeos::file_system_provider::ServiceFactory::GetInstance());
64 VolumeManagerFactory::~VolumeManagerFactory() {
67 } // namespace file_manager