Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_ARC_NOTIFICATION_ARC_CUSTOM_DELEGATE_H_ | 5 #ifndef UI_ARC_NOTIFICATION_ARC_CUSTOM_DELEGATE_H_ |
| 6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_DELEGATE_H_ | 6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "ui/message_center/notification_delegate.h" | 10 #include "ui/message_center/notification_delegate.h" |
| 11 | 11 |
| 12 namespace message_center { | |
| 13 | |
| 14 class MessageCenterController; | |
| 15 class MessageView; | |
| 16 class Notification; | |
| 17 | |
| 18 } // namespace message_center | |
| 19 | |
| 12 namespace arc { | 20 namespace arc { |
| 13 | 21 |
| 14 class ArcNotificationItem; | 22 class ArcNotificationItem; |
| 15 | 23 |
| 16 /* | 24 /* |
| 17 * Implementation of NotificationDelegate for ARC notifications. | 25 * Implementation of NotificationDelegate for ARC notifications. |
|
hidehiko
2017/05/11 14:22:47
(Off-topic)/Style: Probably, '//' should be used h
yoshiki
2017/05/12 08:42:37
Done.
| |
| 18 */ | 26 */ |
| 19 class ArcNotificationDelegate : public message_center::NotificationDelegate { | 27 class ArcNotificationDelegate : public message_center::NotificationDelegate { |
| 20 public: | 28 public: |
| 21 explicit ArcNotificationDelegate(base::WeakPtr<ArcNotificationItem> item); | 29 explicit ArcNotificationDelegate(base::WeakPtr<ArcNotificationItem> item); |
| 22 | 30 |
| 23 // message_center::NotificationDelegate overrides: | 31 // message_center::NotificationDelegate overrides: |
| 24 std::unique_ptr<message_center::CustomContent> CreateCustomContent() override; | 32 std::unique_ptr<message_center::MessageView> CreateCustomMessageView( |
| 33 message_center::MessageCenterController* controller, | |
| 34 const message_center::Notification& notification) override; | |
| 25 void Close(bool by_user) override; | 35 void Close(bool by_user) override; |
| 26 void Click() override; | 36 void Click() override; |
| 27 | 37 |
| 28 private: | 38 private: |
| 29 // The destructor is private since this class is ref-counted. | 39 // The destructor is private since this class is ref-counted. |
| 30 ~ArcNotificationDelegate() override; | 40 ~ArcNotificationDelegate() override; |
| 31 | 41 |
| 32 // We use weak ptr to detect potential use-after-free. The lives of objects | 42 // We use weak ptr to detect potential use-after-free. The lives of objects |
| 33 // around ARC notification is somewhat complex so we want to use it until | 43 // around ARC notification is somewhat complex so we want to use it until |
| 34 // it gets stable. | 44 // it gets stable. |
| 35 base::WeakPtr<ArcNotificationItem> item_; | 45 base::WeakPtr<ArcNotificationItem> item_; |
| 36 | 46 |
| 37 DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate); | 47 DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate); |
| 38 }; | 48 }; |
| 39 | 49 |
| 40 } // namespace arc | 50 } // namespace arc |
| 41 | 51 |
| 42 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_DELEGATE_H_ | 52 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_DELEGATE_H_ |
| OLD | NEW |