NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / ui / message_center / notification_delegate.h
blob475304cc2c4f16a208497644550a549cc139dfab
1 // Copyright 2013 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.
5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_
6 #define UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "ui/message_center/message_center_export.h"
14 namespace content {
15 class RenderViewHost;
18 namespace message_center {
20 // Delegate for a notification. This class has two roles: to implement callback
21 // methods for notification, and to provide an identity of the associated
22 // notification.
23 class MESSAGE_CENTER_EXPORT NotificationDelegate
24 : public base::RefCountedThreadSafe<NotificationDelegate> {
25 public:
26 // To be called when the desktop notification is actually shown.
27 virtual void Display() = 0;
29 // To be called when the desktop notification cannot be shown due to an
30 // error.
31 virtual void Error() = 0;
33 // To be called when the desktop notification is closed. If closed by a
34 // user explicitly (as opposed to timeout/script), |by_user| should be true.
35 virtual void Close(bool by_user) = 0;
37 // Returns true if the delegate can handle click event.
38 virtual bool HasClickedListener();
40 // To be called when a desktop notification is clicked.
41 virtual void Click() = 0;
43 // To be called when the user clicks a button in a notification. TODO(miket):
44 // consider providing default implementations of the pure virtuals of this
45 // interface, to avoid pinging so many OWNERs each time we enhance it.
46 virtual void ButtonClick(int button_index);
48 protected:
49 virtual ~NotificationDelegate() {}
51 private:
52 friend class base::RefCountedThreadSafe<NotificationDelegate>;
55 // A simple notification delegate which invokes the passed closure when clicked.
56 class MESSAGE_CENTER_EXPORT HandleNotificationClickedDelegate
57 : public NotificationDelegate {
58 public:
59 explicit HandleNotificationClickedDelegate(const base::Closure& closure);
61 // message_center::NotificationDelegate overrides:
62 virtual void Display() OVERRIDE;
63 virtual void Error() OVERRIDE;
64 virtual void Close(bool by_user) OVERRIDE;
65 virtual bool HasClickedListener() OVERRIDE;
66 virtual void Click() OVERRIDE;
67 virtual void ButtonClick(int button_index) OVERRIDE;
69 protected:
70 virtual ~HandleNotificationClickedDelegate();
72 private:
73 std::string id_;
74 base::Closure closure_;
76 DISALLOW_COPY_AND_ASSIGN(HandleNotificationClickedDelegate);
79 } // namespace message_center
81 #endif // UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_