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" |
11 #include "content/browser/permissions/permission_service_context.h" | 11 #include "content/browser/permissions/permission_service_context.h" |
12 #include "content/common/permission_service.mojom.h" | 12 #include "content/common/permission_service.mojom.h" |
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" | |
15 | 14 |
16 namespace content { | 15 namespace content { |
17 | 16 |
18 enum class PermissionType; | 17 enum class PermissionType; |
19 | 18 |
20 // Implements the PermissionService Mojo interface. | 19 // Implements the PermissionService Mojo interface. |
21 // This service can be created from a RenderFrameHost or a RenderProcessHost. | 20 // This service can be created from a RenderFrameHost or a RenderProcessHost. |
22 // It is owned by a PermissionServiceContext. | 21 // It is owned by a PermissionServiceContext. |
23 // It receives at PermissionServiceContext instance when created which allows it | 22 // It receives at PermissionServiceContext instance when created which allows it |
24 // to have some information about the current context. That enables the service | 23 // to have some information about the current context. That enables the service |
25 // to know whether it can show UI and have knowledge of the associated | 24 // to know whether it can show UI and have knowledge of the associated |
26 // WebContents for example. | 25 // WebContents for example. |
27 class PermissionServiceImpl : public PermissionService, | 26 class PermissionServiceImpl : public PermissionService { |
28 public mojo::ErrorHandler { | |
29 public: | 27 public: |
30 ~PermissionServiceImpl() override; | 28 ~PermissionServiceImpl() override; |
31 | 29 |
32 // Clear pending operations currently run by the service. This will be called | 30 // Clear pending operations currently run by the service. This will be called |
33 // by PermissionServiceContext when it will need the service to clear its | 31 // by PermissionServiceContext when it will need the service to clear its |
34 // state for example, if the frame changes. | 32 // state for example, if the frame changes. |
35 void CancelPendingOperations(); | 33 void CancelPendingOperations(); |
36 | 34 |
37 protected: | 35 protected: |
38 friend PermissionServiceContext; | 36 friend PermissionServiceContext; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 const PermissionStatusCallback& callback) override; | 75 const PermissionStatusCallback& callback) override; |
78 void RevokePermission(PermissionName permission, | 76 void RevokePermission(PermissionName permission, |
79 const mojo::String& origin, | 77 const mojo::String& origin, |
80 const PermissionStatusCallback& callback) override; | 78 const PermissionStatusCallback& callback) override; |
81 void GetNextPermissionChange( | 79 void GetNextPermissionChange( |
82 PermissionName permission, | 80 PermissionName permission, |
83 const mojo::String& origin, | 81 const mojo::String& origin, |
84 PermissionStatus last_known_status, | 82 PermissionStatus last_known_status, |
85 const PermissionStatusCallback& callback) override; | 83 const PermissionStatusCallback& callback) override; |
86 | 84 |
87 // mojo::ErrorHandler | 85 void OnConnectionError(); |
88 void OnConnectionError() override; | |
yzshen1
2015/07/29 00:01:02
I wonder who does set_error_handler() using this c
| |
89 | 86 |
90 void OnRequestPermissionResponse(int request_id, PermissionStatus status); | 87 void OnRequestPermissionResponse(int request_id, PermissionStatus status); |
91 | 88 |
92 PermissionStatus GetPermissionStatusFromName(PermissionName permission, | 89 PermissionStatus GetPermissionStatusFromName(PermissionName permission, |
93 const GURL& origin); | 90 const GURL& origin); |
94 PermissionStatus GetPermissionStatusFromType(PermissionType type, | 91 PermissionStatus GetPermissionStatusFromType(PermissionType type, |
95 const GURL& origin); | 92 const GURL& origin); |
96 void ResetPermissionStatus(PermissionType type, const GURL& origin); | 93 void ResetPermissionStatus(PermissionType type, const GURL& origin); |
97 | 94 |
98 void OnPermissionStatusChanged(int pending_subscription_id, | 95 void OnPermissionStatusChanged(int pending_subscription_id, |
99 PermissionStatus status); | 96 PermissionStatus status); |
100 | 97 |
101 RequestsMap pending_requests_; | 98 RequestsMap pending_requests_; |
102 SubscriptionsMap pending_subscriptions_; | 99 SubscriptionsMap pending_subscriptions_; |
103 // context_ owns |this|. | 100 // context_ owns |this|. |
104 PermissionServiceContext* context_; | 101 PermissionServiceContext* context_; |
105 mojo::Binding<PermissionService> binding_; | 102 mojo::Binding<PermissionService> binding_; |
106 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; | 103 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; |
107 | 104 |
108 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); | 105 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); |
109 }; | 106 }; |
110 | 107 |
111 } // namespace content | 108 } // namespace content |
112 | 109 |
113 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | 110 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ |
OLD | NEW |