| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ |
| 6 #define CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ | 6 #define CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "content/child/permissions/permission_observers_registry.h" | 14 #include "content/child/permissions/permission_observers_registry.h" |
| 15 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionCl
ient.h" | 15 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionCl
ient.h" |
| 16 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m.h" | 16 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m.h" |
| 17 | 17 |
| 18 namespace shell { |
| 19 class InterfaceProvider; |
| 20 } |
| 21 |
| 18 namespace content { | 22 namespace content { |
| 19 | 23 |
| 20 class ServiceRegistry; | |
| 21 | |
| 22 // The PermissionDispatcher is a layer between Blink and the Mojo | 24 // The PermissionDispatcher is a layer between Blink and the Mojo |
| 23 // PermissionService. It implements blink::WebPermissionClient. It is being used | 25 // PermissionService. It implements blink::WebPermissionClient. It is being used |
| 24 // from workers and frames independently. When called outside of the main | 26 // from workers and frames independently. When called outside of the main |
| 25 // thread, QueryPermissionForWorker is meant to be called. It will handle the | 27 // thread, QueryPermissionForWorker is meant to be called. It will handle the |
| 26 // thread jumping. | 28 // thread jumping. |
| 27 class PermissionDispatcher : public blink::WebPermissionClient, | 29 class PermissionDispatcher : public blink::WebPermissionClient, |
| 28 public PermissionObserversRegistry { | 30 public PermissionObserversRegistry { |
| 29 public: | 31 public: |
| 30 // Returns whether the given WebPermissionType is observable. Some types have | 32 // Returns whether the given WebPermissionType is observable. Some types have |
| 31 // static values that never changes. | 33 // static values that never changes. |
| 32 static bool IsObservable(blink::WebPermissionType type); | 34 static bool IsObservable(blink::WebPermissionType type); |
| 33 | 35 |
| 34 // The caller must guarantee that |service_registry| will have a lifetime | 36 // The caller must guarantee that |interface_registry| will have a lifetime |
| 35 // larger than this instance of PermissionDispatcher. | 37 // larger than this instance of PermissionDispatcher. |
| 36 explicit PermissionDispatcher(ServiceRegistry* service_registry); | 38 explicit PermissionDispatcher(shell::InterfaceProvider* remote_interfaces); |
| 37 ~PermissionDispatcher() override; | 39 ~PermissionDispatcher() override; |
| 38 | 40 |
| 39 // blink::WebPermissionClient implementation. | 41 // blink::WebPermissionClient implementation. |
| 40 void queryPermission(blink::WebPermissionType type, | 42 void queryPermission(blink::WebPermissionType type, |
| 41 const blink::WebURL& origin, | 43 const blink::WebURL& origin, |
| 42 blink::WebPermissionCallback* callback) override; | 44 blink::WebPermissionCallback* callback) override; |
| 43 void requestPermission(blink::WebPermissionType, | 45 void requestPermission(blink::WebPermissionType, |
| 44 const blink::WebURL& origin, | 46 const blink::WebURL& origin, |
| 45 blink::WebPermissionCallback* callback) override; | 47 blink::WebPermissionCallback* callback) override; |
| 46 void requestPermissions( | 48 void requestPermissions( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 const std::string& origin, | 146 const std::string& origin, |
| 145 blink::WebPermissionObserver* observer, | 147 blink::WebPermissionObserver* observer, |
| 146 blink::mojom::PermissionStatus current_status); | 148 blink::mojom::PermissionStatus current_status); |
| 147 | 149 |
| 148 // Pending callbacks for query(), revoke() and request() single permission. | 150 // Pending callbacks for query(), revoke() and request() single permission. |
| 149 PermissionCallbackMap permission_callbacks_; | 151 PermissionCallbackMap permission_callbacks_; |
| 150 | 152 |
| 151 // Pending callbacks for request() multiple permissions. | 153 // Pending callbacks for request() multiple permissions. |
| 152 PermissionsCallbackMap permissions_callbacks_; | 154 PermissionsCallbackMap permissions_callbacks_; |
| 153 | 155 |
| 154 ServiceRegistry* service_registry_; | 156 shell::InterfaceProvider* remote_interfaces_; |
| 155 blink::mojom::PermissionServicePtr permission_service_; | 157 blink::mojom::PermissionServicePtr permission_service_; |
| 156 | 158 |
| 157 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcher); | 159 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcher); |
| 158 }; | 160 }; |
| 159 | 161 |
| 160 } // namespace content | 162 } // namespace content |
| 161 | 163 |
| 162 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ | 164 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ |
| OLD | NEW |