Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / renderer / shared_worker / embedded_shared_worker_stub.h
blob6adf71a3d7f6cffda1e8e9825c5240fbc38c2179
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_SHARED_WORKER_EMBEDDED_SHARED_WORKER_STUB_H_
6 #define CONTENT_RENDERER_SHARED_WORKER_EMBEDDED_SHARED_WORKER_STUB_H_
8 #include <vector>
10 #include "content/child/child_message_filter.h"
11 #include "content/child/scoped_child_process_reference.h"
12 #include "ipc/ipc_listener.h"
13 #include "third_party/WebKit/public/platform/WebString.h"
14 #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h"
15 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h"
16 #include "url/gurl.h"
18 namespace blink {
19 class WebApplicationCacheHost;
20 class WebApplicationCacheHostClient;
21 class WebMessagePortChannel;
22 class WebNotificationPresenter;
23 class WebSecurityOrigin;
24 class WebSharedWorker;
25 class WebWorkerContentSettingsClientProxy;
28 namespace content {
29 class SharedWorkerDevToolsAgent;
30 class WebApplicationCacheHostImpl;
31 class WebMessagePortChannelImpl;
33 // A stub class to receive IPC from browser process and talk to
34 // blink::WebSharedWorker. Implements blink::WebSharedWorkerClient.
35 // This class is self-destruct (no one explicitly owns this), and
36 // deletes itself (via private Shutdown() method) when either one of
37 // following methods is called by blink::WebSharedWorker:
38 // - workerScriptLoadFailed() or
39 // - workerContextDestroyed()
41 // In either case the corresponding blink::WebSharedWorker also deletes
42 // itself.
43 class EmbeddedSharedWorkerStub : public IPC::Listener,
44 public blink::WebSharedWorkerClient {
45 public:
46 EmbeddedSharedWorkerStub(
47 const GURL& url,
48 const base::string16& name,
49 const base::string16& content_security_policy,
50 blink::WebContentSecurityPolicyType security_policy_type,
51 bool pause_on_start,
52 int route_id);
54 // IPC::Listener implementation.
55 bool OnMessageReceived(const IPC::Message& message) override;
56 void OnChannelError() override;
58 // blink::WebSharedWorkerClient implementation.
59 virtual void workerContextClosed() override;
60 virtual void workerContextDestroyed() override;
61 virtual void workerReadyForInspection() override;
62 virtual void workerScriptLoaded() override;
63 virtual void workerScriptLoadFailed() override;
64 virtual void selectAppCacheID(long long) override;
65 virtual blink::WebNotificationPresenter* notificationPresenter() override;
66 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
67 blink::WebApplicationCacheHostClient*) override;
68 virtual blink::WebWorkerContentSettingsClientProxy*
69 createWorkerContentSettingsClientProxy(
70 const blink::WebSecurityOrigin& origin) override;
71 virtual blink::WebServiceWorkerNetworkProvider*
72 createServiceWorkerNetworkProvider(blink::WebDataSource*) override;
73 virtual void sendDevToolsMessage(
74 int call_id,
75 const blink::WebString& message,
76 const blink::WebString& state) override;
78 private:
79 ~EmbeddedSharedWorkerStub() override;
81 void Shutdown();
82 bool Send(IPC::Message* message);
84 // WebSharedWorker will own |channel|.
85 void ConnectToChannel(WebMessagePortChannelImpl* channel);
87 void OnConnect(int sent_message_port_id, int routing_id);
88 void OnTerminateWorkerContext();
90 int route_id_;
91 base::string16 name_;
92 bool running_ = false;
93 GURL url_;
94 blink::WebSharedWorker* impl_ = nullptr;
95 scoped_ptr<SharedWorkerDevToolsAgent> worker_devtools_agent_;
97 typedef std::vector<WebMessagePortChannelImpl*> PendingChannelList;
98 PendingChannelList pending_channels_;
100 ScopedChildProcessReference process_ref_;
101 WebApplicationCacheHostImpl* app_cache_host_ = nullptr;
102 DISALLOW_COPY_AND_ASSIGN(EmbeddedSharedWorkerStub);
105 } // namespace content
107 #endif // CONTENT_RENDERER_SHARED_WORKER_EMBEDDED_SHARED_WORKER_STUB_H_