Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / message_center / notification_delegate.h
blob8196e98eca10ae9588de55d1aa6cd48a53134017
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();
29 // To be called when the desktop notification is closed. If closed by a
30 // user explicitly (as opposed to timeout/script), |by_user| should be true.
31 virtual void Close(bool by_user);
33 // Returns true if the delegate can handle click event.
34 virtual bool HasClickedListener();
36 // To be called when a desktop notification is clicked.
37 virtual void Click();
39 // To be called when the user clicks a button in a notification.
40 virtual void ButtonClick(int button_index);
42 protected:
43 virtual ~NotificationDelegate() {}
45 private:
46 friend class base::RefCountedThreadSafe<NotificationDelegate>;
49 // A simple notification delegate which invokes the passed closure when clicked.
50 class MESSAGE_CENTER_EXPORT HandleNotificationClickedDelegate
51 : public NotificationDelegate {
52 public:
53 explicit HandleNotificationClickedDelegate(const base::Closure& closure);
55 // message_center::NotificationDelegate overrides:
56 void Click() override;
57 bool HasClickedListener() override;
59 protected:
60 ~HandleNotificationClickedDelegate() override;
62 private:
63 std::string id_;
64 base::Closure closure_;
66 DISALLOW_COPY_AND_ASSIGN(HandleNotificationClickedDelegate);
69 // A notification delegate which invokes a callback when a notification button
70 // has been clicked.
71 class MESSAGE_CENTER_EXPORT HandleNotificationButtonClickDelegate
72 : public NotificationDelegate {
73 public:
74 typedef base::Callback<void(int)> ButtonClickCallback;
76 explicit HandleNotificationButtonClickDelegate(
77 const ButtonClickCallback& button_callback);
79 // message_center::NotificationDelegate overrides:
80 void ButtonClick(int button_index) override;
82 protected:
83 ~HandleNotificationButtonClickDelegate() override;
85 private:
86 ButtonClickCallback button_callback_;
88 DISALLOW_COPY_AND_ASSIGN(HandleNotificationButtonClickDelegate);
91 } // namespace message_center
93 #endif // UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_