OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" | 5 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
9 #include "url/url_constants.h" | 9 #include "url/url_constants.h" |
10 | 10 |
11 namespace web { | 11 namespace web { |
12 | 12 |
13 base::LazyInstance<std::vector<WebUIIOSControllerFactory*> > g_factories = | 13 base::LazyInstance<std::vector<WebUIIOSControllerFactory*> > g_factories = |
14 LAZY_INSTANCE_INITIALIZER; | 14 LAZY_INSTANCE_INITIALIZER; |
15 | 15 |
16 void WebUIIOSControllerFactory::RegisterFactory( | 16 void WebUIIOSControllerFactory::RegisterFactory( |
17 WebUIIOSControllerFactory* factory) { | 17 WebUIIOSControllerFactory* factory) { |
18 g_factories.Pointer()->push_back(factory); | 18 g_factories.Pointer()->push_back(factory); |
19 } | 19 } |
20 | 20 |
21 WebUIIOSControllerFactoryRegistry* | 21 WebUIIOSControllerFactoryRegistry* |
22 WebUIIOSControllerFactoryRegistry::GetInstance() { | 22 WebUIIOSControllerFactoryRegistry::GetInstance() { |
23 return Singleton<WebUIIOSControllerFactoryRegistry>::get(); | 23 return base::Singleton<WebUIIOSControllerFactoryRegistry>::get(); |
24 } | 24 } |
25 | 25 |
26 WebUIIOSController* | 26 WebUIIOSController* |
27 WebUIIOSControllerFactoryRegistry::CreateWebUIIOSControllerForURL( | 27 WebUIIOSControllerFactoryRegistry::CreateWebUIIOSControllerForURL( |
28 WebUIIOS* web_ui, | 28 WebUIIOS* web_ui, |
29 const GURL& url) const { | 29 const GURL& url) const { |
30 std::vector<WebUIIOSControllerFactory*>* factories = g_factories.Pointer(); | 30 std::vector<WebUIIOSControllerFactory*>* factories = g_factories.Pointer(); |
31 for (size_t i = 0; i < factories->size(); ++i) { | 31 for (size_t i = 0; i < factories->size(); ++i) { |
32 WebUIIOSController* controller = | 32 WebUIIOSController* controller = |
33 (*factories)[i]->CreateWebUIIOSControllerForURL(web_ui, url); | 33 (*factories)[i]->CreateWebUIIOSControllerForURL(web_ui, url); |
34 if (controller) | 34 if (controller) |
35 return controller; | 35 return controller; |
36 } | 36 } |
37 return NULL; | 37 return NULL; |
38 } | 38 } |
39 | 39 |
40 WebUIIOSControllerFactoryRegistry::WebUIIOSControllerFactoryRegistry() { | 40 WebUIIOSControllerFactoryRegistry::WebUIIOSControllerFactoryRegistry() { |
41 } | 41 } |
42 | 42 |
43 WebUIIOSControllerFactoryRegistry::~WebUIIOSControllerFactoryRegistry() { | 43 WebUIIOSControllerFactoryRegistry::~WebUIIOSControllerFactoryRegistry() { |
44 } | 44 } |
45 | 45 |
46 } // namespace web | 46 } // namespace web |
OLD | NEW |