web_ui_ios_controller_factory_registry.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef IOS_WEB_WEBUI_WEB_UI_IOS_CONTROLLER_FACTORY_REGISTRY_H_
  5. #define IOS_WEB_WEBUI_WEB_UI_IOS_CONTROLLER_FACTORY_REGISTRY_H_
  6. #include <memory>
  7. #include "base/no_destructor.h"
  8. #include "ios/web/public/webui/web_ui_ios_controller_factory.h"
  9. namespace web {
  10. // A singleton which holds on to all the registered WebUIIOSControllerFactory
  11. // instances.
  12. class WebUIIOSControllerFactoryRegistry : public WebUIIOSControllerFactory {
  13. public:
  14. static WebUIIOSControllerFactoryRegistry* GetInstance();
  15. WebUIIOSControllerFactoryRegistry(const WebUIIOSControllerFactoryRegistry&) =
  16. delete;
  17. WebUIIOSControllerFactoryRegistry& operator=(
  18. const WebUIIOSControllerFactoryRegistry&) = delete;
  19. NSInteger GetErrorCodeForWebUIURL(const GURL& url) const override;
  20. // WebUIIOSControllerFactory implementation. Each method loops through the
  21. // same method on all the factories.
  22. std::unique_ptr<WebUIIOSController> CreateWebUIIOSControllerForURL(
  23. WebUIIOS* web_ui,
  24. const GURL& url) const override;
  25. private:
  26. friend class base::NoDestructor<WebUIIOSControllerFactoryRegistry>;
  27. WebUIIOSControllerFactoryRegistry();
  28. ~WebUIIOSControllerFactoryRegistry() override;
  29. };
  30. } // namespace web
  31. #endif // IOS_WEB_WEBUI_WEB_UI_IOS_CONTROLLER_FACTORY_REGISTRY_H_