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_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_
6 #define CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_
8 #include "base/id_map.h"
9 #include "content/common/permission_service.mojom.h"
10 #include "content/public/renderer/render_frame_observer.h"
13 class WebNotificationPermissionCallback
;
14 class WebSecurityOrigin
;
19 // Dispatcher for Web Notification permission requests.
20 class NotificationPermissionDispatcher
: public RenderFrameObserver
{
22 explicit NotificationPermissionDispatcher(RenderFrame
* render_frame
);
23 ~NotificationPermissionDispatcher() override
;
25 // Requests permission to display Web Notifications for |origin|. The callback
26 // will be invoked when the permission status is available. This class will
27 // take ownership of |callback|.
28 void RequestPermission(
29 const blink::WebSecurityOrigin
& origin
,
30 blink::WebNotificationPermissionCallback
* callback
);
33 void OnPermissionRequestComplete(
34 int request_id
, PermissionStatus status
);
36 // Tracks the active notification permission requests. This class takes
37 // ownership of the created WebNotificationPermissionCallback objects.
38 IDMap
<blink::WebNotificationPermissionCallback
, IDMapOwnPointer
>
41 PermissionServicePtr permission_service_
;
43 DISALLOW_COPY_AND_ASSIGN(NotificationPermissionDispatcher
);
46 } // namespace content
48 #endif // CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_