Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / renderer / mojo / service_registry_js_wrapper.h
blobfa0eee9704c0bd6f0103d2f3c276b905d9c1df89
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 #ifndef CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_
6 #define CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_
8 #include <string>
10 #include "content/common/content_export.h"
11 #include "gin/handle.h"
12 #include "gin/object_template_builder.h"
13 #include "gin/wrappable.h"
14 #include "third_party/mojo/src/mojo/public/cpp/system/core.h"
16 namespace content {
18 class ServiceRegistry;
20 // A JS wrapper around ServiceRegistry that allows connecting to remote
21 // services.
22 class CONTENT_EXPORT ServiceRegistryJsWrapper
23 : public gin::Wrappable<ServiceRegistryJsWrapper> {
24 public:
25 ~ServiceRegistryJsWrapper() override;
26 static gin::Handle<ServiceRegistryJsWrapper> Create(
27 v8::Isolate* isolate,
28 ServiceRegistry* service_registry);
30 // gin::Wrappable<ServiceRegistryJsWrapper> overrides.
31 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
32 v8::Isolate* isolate) override;
34 // JS interface implementation.
35 mojo::Handle ConnectToService(const std::string& service_name);
37 static gin::WrapperInfo kWrapperInfo;
38 static const char kModuleName[];
40 private:
41 explicit ServiceRegistryJsWrapper(
42 base::WeakPtr<ServiceRegistry> service_registry);
44 base::WeakPtr<ServiceRegistry> service_registry_;
46 DISALLOW_COPY_AND_ASSIGN(ServiceRegistryJsWrapper);
49 } // namespace content
51 #endif // CONTENT_RENDERER_MOJO_SERVICE_REGISTRY_JS_WRAPPER_H_