| 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 #ifndef CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ | 5 #ifndef CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ |
| 6 #define CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ | 6 #define CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "gin/handle.h" | 12 #include "gin/handle.h" |
| 13 #include "gin/object_template_builder.h" | 13 #include "gin/object_template_builder.h" |
| 14 #include "gin/wrappable.h" | 14 #include "gin/wrappable.h" |
| 15 #include "mojo/public/cpp/system/core.h" | 15 #include "mojo/public/cpp/system/handle.h" |
| 16 |
| 17 namespace v8 { |
| 18 class Isolate; |
| 19 } |
| 16 | 20 |
| 17 namespace content { | 21 namespace content { |
| 18 | 22 |
| 19 class ServiceRegistry; | 23 class ServiceRegistry; |
| 20 | 24 |
| 21 // A JS wrapper around ServiceRegistry that allows connecting to remote | 25 // A JS wrapper around ServiceRegistry that allows connecting to remote |
| 22 // services. | 26 // services. |
| 23 class CONTENT_EXPORT ServiceRegistryJsWrapper | 27 class CONTENT_EXPORT ServiceRegistryJsWrapper |
| 24 : public gin::Wrappable<ServiceRegistryJsWrapper> { | 28 : public gin::Wrappable<ServiceRegistryJsWrapper> { |
| 25 public: | 29 public: |
| 26 ~ServiceRegistryJsWrapper() override; | 30 ~ServiceRegistryJsWrapper() override; |
| 27 static gin::Handle<ServiceRegistryJsWrapper> Create( | 31 static gin::Handle<ServiceRegistryJsWrapper> Create( |
| 28 v8::Isolate* isolate, | 32 v8::Isolate* isolate, |
| 29 ServiceRegistry* service_registry); | 33 ServiceRegistry* service_registry); |
| 30 | 34 |
| 31 // gin::Wrappable<ServiceRegistryJsWrapper> overrides. | 35 // gin::Wrappable<ServiceRegistryJsWrapper> overrides. |
| 32 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 36 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 33 v8::Isolate* isolate) override; | 37 v8::Isolate* isolate) override; |
| 34 | 38 |
| 35 // JS interface implementation. | 39 // JS interface implementation. |
| 40 void AddServiceOverride(const std::string& service_name, |
| 41 v8::Local<v8::Function> service_factory); |
| 36 mojo::Handle ConnectToService(const std::string& service_name); | 42 mojo::Handle ConnectToService(const std::string& service_name); |
| 37 | 43 |
| 38 static gin::WrapperInfo kWrapperInfo; | 44 static gin::WrapperInfo kWrapperInfo; |
| 39 static const char kModuleName[]; | 45 static const char kModuleName[]; |
| 40 | 46 |
| 41 private: | 47 private: |
| 42 explicit ServiceRegistryJsWrapper( | 48 explicit ServiceRegistryJsWrapper( |
| 43 base::WeakPtr<ServiceRegistry> service_registry); | 49 base::WeakPtr<ServiceRegistry> service_registry); |
| 44 | 50 |
| 45 base::WeakPtr<ServiceRegistry> service_registry_; | 51 base::WeakPtr<ServiceRegistry> service_registry_; |
| 46 | 52 |
| 47 DISALLOW_COPY_AND_ASSIGN(ServiceRegistryJsWrapper); | 53 DISALLOW_COPY_AND_ASSIGN(ServiceRegistryJsWrapper); |
| 48 }; | 54 }; |
| 49 | 55 |
| 50 } // namespace content | 56 } // namespace content |
| 51 | 57 |
| 52 #endif // CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ | 58 #endif // CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_ |
| OLD | NEW |