summaryrefslogtreecommitdiffstats
path: root/content/renderer/notification_permission_dispatcher.h
blob: df23dee15b5c811fbab58fdb6a83f4fb494e8917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_
#define CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/permission_service.mojom.h"
#include "content/public/renderer/render_frame_observer.h"

namespace blink {
class WebNotificationPermissionCallback;
class WebSecurityOrigin;
}

namespace content {

class RenderFrame;

// Dispatcher for Web Notification permission requests.
class NotificationPermissionDispatcher : public RenderFrameObserver {
 public:
  explicit NotificationPermissionDispatcher(RenderFrame* render_frame);
  ~NotificationPermissionDispatcher() override;

  // Requests permission to display Web Notifications for |origin|. The callback
  // will be invoked when the permission status is available. This class will
  // take ownership of |callback|.
  void RequestPermission(const blink::WebSecurityOrigin& origin,
                         blink::WebNotificationPermissionCallback* callback);

 private:
  void OnPermissionRequestComplete(
      scoped_ptr<blink::WebNotificationPermissionCallback> callback,
      PermissionStatus status);

  PermissionServicePtr permission_service_;

  DISALLOW_COPY_AND_ASSIGN(NotificationPermissionDispatcher);
};

}  // namespace content

#endif  // CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_