Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: content/browser/permissions/permission_service_impl.h

Issue 722153003: Implement basic mojo Permission service and use it for Geolocation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
7
8 #include "base/id_map.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/permissions/permission_service_context.h"
12 #include "content/common/permission_service.mojom.h"
13 #include "content/public/browser/permission_type.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 is owned by a PermissionServiceContext.
20 // It receives at PermissionServiceContext instance when created which allows it
21 // to have some information about the current context. That enables the service
22 // to know whether it can show UI and have knowledge of the associated
23 // WebContents for example.
24 class PermissionServiceImpl : public mojo::InterfaceImpl<PermissionService> {
25 public:
26 virtual ~PermissionServiceImpl();
27
28 // Clear pending permissions associated with a given frame and request the
29 // browser to cancel the permission requests.
30 void CancelPendingRequests();
31
32 protected:
33 friend PermissionServiceContext;
34
35 PermissionServiceImpl(PermissionServiceContext* context);
36
37 private:
38 struct PendingRequest {
39 PendingRequest(PermissionType permission, const GURL& origin);
40 PermissionType permission;
41 GURL origin;
42 };
43 typedef IDMap<PendingRequest, IDMapOwnPointer> RequestsMap;
44
45 // PermissionService.
46 void HasPermission(
47 PermissionName permission,
48 const mojo::String& origin,
49 const mojo::Callback<void(PermissionStatus)>& callback) override;
50 void RequestPermission(
51 PermissionName permission,
52 const mojo::String& origin,
53 const mojo::Callback<void(PermissionStatus)>& callback) override;
54
55 // mojo::InterfaceImpl.
56 void OnConnectionError() override;
57
58 void OnRequestPermissionResponse(
59 const mojo::Callback<void(PermissionStatus)>& callback,
60 int request_id,
61 bool allowed);
62
63 RequestsMap pending_requests_;
64 // context_ owns |this|.
65 PermissionServiceContext* context_;
66 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_;
67
68 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl);
69 };
70
71 } // namespace content
72
73 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/permissions/permission_service_context.cc ('k') | content/browser/permissions/permission_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698