Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1673)

Unified Diff: ios/web/webui/web_ui_ios_controller_factory_registry.cc

Issue 1110213002: Upstream most of the iOS WebUI support in ios/web/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/web/webui/web_ui_ios_controller_factory_registry.cc
diff --git a/ios/web/webui/web_ui_ios_controller_factory_registry.cc b/ios/web/webui/web_ui_ios_controller_factory_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..58e8d1360bf31e35399c927826199461d0e3d74d
--- /dev/null
+++ b/ios/web/webui/web_ui_ios_controller_factory_registry.cc
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/web/webui/web_ui_ios_controller_factory_registry.h"
+
+#include "base/lazy_instance.h"
+#include "url/gurl.h"
+#include "url/url_constants.h"
+
+namespace web {
+
+base::LazyInstance<std::vector<WebUIIOSControllerFactory*> > g_factories =
Eugene But (OOO till 7-30) 2015/04/28 20:23:01 NIT: no need for space between '>'
+ LAZY_INSTANCE_INITIALIZER;
+
+void WebUIIOSControllerFactory::RegisterFactory(
+ WebUIIOSControllerFactory* factory) {
+ g_factories.Pointer()->push_back(factory);
+}
+
+WebUIIOSControllerFactoryRegistry*
+WebUIIOSControllerFactoryRegistry::GetInstance() {
+ return Singleton<WebUIIOSControllerFactoryRegistry>::get();
+}
+
+WebUIIOSController*
+WebUIIOSControllerFactoryRegistry::CreateWebUIIOSControllerForURL(
+ WebUIIOS* web_ui,
+ const GURL& url) const {
+ std::vector<WebUIIOSControllerFactory*>* factories = g_factories.Pointer();
+ for (size_t i = 0; i < factories->size(); ++i) {
+ WebUIIOSController* controller =
+ (*factories)[i]->CreateWebUIIOSControllerForURL(web_ui, url);
+ if (controller)
+ return controller;
+ }
+ return NULL;
+}
+
+WebUIIOSControllerFactoryRegistry::WebUIIOSControllerFactoryRegistry() {
+}
+
+WebUIIOSControllerFactoryRegistry::~WebUIIOSControllerFactoryRegistry() {
+}
+
+} // namespace web

Powered by Google App Engine
This is Rietveld 408576698