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/event_router_factory.h"
7 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
8 #include "chrome/browser/chromeos/extensions/file_manager/event_router.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/keyed_service/content/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 EventRouter
* EventRouterFactory::GetForProfile(Profile
* profile
) {
20 return static_cast<EventRouter
*>(
21 GetInstance()->GetServiceForBrowserContext(profile
, true));
25 EventRouterFactory
* EventRouterFactory::GetInstance() {
26 return Singleton
<EventRouterFactory
>::get();
29 EventRouterFactory::EventRouterFactory()
30 : BrowserContextKeyedServiceFactory(
32 BrowserContextDependencyManager::GetInstance()) {
33 DependsOn(drive::DriveIntegrationServiceFactory::GetInstance());
35 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
36 DependsOn(VolumeManagerFactory::GetInstance());
39 EventRouterFactory::~EventRouterFactory() {
42 KeyedService
* EventRouterFactory::BuildServiceInstanceFor(
43 content::BrowserContext
* context
) const {
44 return new EventRouter(Profile::FromBrowserContext(context
));
47 content::BrowserContext
* EventRouterFactory::GetBrowserContextToUse(
48 content::BrowserContext
* context
) const {
49 // Explicitly and always allow this router in guest login mode.
50 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);
53 bool EventRouterFactory::ServiceIsCreatedWithBrowserContext() const {
57 bool EventRouterFactory::ServiceIsNULLWhileTesting() const {
61 } // namespace file_manager