OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/browser/chromeos/extensions/file_manager/volume_manager_factory
.h" | |
6 | |
7 #include "base/basictypes.h" | |
8 #include "base/memory/singleton.h" | |
9 #include "chrome/browser/chromeos/extensions/file_manager/volume_manager.h" | |
10 #include "chrome/browser/profiles/incognito_helpers.h" | |
11 #include "chrome/browser/profiles/profile.h" | |
12 #include "chromeos/disks/disk_mount_manager.h" | |
13 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | |
14 | |
15 namespace file_manager { | |
16 | |
17 VolumeManager* VolumeManagerFactory::Get(content::BrowserContext* context) { | |
18 return static_cast<VolumeManager*>( | |
19 GetInstance()->GetServiceForBrowserContext(context, true)); | |
20 } | |
21 | |
22 VolumeManagerFactory* VolumeManagerFactory::GetInstance() { | |
23 return Singleton<VolumeManagerFactory>::get(); | |
24 } | |
25 | |
26 content::BrowserContext* VolumeManagerFactory::GetBrowserContextToUse( | |
27 content::BrowserContext* context) const { | |
28 // Explicitly allow this manager in guest login mode. | |
29 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
30 } | |
31 | |
32 bool VolumeManagerFactory::ServiceIsCreatedWithBrowserContext() const { | |
33 return true; | |
34 } | |
35 | |
36 bool VolumeManagerFactory::ServiceIsNULLWhileTesting() const { | |
37 return true; | |
38 } | |
39 | |
40 BrowserContextKeyedService* VolumeManagerFactory::BuildServiceInstanceFor( | |
41 content::BrowserContext* profile) const { | |
42 VolumeManager* instance = | |
43 new VolumeManager(Profile::FromBrowserContext(profile), | |
44 chromeos::disks::DiskMountManager::GetInstance()); | |
45 instance->Initialize(); | |
46 return instance; | |
47 } | |
48 | |
49 VolumeManagerFactory::VolumeManagerFactory() | |
50 : BrowserContextKeyedServiceFactory( | |
51 "VolumeManagerFactory", | |
52 BrowserContextDependencyManager::GetInstance()) { | |
53 } | |
54 | |
55 VolumeManagerFactory::~VolumeManagerFactory() { | |
56 } | |
57 | |
58 } // namespace file_manager | |
OLD | NEW |