Chromium Code Reviews| 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. | |
| 18 // This service can be created from a RenderFrameHost or a RenderProcessHost. | |
| 19 // It receives at PermissionContext instance when created (that it then owns) | |
| 20 // which allows it to have some information about the current context. That | |
| 21 // allows the service to know whether it can show UI and have knowledge of the | |
| 22 // associated WebContents for example. | |
| 23 class PermissionServiceImpl : public mojo::InterfaceImpl<PermissionService> { | |
| 24 public: | |
| 25 static void Create(scoped_ptr<PermissionServiceContext> context, | |
| 26 mojo::InterfaceRequest<PermissionService> request); | |
| 27 | |
| 28 protected: | |
| 29 friend PermissionServiceContext; | |
| 30 | |
| 31 // Clear pending permissions associated with a given frame and request the | |
| 32 // browser to cancel the permission requests. | |
| 33 // This has to be called by the PermissionServiceContext. | |
| 34 void CancelPendingRequests(); | |
| 35 | |
| 36 private: | |
| 37 PermissionServiceImpl(scoped_ptr<PermissionServiceContext> context); | |
| 38 virtual ~PermissionServiceImpl(); | |
| 39 | |
| 40 // PermissionService: | |
| 41 void RequestPermission( | |
| 42 PermissionPtr permission, | |
| 43 const mojo::String& origin, | |
| 44 const mojo::Callback<void(PermissionStatus)>& callback) override; | |
| 45 void RevokePermission( | |
| 46 PermissionPtr permission, | |
| 47 const mojo::String& origin, | |
| 48 const mojo::Callback<void(PermissionStatus)>& callback) override; | |
| 49 void HasPermission( | |
| 50 PermissionPtr permission, | |
| 51 const mojo::String& origin, | |
| 52 const mojo::Callback<void(PermissionStatus)>& callback) override; | |
| 53 void StartObserving( | |
| 54 PermissionPtr permission, | |
| 55 const mojo::String& origin) override; | |
| 56 void StopObserving( | |
| 57 PermissionPtr permission, | |
| 58 const mojo::String& origin) override; | |
| 59 | |
| 60 void OnRequestPermissionResponse( | |
| 61 const mojo::Callback<void(PermissionStatus)>& callback, | |
| 62 int request_id, | |
| 63 bool allowed); | |
| 64 | |
| 65 struct PendingRequest { | |
| 66 PendingRequest(PermissionType permission, const GURL& origin); | |
| 67 PermissionType permission; | |
| 68 GURL origin; | |
| 69 }; | |
| 70 | |
| 71 typedef IDMap<PendingRequest, IDMapOwnPointer> RequestsMap; | |
|
qsr
2014/11/14 09:20:26
Declaration order seems weird: http://google-style
mlamouri (slow - plz ping)
2014/11/14 11:37:11
Done.
| |
| 72 RequestsMap pending_requests_; | |
| 73 | |
| 74 scoped_ptr<PermissionServiceContext> context_; | |
| 75 | |
| 76 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); | |
| 79 }; | |
| 80 | |
| 81 } // namespace content | |
| 82 | |
| 83 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ | |
| OLD | NEW |