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

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

Issue 2319893002: 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 34c13f2002dba0cd95c437c3ec9e9c15e81966dc..59be98a787d3d32796e5b068d8431788ba47c8e2 100644
--- a/ui/arc/notification/arc_notification_manager.cc
+++ b/ui/arc/notification/arc_notification_manager.cc
@@ -14,6 +14,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,
@@ -192,6 +199,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::WmShell::Get()->toast_manager()->Show(
ash::ToastData(data->id, data->text.To<base::string16>(), data->duration,
« 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