15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2009 Google Inc. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met:
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution.
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * this software without specific prior written permission.
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef NotificationClient_h
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define NotificationClient_h
345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/VoidCallback.h"
3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "modules/notifications/NotificationPermissionCallback.h"
3753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "wtf/PassRefPtr.h"
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WebCore {
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
411e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)class ExecutionContext;
42a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)class NotificationBase;
435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class NotificationClient {
455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    enum Permission {
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        PermissionAllowed, // User has allowed notifications
495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        PermissionNotAllowed, // User has not yet allowed
505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        PermissionDenied // User has explicitly denied permission
515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    };
525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Requests that a notification be shown.
54a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    virtual bool show(NotificationBase*) = 0;
555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Requests that a notification that has already been shown be canceled.
57a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    virtual void cancel(NotificationBase*) = 0;
5802772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Informs the presenter that a Notification object has been destroyed
605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // (such as by a page transition). The presenter may continue showing
615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // the notification, but must not attempt to call the event handlers.
62a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    virtual void notificationObjectDestroyed(NotificationBase*) = 0;
635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#if ENABLE(LEGACY_NOTIFICATIONS)
655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Requests user permission to show desktop notifications from a particular
665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // script context. The callback parameter should be run when the user has
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // made a decision.
68a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    virtual void requestPermission(ExecutionContext*, PassOwnPtr<VoidCallback>) = 0;
695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif
70a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    virtual void requestPermission(ExecutionContext*, PassOwnPtr<NotificationPermissionCallback>) = 0;
715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Checks the current level of permission.
731e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    virtual Permission checkPermission(ExecutionContext*) = 0;
745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)protected:
765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    virtual ~NotificationClient() { }
775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace WebCore
805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // NotificationClient_h
82