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 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h"
7 #include "base/lazy_instance.h"
9 #include "url/url_constants.h"
13 base::LazyInstance
<std::vector
<WebUIIOSControllerFactory
*> > g_factories
=
14 LAZY_INSTANCE_INITIALIZER
;
16 void WebUIIOSControllerFactory::RegisterFactory(
17 WebUIIOSControllerFactory
* factory
) {
18 g_factories
.Pointer()->push_back(factory
);
21 WebUIIOSControllerFactoryRegistry
*
22 WebUIIOSControllerFactoryRegistry::GetInstance() {
23 return Singleton
<WebUIIOSControllerFactoryRegistry
>::get();
27 WebUIIOSControllerFactoryRegistry::CreateWebUIIOSControllerForURL(
29 const GURL
& url
) const {
30 std::vector
<WebUIIOSControllerFactory
*>* factories
= g_factories
.Pointer();
31 for (size_t i
= 0; i
< factories
->size(); ++i
) {
32 WebUIIOSController
* controller
=
33 (*factories
)[i
]->CreateWebUIIOSControllerForURL(web_ui
, url
);
40 WebUIIOSControllerFactoryRegistry::WebUIIOSControllerFactoryRegistry() {
43 WebUIIOSControllerFactoryRegistry::~WebUIIOSControllerFactoryRegistry() {