OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // browser to cancel the permission requests. | 29 // browser to cancel the permission requests. |
30 void CancelPendingRequests(); | 30 void CancelPendingRequests(); |
31 | 31 |
32 protected: | 32 protected: |
33 friend PermissionServiceContext; | 33 friend PermissionServiceContext; |
34 | 34 |
35 PermissionServiceImpl(PermissionServiceContext* context); | 35 PermissionServiceImpl(PermissionServiceContext* context); |
36 | 36 |
37 private: | 37 private: |
38 struct PendingRequest { | 38 struct PendingRequest { |
39 PendingRequest(PermissionType permission, const GURL& origin); | 39 PendingRequest(PermissionType permission, const GURL& origin, |
| 40 const mojo::Callback<void(PermissionStatus)>& callback); |
| 41 ~PendingRequest(); |
| 42 |
40 PermissionType permission; | 43 PermissionType permission; |
41 GURL origin; | 44 GURL origin; |
| 45 mojo::Callback<void(PermissionStatus)> callback; |
42 }; | 46 }; |
43 typedef IDMap<PendingRequest, IDMapOwnPointer> RequestsMap; | 47 typedef IDMap<PendingRequest, IDMapOwnPointer> RequestsMap; |
44 | 48 |
45 // PermissionService. | 49 // PermissionService. |
46 void HasPermission( | 50 void HasPermission( |
47 PermissionName permission, | 51 PermissionName permission, |
48 const mojo::String& origin, | 52 const mojo::String& origin, |
49 const mojo::Callback<void(PermissionStatus)>& callback) override; | 53 const mojo::Callback<void(PermissionStatus)>& callback) override; |
50 void RequestPermission( | 54 void RequestPermission( |
51 PermissionName permission, | 55 PermissionName permission, |
52 const mojo::String& origin, | 56 const mojo::String& origin, |
53 bool user_gesture, | 57 bool user_gesture, |
54 const mojo::Callback<void(PermissionStatus)>& callback) override; | 58 const mojo::Callback<void(PermissionStatus)>& callback) override; |
55 void RevokePermission( | 59 void RevokePermission( |
56 PermissionName permission, | 60 PermissionName permission, |
57 const mojo::String& origin, | 61 const mojo::String& origin, |
58 const mojo::Callback<void(PermissionStatus)>& callback) override; | 62 const mojo::Callback<void(PermissionStatus)>& callback) override; |
59 | 63 |
60 // mojo::InterfaceImpl. | 64 // mojo::InterfaceImpl. |
61 void OnConnectionError() override; | 65 void OnConnectionError() override; |
62 | 66 |
63 void OnRequestPermissionResponse( | 67 void OnRequestPermissionResponse(int request_id, PermissionStatus status); |
64 const mojo::Callback<void(PermissionStatus)>& callback, | |
65 int request_id, | |
66 PermissionStatus status); | |
67 | 68 |
68 PermissionStatus GetPermissionStatus(PermissionType type, GURL origin); | 69 PermissionStatus GetPermissionStatus(PermissionType type, GURL origin); |
69 void ResetPermissionStatus(PermissionType type, GURL origin); | 70 void ResetPermissionStatus(PermissionType type, GURL origin); |
70 | 71 |
71 RequestsMap pending_requests_; | 72 RequestsMap pending_requests_; |
72 // context_ owns |this|. | 73 // context_ owns |this|. |
73 PermissionServiceContext* context_; | 74 PermissionServiceContext* context_; |
74 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; | 75 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; |
75 | 76 |
76 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); | 77 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); |
77 }; | 78 }; |
78 | 79 |
79 } // namespace content | 80 } // namespace content |
80 | 81 |
81 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | 82 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ |
OLD | NEW |