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
3 // found in the LICENSE file.
4 
5 #include "ash/public/cpp/external_arc/message_center/arc_notification_delegate.h"
6 
7 #include "ash/public/cpp/external_arc/message_center/arc_notification_content_view.h"
8 #include "ash/public/cpp/external_arc/message_center/arc_notification_item.h"
9 #include "ash/public/cpp/external_arc/message_center/arc_notification_view.h"
10 #include "ui/message_center/public/cpp/notification.h"
11 #include "ui/message_center/views/message_view.h"
12 
13 namespace ash {
14 
ArcNotificationDelegate(base::WeakPtr<ArcNotificationItem> item)15 ArcNotificationDelegate::ArcNotificationDelegate(
16     base::WeakPtr<ArcNotificationItem> item)
17     : item_(item) {
18   DCHECK(item_);
19 }
20 
21 ArcNotificationDelegate::~ArcNotificationDelegate() = default;
22 
23 std::unique_ptr<message_center::MessageView>
CreateCustomMessageView(const message_center::Notification & notification)24 ArcNotificationDelegate::CreateCustomMessageView(
25     const message_center::Notification& notification) {
26   CHECK(item_);
27   DCHECK_EQ(item_->GetNotificationId(), notification.id());
28   return std::make_unique<ArcNotificationView>(item_.get(), notification);
29 }
30 
Close(bool by_user)31 void ArcNotificationDelegate::Close(bool by_user) {
32   DCHECK(item_);
33   item_->Close(by_user);
34 }
35 
Click(const base::Optional<int> & button_index,const base::Optional<base::string16> & reply)36 void ArcNotificationDelegate::Click(
37     const base::Optional<int>& button_index,
38     const base::Optional<base::string16>& reply) {
39   DCHECK(item_);
40   item_->Click();
41 }
42 
SettingsClick()43 void ArcNotificationDelegate::SettingsClick() {
44   DCHECK(item_);
45   item_->OpenSettings();
46 }
47 
48 }  // namespace ash
49