Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / notification_permission_dispatcher.h
blob5c32693b18a7295e3a1fb12cbd14f7b3b9efddcd
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"
12 namespace blink {
13 class WebNotificationPermissionCallback;
14 class WebSecurityOrigin;
17 namespace content {
19 // Dispatcher for Web Notification permission requests.
20 class NotificationPermissionDispatcher : public RenderFrameObserver {
21 public:
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);
32 private:
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>
39 pending_requests_;
41 PermissionServicePtr permission_service_;
43 DISALLOW_COPY_AND_ASSIGN(NotificationPermissionDispatcher);
46 } // namespace content
48 #endif // CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_