OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "base/id_map.h" | |
6 #include "base/macros.h" | |
7 #include "base/memory/weak_ptr.h" | |
8 #include "content/browser/permissions/permission_service_context.h" | |
9 #include "content/common/permission_service.mojom.h" | |
10 #include "content/public/browser/permission_type.h" | |
11 | |
12 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | |
13 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | |
14 | |
15 namespace content { | |
16 | |
17 // Implements the PermissionService Mojo interface. | |
nasko
2014/11/13 23:57:38
For devs like me, who aren't familiar with Mojo se
mlamouri (slow - plz ping)
2014/11/14 00:16:33
Acknowledged.
| |
18 class PermissionServiceImpl : public mojo::InterfaceImpl<PermissionService> { | |
19 public: | |
20 static void Create(scoped_ptr<PermissionServiceContext> context, | |
21 mojo::InterfaceRequest<PermissionService> request); | |
22 | |
23 protected: | |
24 friend PermissionServiceContext; | |
25 | |
26 // Clear pending permissions associated with a given frame and request the | |
27 // browser to cancel the permission requests. | |
28 // This has to be called by the PermissionServiceContext. | |
29 void CancelPendingRequests(); | |
30 | |
31 private: | |
32 PermissionServiceImpl(scoped_ptr<PermissionServiceContext> context); | |
33 virtual ~PermissionServiceImpl(); | |
34 | |
35 // PermissionService: | |
36 void RequestPermission( | |
37 PermissionPtr permission, | |
38 const mojo::String& origin, | |
39 const mojo::Callback<void(PermissionStatus)>& callback) override; | |
40 void RevokePermission( | |
41 PermissionPtr permission, | |
42 const mojo::String& origin, | |
43 const mojo::Callback<void(PermissionStatus)>& callback) override; | |
44 void HasPermission( | |
45 PermissionPtr permission, | |
46 const mojo::String& origin, | |
47 const mojo::Callback<void(PermissionStatus)>& callback) override; | |
48 void StartObserving( | |
49 PermissionPtr permission, | |
50 const mojo::String& origin) override; | |
51 void StopObserving( | |
52 PermissionPtr permission, | |
53 const mojo::String& origin) override; | |
54 | |
55 void OnRequestPermissionResponse( | |
56 const mojo::Callback<void(PermissionStatus)>& callback, | |
57 int request_id, | |
58 bool allowed); | |
59 | |
60 struct PendingRequest { | |
61 PendingRequest(PermissionType permission, const GURL& origin); | |
62 PermissionType permission; | |
63 GURL origin; | |
64 }; | |
65 | |
66 typedef IDMap<PendingRequest, IDMapOwnPointer> RequestsMap; | |
67 RequestsMap pending_requests_; | |
68 | |
69 scoped_ptr<PermissionServiceContext> context_; | |
70 | |
71 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); | |
74 }; | |
75 | |
76 } // namespace content | |
77 | |
78 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | |
OLD | NEW |