| 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::unique_ptr<message_center::CustomContent> CreateCustomContent() |
| 30 return base::MakeUnique<ArcCustomNotificationView>(item_); | 31 override { |
| 32 auto view = base::MakeUnique<ArcCustomNotificationView>(item_); |
| 33 auto content_view_delegate = view->CreateContentViewDelegate(); |
| 34 return base::MakeUnique<message_center::CustomContent>( |
| 35 std::move(view), std::move(content_view_delegate)); |
| 31 } | 36 } |
| 32 | 37 |
| 33 private: | 38 private: |
| 34 // The destructor is private since this class is ref-counted. | 39 // The destructor is private since this class is ref-counted. |
| 35 ~ArcNotificationDelegate() override {} | 40 ~ArcNotificationDelegate() override {} |
| 36 | 41 |
| 37 ArcCustomNotificationItem* const item_; | 42 ArcCustomNotificationItem* const item_; |
| 38 | 43 |
| 39 DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate); | 44 DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate); |
| 40 }; | 45 }; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 129 } |
| 125 | 130 |
| 126 void ArcCustomNotificationItem::DecrementWindowRefCount() { | 131 void ArcCustomNotificationItem::DecrementWindowRefCount() { |
| 127 DCHECK_GT(window_ref_count_, 0); | 132 DCHECK_GT(window_ref_count_, 0); |
| 128 --window_ref_count_; | 133 --window_ref_count_; |
| 129 if (window_ref_count_ == 0) | 134 if (window_ref_count_ == 0) |
| 130 manager()->CloseNotificationWindow(notification_key()); | 135 manager()->CloseNotificationWindow(notification_key()); |
| 131 } | 136 } |
| 132 | 137 |
| 133 } // namespace arc | 138 } // namespace arc |
| OLD | NEW |