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