1 // Copyright (c) 2011 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. 4 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "base/memory/ref_counted.h" 12 13 // Delegate for a notification. This class has two role, to implement 14 // callback methods for notification, and provides an identify of 15 // the associated notification. 16 class NotificationDelegate 17 : public base::RefCountedThreadSafe<NotificationDelegate> { 18 public: 19 // To be called when the desktop notification is actually shown. 20 virtual void Display() = 0; 21 22 // To be called when the desktop notification cannot be shown due to an 23 // error. 24 virtual void Error() = 0; 25 26 // To be called when the desktop notification is closed. If closed by a 27 // user explicitly (as opposed to timeout/script), |by_user| should be true. 28 virtual void Close(bool by_user) = 0; 29 30 // To be called when a desktop notification is clicked. 31 virtual void Click() = 0; 32 33 // Returns unique id of the notification. 34 virtual std::string id() const = 0; 35 36 protected: 37 virtual ~NotificationDelegate() {} 38 39 private: 40 friend class base::RefCountedThreadSafe<NotificationDelegate>; 41 }; 42 43 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ 44