15267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)/* 25267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * Copyright (C) 2009 Google Inc. All rights reserved. 35267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 45267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * modification, are permitted provided that the following conditions are 65267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * met: 75267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 85267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * * Redistributions of source code must retain the above copyright 95267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * notice, this list of conditions and the following disclaimer. 105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * * Redistributions in binary form must reproduce the above 115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * in the documentation and/or other materials provided with the 135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * distribution. 145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 155267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * contributors may be used to endorse or promote products derived from 165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * this software without specific prior written permission. 175267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 185267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 215267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 225267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 235267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 245267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 255267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 265267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 285267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) */ 305267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 315267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#ifndef WebNotification_h 325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#define WebNotification_h 335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 345267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "../platform/WebCommon.h" 35d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "../platform/WebPrivatePtr.h" 36d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "../platform/WebString.h" 375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "WebTextDirection.h" 385267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 3906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#if BLINK_IMPLEMENTATION 405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)namespace WTF { template <typename T> class PassRefPtr; } 415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif 425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 4351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink { 445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 45e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class Notification; 465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebURL; 475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 485267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// Represents access to a desktop notification. 495267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebNotification { 505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)public: 51d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebNotification() { } 52d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebNotification(const WebNotification& other) { assign(other); } 535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) WebNotification& operator=(const WebNotification& other) 545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) { 555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) assign(other); 565267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) return *this; 575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) } 585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 59d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) ~WebNotification() { reset(); } 605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 61d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT void reset(); 62d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT void assign(const WebNotification&); 635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 64d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Operators required to put WebNotification in an std::map. Mind that the 65d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // order of the notifications in an ordered map will be arbitrary. 66d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT bool equals(const WebNotification& other) const; 67d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT bool lessThan(const WebNotification& other) const; 685267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 6906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles) BLINK_EXPORT WebString title() const; 705267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 71d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT WebTextDirection direction() const; 72d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT WebString lang() const; 73d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT WebString body() const; 74d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT WebString tag() const; 75d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT WebURL iconURL() const; 765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 775267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Called to indicate the notification has been displayed. 78d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) BLINK_EXPORT void dispatchShowEvent(); 795267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 805267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Called to indicate an error has occurred with this notification. 8106f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles) BLINK_EXPORT void dispatchErrorEvent(const WebString& errorMessage); 825267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 83d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Called to indicate the notification has been closed. |byUser| indicates 84d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // whether it was closed by the user instead of automatically by the system. 8506f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles) BLINK_EXPORT void dispatchCloseEvent(bool byUser); 865267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 875267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Called to indicate the notification was clicked on. 8806f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles) BLINK_EXPORT void dispatchClickEvent(); 895267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 90d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // FIXME: Remove these methods once Chromium switched to the new APIs. 91d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebString replaceId() const { return tag(); } 92d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void dispatchDisplayEvent() { dispatchShowEvent(); } 93d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 9406f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#if BLINK_IMPLEMENTATION 95e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) WebNotification(Notification*); 96e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) WebNotification& operator=(Notification*); 975267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif 985267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 995267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)private: 100e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) WebPrivatePtr<Notification> m_private; 1015267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)}; 1025267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1035267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)inline bool operator==(const WebNotification& a, const WebNotification& b) 1045267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles){ 1055267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) return a.equals(b); 1065267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 1075267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1085267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)inline bool operator!=(const WebNotification& a, const WebNotification& b) 1095267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles){ 1105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) return !a.equals(b); 1115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 1125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)inline bool operator<(const WebNotification& a, const WebNotification& b) 1145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles){ 1155267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) return a.lessThan(b); 1165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 1175267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 11851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink 1195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif 121