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

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

Issue 2269403004: arc: Defer notification surface creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix compile Created 4 years, 4 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
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 f482ff719f423a77234491967ebb4a40ee4dc953..601298f308c5f22dcf3c3a05a8367a7124ae2995 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::WmShell::Get()->toast_manager()->Show(
ash::ToastData(data->id, data->text, data->duration, data->dismiss_text));

Powered by Google App Engine
This is Rietveld 408576698