webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
WebNotificationClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import <WebCore/NotificationClient.h>
27 
28 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
29 #import <WebCore/Notification.h>
30 #import <wtf/HashMap.h>
31 #import <wtf/RefPtr.h>
32 #import <wtf/RetainPtr.h>
33 #endif
34 
35 namespace WebCore {
36 class Notification;
38 class ScriptExecutionContext;
39 class VoidCallback;
40 }
41 
42 @class WebNotification;
43 @class WebNotificationPolicyListener;
44 @class WebView;
45 
47 public:
49  WebView *webView() { return m_webView; }
50 
51 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
52  // For testing purposes.
53  uint64_t notificationIDForTesting(WebCore::Notification*);
54 #endif
55 
56 private:
57  bool show(WebCore::Notification*) override;
58  void cancel(WebCore::Notification*) override;
59  void clearNotifications(WebCore::ScriptExecutionContext*) override;
60  void notificationObjectDestroyed(WebCore::Notification*) override;
61  void notificationControllerDestroyed() override;
62 #if ENABLE(LEGACY_NOTIFICATIONS)
63  void requestPermission(WebCore::ScriptExecutionContext*, RefPtr<WebCore::VoidCallback>&&) override;
64 #endif
65 #if ENABLE(NOTIFICATIONS)
66  void requestPermission(WebCore::ScriptExecutionContext*, RefPtr<WebCore::NotificationPermissionCallback>&&) override;
67 #endif
68  void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) override { }
69  bool hasPendingPermissionRequests(WebCore::ScriptExecutionContext*) const override;
71 
72 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
73  void requestPermission(WebCore::ScriptExecutionContext*, WebNotificationPolicyListener *);
74 #endif
75 
76  WebView *m_webView;
77 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
78  HashMap<RefPtr<WebCore::Notification>, RetainPtr<WebNotification>> m_notificationMap;
79 
80  typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<RetainPtr<WebNotification>>> NotificationContextMap;
81  NotificationContextMap m_notificationContextMap;
82 
83  bool m_everRequestedPermission { false };
84 #endif
85 };
OBJC_CLASS WebView
Definition: BackForwardList.h:34
callback VoidCallback
Definition: VoidCallback.idl:26
Permission
Definition: NotificationClient.h:46
unsigned long long uint64_t
Definition: ptypes.h:120
callback NotificationPermissionCallback
Definition: NotificationPermissionCallback.idl:28
Definition: WebNotificationClient.h:46
Definition: Notification.idl:40
Definition: ScriptExecutionContext.h:68
Definition: WebView.h:127
Definition: NotificationClient.h:44
Definition: WebNotification.h:32
WebView * webView()
Definition: WebNotificationClient.h:49
This file is generated by create-http-header-name-table, do not edit.
Definition: CharsetData.cpp:6