Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / child / permissions / permission_dispatcher_thread_proxy.h
blob718324722682f21cbb804505bee03d7b6e2a9889
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::WebPermissionCallback* callback);
39 virtual void revokePermission(blink::WebPermissionType type,
40 const blink::WebURL& origin,
41 blink::WebPermissionCallback* callback);
42 virtual void startListening(blink::WebPermissionType type,
43 const blink::WebURL& origin,
44 blink::WebPermissionObserver* observer);
45 virtual void stopListening(blink::WebPermissionObserver* observer);
47 // WorkerTaskRunner::Observer implementation.
48 void OnWorkerRunLoopStopped() override;
50 private:
51 PermissionDispatcherThreadProxy(
52 base::SingleThreadTaskRunner* main_thread_task_runner,
53 PermissionDispatcher* permissions_dispatcher);
55 // Callback when an observed permission changes.
56 void OnPermissionChanged(blink::WebPermissionType type,
57 const std::string& origin,
58 blink::WebPermissionObserver* observer,
59 blink::WebPermissionStatus status);
61 virtual ~PermissionDispatcherThreadProxy();
63 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
64 PermissionDispatcher* permission_dispatcher_;
66 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcherThreadProxy);
69 } // namespace content
71 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_THREAD_PROXY_H_