| 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_notification_manager.h" | 5 #include "ui/arc/notification/arc_notification_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/system/toast/toast_manager.h" | 10 #include "ash/common/system/toast/toast_manager.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD( | 233 auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 234 arc_bridge_service()->notifications(), OpenNotificationSettings); | 234 arc_bridge_service()->notifications(), OpenNotificationSettings); |
| 235 | 235 |
| 236 // On shutdown, the ARC channel may quit earlier than notifications. | 236 // On shutdown, the ARC channel may quit earlier than notifications. |
| 237 if (!notifications_instance) | 237 if (!notifications_instance) |
| 238 return; | 238 return; |
| 239 | 239 |
| 240 notifications_instance->OpenNotificationSettings(key); | 240 notifications_instance->OpenNotificationSettings(key); |
| 241 } | 241 } |
| 242 | 242 |
| 243 bool ArcNotificationManager::IsOpeningSettingsSupported() const { |
| 244 const auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 245 arc_bridge_service()->notifications(), OpenNotificationSettings); |
| 246 return notifications_instance != nullptr; |
| 247 } |
| 248 |
| 243 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) { | 249 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) { |
| 244 const base::string16 text16( | 250 const base::string16 text16( |
| 245 base::UTF8ToUTF16(data->text.has_value() ? *data->text : std::string())); | 251 base::UTF8ToUTF16(data->text.has_value() ? *data->text : std::string())); |
| 246 const base::string16 dismiss_text16(base::UTF8ToUTF16( | 252 const base::string16 dismiss_text16(base::UTF8ToUTF16( |
| 247 data->dismiss_text.has_value() ? *data->dismiss_text : std::string())); | 253 data->dismiss_text.has_value() ? *data->dismiss_text : std::string())); |
| 248 ash::Shell::GetInstance()->toast_manager()->Show( | 254 ash::Shell::GetInstance()->toast_manager()->Show( |
| 249 ash::ToastData(data->id, text16, data->duration, dismiss_text16)); | 255 ash::ToastData(data->id, text16, data->duration, dismiss_text16)); |
| 250 } | 256 } |
| 251 | 257 |
| 252 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { | 258 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { |
| 253 ash::Shell::GetInstance()->toast_manager()->Cancel(data->id); | 259 ash::Shell::GetInstance()->toast_manager()->Cancel(data->id); |
| 254 } | 260 } |
| 255 | 261 |
| 256 } // namespace arc | 262 } // namespace arc |
| OLD | NEW |