1 // Copyright 2014 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 #ifndef EXTENSIONS_TEST_TEST_SERVICE_REGISTRATION_MANAGER_H_
6 #define EXTENSIONS_TEST_TEST_SERVICE_REGISTRATION_MANAGER_H_
11 #include "extensions/browser/mojo/service_registration_manager.h"
13 namespace extensions
{
15 class TestServiceRegistrationManager
: public ServiceRegistrationManager
{
17 TestServiceRegistrationManager();
18 ~TestServiceRegistrationManager() override
;
20 // Overrides an existing service factory with |factory| for testing. This
21 // does not alter the permission checks used to determine whether a service
23 template <typename Interface
>
24 void OverrideServiceFactoryForTest(
25 const base::Callback
<void(mojo::InterfaceRequest
<Interface
>)>& factory
) {
26 linked_ptr
<internal::ServiceFactoryBase
> service_factory(
27 new internal::ServiceFactory
<Interface
>(factory
));
28 auto result
= test_factories_
.insert(
29 std::make_pair(Interface::Name_
, service_factory
));
30 DCHECK(result
.second
);
33 void AddServiceToServiceRegistry(
34 content::ServiceRegistry
* service_registry
,
35 internal::ServiceFactoryBase
* service_factory
) override
;
38 std::map
<std::string
, linked_ptr
<internal::ServiceFactoryBase
>>
41 ServiceRegistrationManager
* service_registration_manager_
;
43 DISALLOW_COPY_AND_ASSIGN(TestServiceRegistrationManager
);
46 } // namespace extensions
48 #endif // EXTENSIONS_TEST_TEST_SERVICE_REGISTRATION_MANAGER_H_