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

Unified Diff: extensions/browser/mojo/service_registration_manager.cc

Issue 652313002: Enable the mojo-based serial API in the renderer behind a flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-js-natives-registration
Patch Set: fix windows build Created 6 years, 2 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
« no previous file with comments | « extensions/browser/mojo/service_registration_manager.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/mojo/service_registration_manager.cc
diff --git a/extensions/browser/mojo/service_registration_manager.cc b/extensions/browser/mojo/service_registration_manager.cc
index 97f3698db4cb5fbe974c85be2e927f828bbc3adf..ee3e55a5fd50742bc9e6df52658f400fc6b45bc9 100644
--- a/extensions/browser/mojo/service_registration_manager.cc
+++ b/extensions/browser/mojo/service_registration_manager.cc
@@ -23,6 +23,8 @@ namespace {
base::LazyInstance<ServiceRegistrationManager> g_lazy_instance =
LAZY_INSTANCE_INITIALIZER;
+ServiceRegistrationManager* g_test_instance = nullptr;
+
} // namespace
ServiceRegistrationManager::ServiceRegistrationManager() {
@@ -44,6 +46,8 @@ ServiceRegistrationManager::~ServiceRegistrationManager() {
}
ServiceRegistrationManager* ServiceRegistrationManager::GetSharedInstance() {
+ if (g_test_instance)
+ return g_test_instance;
return g_lazy_instance.Pointer();
}
@@ -72,9 +76,23 @@ void ServiceRegistrationManager::AddServicesToRenderFrame(
for (const auto& factory : factories_) {
auto availability = ExtensionAPI::GetSharedInstance()->IsAvailable(
factory.first, extension, context_type, extension_url);
- if (availability.is_available())
- factory.second->Register(render_frame_host->GetServiceRegistry());
+ if (availability.is_available()) {
+ AddServiceToServiceRegistry(render_frame_host->GetServiceRegistry(),
+ factory.second.get());
+ }
}
}
+void ServiceRegistrationManager::AddServiceToServiceRegistry(
+ content::ServiceRegistry* service_registry,
+ internal::ServiceFactoryBase* factory) {
+ factory->Register(service_registry);
+}
+
+// static
+void ServiceRegistrationManager::SetServiceRegistrationManagerForTest(
+ ServiceRegistrationManager* service_registration_manager) {
+ g_test_instance = service_registration_manager;
+}
+
} // namespace extensions
« no previous file with comments | « extensions/browser/mojo/service_registration_manager.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698