Change next_proto member type.
[chromium-blink-merge.git] / content / browser / permissions / permission_service_impl.h
blobc67ae88ef1d1fa3e5094a5ebcb99d7ee004a12de
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.
5 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
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"
15 namespace content {
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();
28 // Clear pending permissions associated with a given frame and request the
29 // browser to cancel the permission requests.
30 void CancelPendingRequests();
32 protected:
33 friend PermissionServiceContext;
35 PermissionServiceImpl(PermissionServiceContext* context);
37 private:
38 struct PendingRequest {
39 PendingRequest(PermissionType permission, const GURL& origin);
40 PermissionType permission;
41 GURL origin;
43 typedef IDMap<PendingRequest, IDMapOwnPointer> RequestsMap;
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;
55 // mojo::InterfaceImpl.
56 void OnConnectionError() override;
58 void OnRequestPermissionResponse(
59 const mojo::Callback<void(PermissionStatus)>& callback,
60 int request_id,
61 bool allowed);
63 RequestsMap pending_requests_;
64 // context_ owns |this|.
65 PermissionServiceContext* context_;
66 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_;
68 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl);
71 } // namespace content
73 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_