Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: content/child/permissions/permission_manager.h

Issue 990303002: Implement PermissionService::GetNextPermissionChange. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_impl
Patch Set: review comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_CHILD_PERMISSIONS_PERMISSION_MANAGER_H_
6 #define CONTENT_CHILD_PERMISSIONS_PERMISSION_MANAGER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/id_map.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/common/permission_service.mojom.h"
15 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionCl ient.h"
16
17 namespace content {
18
19 class ServiceRegistry;
20
21 // The PermissionManager is a layer between Blink and the Mojo PermissionService
22 // It implements blink::WebPermissionClient. It is being used from workers and
23 // frames independently. When called outside of the main thread,
24 // QueryPermissionForWorker is meant to be called. It will handle the thread
25 // jumping.
26 class PermissionManager : public blink::WebPermissionClient {
27 public:
28 PermissionManager(ServiceRegistry& service_registry);
Bernhard Bauer 2015/03/23 10:20:44 explicit
29 virtual ~PermissionManager();
30
31 // blink::WebPermissionClient implementation.
32 virtual void queryPermission(blink::WebPermissionType type,
33 const blink::WebURL& origin,
34 blink::WebPermissionQueryCallback* callback);
35
36 void QueryPermissionForWorker(blink::WebPermissionType type,
37 const std::string& origin,
38 blink::WebPermissionQueryCallback* callback,
39 int worker_thread_id);
40
41 protected:
Bernhard Bauer 2015/03/23 10:20:44 Why protected? Is this class meant to be subclasse
42 void QueryPermissionInternal(blink::WebPermissionType type,
43 const std::string& origin,
44 blink::WebPermissionQueryCallback* callback,
45 int worker_thread_id);
46
47 void OnQueryPermission(int request_id, PermissionStatus status);
48
49 // Called from the main thread in order to run the callback in the thread it
50 // was created on.
51 static void RunCallbackOnWorkerThread(
Bernhard Bauer 2015/03/23 10:20:44 You could move this to an anonymous namespace in t
52 blink::WebPermissionQueryCallback* callback,
53 scoped_ptr<blink::WebPermissionStatus> status);
54
55 // Saves some basic information about the callback in order to be able to run
56 // it in the right thread.
57 class CallbackInformation {
Bernhard Bauer 2015/03/23 10:20:44 Can you only forward-declare this class here? Als
58 public:
59 CallbackInformation(blink::WebPermissionQueryCallback* callback,
60 int worker_thread_id);
61 ~CallbackInformation();
62
63 blink::WebPermissionQueryCallback* callback() const;
64 int worker_thread_id() const;
65
66 blink::WebPermissionQueryCallback* ReleaseCallback();
67
68 private:
69 scoped_ptr<blink::WebPermissionQueryCallback> callback_;
70 int worker_thread_id_;
71
72 DISALLOW_COPY_AND_ASSIGN(CallbackInformation);
73 };
74 using CallbackMap = IDMap<CallbackInformation, IDMapOwnPointer>;
75 CallbackMap pending_callbacks_;
76
77 PermissionServicePtr permission_service_;
78
79 DISALLOW_COPY_AND_ASSIGN(PermissionManager);
80 };
81
82 } // namespace content
83
84 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698