Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ui/arc/notification/arc_custom_notification_item.h" | 5 #include "ui/arc/notification/arc_custom_notification_item.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "ui/arc/notification/arc_custom_notification_view.h" | 14 #include "ui/arc/notification/arc_custom_notification_view.h" |
| 15 #include "ui/message_center/notification.h" | 15 #include "ui/message_center/notification.h" |
| 16 #include "ui/message_center/notification_types.h" | 16 #include "ui/message_center/notification_types.h" |
| 17 #include "ui/message_center/views/custom_notification_content_view_delegate.h" | |
| 17 | 18 |
| 18 namespace arc { | 19 namespace arc { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 constexpr char kNotifierId[] = "ARC_NOTIFICATION"; | 23 constexpr char kNotifierId[] = "ARC_NOTIFICATION"; |
| 23 | 24 |
| 24 class ArcNotificationDelegate : public message_center::NotificationDelegate { | 25 class ArcNotificationDelegate : public message_center::NotificationDelegate { |
| 25 public: | 26 public: |
| 26 explicit ArcNotificationDelegate(ArcCustomNotificationItem* item) | 27 explicit ArcNotificationDelegate(ArcCustomNotificationItem* item) |
| 27 : item_(item) {} | 28 : item_(item) {} |
| 28 | 29 |
| 29 std::unique_ptr<views::View> CreateCustomContent() override { | 30 std::tuple< |
|
yoshiki
2016/12/02 12:15:48
Instead of using a tuple, how about creating new c
xiyuan
2016/12/02 17:45:53
+1 to this, e.g. making struct CustomContent inste
yhanada
2016/12/06 02:48:08
Created |CustomContent| struct for holding the two
| |
| 30 return base::MakeUnique<ArcCustomNotificationView>(item_); | 31 std::unique_ptr<views::View>, |
| 32 std::unique_ptr<message_center::CustomNotificationContentViewDelegate>> | |
| 33 CreateCustomContent() override { | |
| 34 auto view = base::MakeUnique<ArcCustomNotificationView>(item_); | |
| 35 auto content_view_delegate = view->CreateContentViewDelegate(); | |
| 36 return std::make_tuple(std::move(view), std::move(content_view_delegate)); | |
| 31 } | 37 } |
| 32 | 38 |
| 33 private: | 39 private: |
| 34 // The destructor is private since this class is ref-counted. | 40 // The destructor is private since this class is ref-counted. |
| 35 ~ArcNotificationDelegate() override {} | 41 ~ArcNotificationDelegate() override {} |
| 36 | 42 |
| 37 ArcCustomNotificationItem* const item_; | 43 ArcCustomNotificationItem* const item_; |
| 38 | 44 |
| 39 DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate); | 45 DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate); |
| 40 }; | 46 }; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 } | 130 } |
| 125 | 131 |
| 126 void ArcCustomNotificationItem::DecrementWindowRefCount() { | 132 void ArcCustomNotificationItem::DecrementWindowRefCount() { |
| 127 DCHECK_GT(window_ref_count_, 0); | 133 DCHECK_GT(window_ref_count_, 0); |
| 128 --window_ref_count_; | 134 --window_ref_count_; |
| 129 if (window_ref_count_ == 0) | 135 if (window_ref_count_ == 0) |
| 130 manager()->CloseNotificationWindow(notification_key()); | 136 manager()->CloseNotificationWindow(notification_key()); |
| 131 } | 137 } |
| 132 | 138 |
| 133 } // namespace arc | 139 } // namespace arc |
| OLD | NEW |