Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: ui/arc/notification/arc_notification_manager.cc

Issue 2323533002: Merge "arc: Defer notification surface creation" (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/arc/notification/arc_notification_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/arc/notification/arc_notification_manager.cc
diff --git a/ui/arc/notification/arc_notification_manager.cc b/ui/arc/notification/arc_notification_manager.cc
index 0c226ce868260961fe77e89dbdba8ecb2b99dedb..ef70ba88a6d6d86a6c47504c6c95d385fba49acb 100644
--- a/ui/arc/notification/arc_notification_manager.cc
+++ b/ui/arc/notification/arc_notification_manager.cc
@@ -13,6 +13,13 @@
namespace arc {
+namespace {
+
+// Min version to support Create/CloseNotificationWindow.
+constexpr int kMinVersionNotificationWindow = 7;
+
+} // namespace
+
ArcNotificationManager::ArcNotificationManager(ArcBridgeService* bridge_service,
const AccountId& main_profile_id)
: ArcNotificationManager(bridge_service,
@@ -191,6 +198,57 @@ void ArcNotificationManager::SendNotificationButtonClickedOnChrome(
notifications_instance->SendNotificationEventToAndroid(key, command);
}
+void ArcNotificationManager::CreateNotificationWindow(const std::string& key) {
+ if (items_.find(key) == items_.end()) {
+ VLOG(3) << "Chrome requests to create window on notification (key: " << key
+ << "), but it is gone.";
+ return;
+ }
+
+ auto* notifications_instance =
+ arc_bridge_service()->notifications()->instance();
+ // On shutdown, the ARC channel may quit earlier then notifications.
+ if (!notifications_instance) {
+ VLOG(2) << "Request to create window for ARC Notification (key: " << key
+ << "), but the ARC channel has already gone.";
+ return;
+ }
+
+ if (arc_bridge_service()->notifications()->version() <
+ kMinVersionNotificationWindow) {
+ VLOG(2)
+ << "NotificationInstance does not support CreateNotificationWindow.";
+ return;
+ }
+
+ notifications_instance->CreateNotificationWindow(key);
+}
+
+void ArcNotificationManager::CloseNotificationWindow(const std::string& key) {
+ if (items_.find(key) == items_.end()) {
+ VLOG(3) << "Chrome requests to close window on notification (key: " << key
+ << "), but it is gone.";
+ return;
+ }
+
+ auto* notifications_instance =
+ arc_bridge_service()->notifications()->instance();
+ // On shutdown, the ARC channel may quit earlier then notifications.
+ if (!notifications_instance) {
+ VLOG(2) << "Request to close window for ARC Notification (key: " << key
+ << "), but the ARC channel has already gone.";
+ return;
+ }
+
+ if (arc_bridge_service()->notifications()->version() <
+ kMinVersionNotificationWindow) {
+ VLOG(2) << "NotificationInstance does not support CloseNotificationWindow.";
+ return;
+ }
+
+ notifications_instance->CloseNotificationWindow(key);
+}
+
void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) {
ash::Shell::GetInstance()->toast_manager()->Show(
ash::ToastData(data->id, data->text, data->duration, data->dismiss_text));
« no previous file with comments | « ui/arc/notification/arc_notification_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698