Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / child / permissions / permission_dispatcher_thread_proxy.h
blob65d07eb514bf72d0dd5148ae8d54fd0725cde9a1
1 // Copyright 2015 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_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_THREAD_PROXY_H_
6 #define CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_THREAD_PROXY_H_
8 #include "base/id_map.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/child/permissions/permission_observers_registry.h"
12 #include "content/child/worker_task_runner.h"
13 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionClient.h"
15 namespace base {
16 class SingleThreadTaskRunner;
19 namespace content {
21 class PermissionDispatcher;
23 // PermissionDispatcherThreadProxy is a a proxy to the PermissionDispatcher for
24 // callers running on a different thread than the main thread. There is one
25 // instance of that class per thread.
26 class PermissionDispatcherThreadProxy :
27 public blink::WebPermissionClient,
28 public PermissionObserversRegistry,
29 public WorkerTaskRunner::Observer {
30 public:
31 static PermissionDispatcherThreadProxy* GetThreadInstance(
32 base::SingleThreadTaskRunner* main_thread_task_runner,
33 PermissionDispatcher* permissions_dispatcher);
35 // blink::WebPermissionClient implementation.
36 virtual void queryPermission(blink::WebPermissionType type,
37 const blink::WebURL& origin,
38 blink::WebPermissionQueryCallback* callback);
39 virtual void startListening(blink::WebPermissionType type,
40 const blink::WebURL& origin,
41 blink::WebPermissionObserver* observer);
42 virtual void stopListening(blink::WebPermissionObserver* observer);
44 // WorkerTaskRunner::Observer implementation.
45 void OnWorkerRunLoopStopped() override;
47 private:
48 PermissionDispatcherThreadProxy(
49 base::SingleThreadTaskRunner* main_thread_task_runner,
50 PermissionDispatcher* permissions_dispatcher);
52 // Callback when an observed permission changes.
53 void OnPermissionChanged(blink::WebPermissionType type,
54 const std::string& origin,
55 blink::WebPermissionObserver* observer,
56 blink::WebPermissionStatus status);
58 virtual ~PermissionDispatcherThreadProxy();
60 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
61 PermissionDispatcher* permission_dispatcher_;
63 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcherThreadProxy);
66 } // namespace content
68 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_THREAD_PROXY_H_