| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef EXTENSIONS_TEST_TEST_SERVICE_REGISTRATION_MANAGER_H_ | |
| 6 #define EXTENSIONS_TEST_TEST_SERVICE_REGISTRATION_MANAGER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "extensions/browser/mojo/service_registration_manager.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 class TestServiceRegistrationManager : public ServiceRegistrationManager { | |
| 16 public: | |
| 17 TestServiceRegistrationManager(); | |
| 18 ~TestServiceRegistrationManager() override; | |
| 19 | |
| 20 // Overrides an existing service factory with |factory| for testing. This | |
| 21 // does not alter the permission checks used to determine whether a service | |
| 22 // is available. | |
| 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); | |
| 31 } | |
| 32 | |
| 33 void AddServiceToServiceRegistry( | |
| 34 content::ServiceRegistry* service_registry, | |
| 35 internal::ServiceFactoryBase* service_factory) override; | |
| 36 | |
| 37 private: | |
| 38 std::map<std::string, linked_ptr<internal::ServiceFactoryBase>> | |
| 39 test_factories_; | |
| 40 | |
| 41 DISALLOW_COPY_AND_ASSIGN(TestServiceRegistrationManager); | |
| 42 }; | |
| 43 | |
| 44 } // namespace extensions | |
| 45 | |
| 46 #endif // EXTENSIONS_TEST_TEST_SERVICE_REGISTRATION_MANAGER_H_ | |
| OLD | NEW |