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

Side by Side Diff: ui/arc/notification/arc_notification_manager.cc

Issue 2066853002: arc: Show custom notification via notification surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-exo
Patch Set: add comment for use_custom_notification Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/toast/toast_manager.h" 8 #include "ash/system/toast/toast_manager.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "ui/arc/notification/arc_custom_notification_item.h"
11 #include "ui/arc/notification/arc_notification_item.h" 12 #include "ui/arc/notification/arc_notification_item.h"
12 13
13 namespace arc { 14 namespace arc {
14 15
15 ArcNotificationManager::ArcNotificationManager(ArcBridgeService* bridge_service, 16 ArcNotificationManager::ArcNotificationManager(ArcBridgeService* bridge_service,
16 const AccountId& main_profile_id) 17 const AccountId& main_profile_id)
17 : ArcNotificationManager(bridge_service, 18 : ArcNotificationManager(bridge_service,
18 main_profile_id, 19 main_profile_id,
19 message_center::MessageCenter::Get()) {} 20 message_center::MessageCenter::Get()) {}
20 21
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 item->OnClosedFromAndroid(false /* by_user */); 56 item->OnClosedFromAndroid(false /* by_user */);
56 } 57 }
57 ready_ = false; 58 ready_ = false;
58 } 59 }
59 60
60 void ArcNotificationManager::OnNotificationPosted( 61 void ArcNotificationManager::OnNotificationPosted(
61 mojom::ArcNotificationDataPtr data) { 62 mojom::ArcNotificationDataPtr data) {
62 const std::string& key = data->key; 63 const std::string& key = data->key;
63 auto it = items_.find(key); 64 auto it = items_.find(key);
64 if (it == items_.end()) { 65 if (it == items_.end()) {
65 // Show a notification on the primary loged-in user's desktop. 66 // Old client with version < 5 would have use_custom_notification default,
67 // which is false.
68 const bool use_custom_notification = data->use_custom_notification;
69 // Show a notification on the primary logged-in user's desktop.
66 // TODO(yoshiki): Reconsider when ARC supports multi-user. 70 // TODO(yoshiki): Reconsider when ARC supports multi-user.
67 ArcNotificationItem* item = 71 ArcNotificationItem* item =
68 new ArcNotificationItem(this, message_center_, key, main_profile_id_); 72 use_custom_notification
73 ? new ArcCustomNotificationItem(this, message_center_, key,
74 main_profile_id_)
75 : new ArcNotificationItem(this, message_center_, key,
76 main_profile_id_);
69 // TODO(yoshiki): Use emplacement for performance when it's available. 77 // TODO(yoshiki): Use emplacement for performance when it's available.
70 auto result = items_.insert(std::make_pair(key, base::WrapUnique(item))); 78 auto result = items_.insert(std::make_pair(key, base::WrapUnique(item)));
71 DCHECK(result.second); 79 DCHECK(result.second);
72 it = result.first; 80 it = result.first;
73 } 81 }
74 it->second->UpdateWithArcNotificationData(*data); 82 it->second->UpdateWithArcNotificationData(*data);
75 } 83 }
76 84
77 void ArcNotificationManager::OnNotificationRemoved(const mojo::String& key) { 85 void ArcNotificationManager::OnNotificationRemoved(const mojo::String& key) {
78 auto it = items_.find(key.get()); 86 auto it = items_.find(key.get());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) { 189 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) {
182 ash::Shell::GetInstance()->toast_manager()->Show( 190 ash::Shell::GetInstance()->toast_manager()->Show(
183 ash::ToastData(data->id, data->text, data->duration, data->dismiss_text)); 191 ash::ToastData(data->id, data->text, data->duration, data->dismiss_text));
184 } 192 }
185 193
186 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { 194 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) {
187 ash::Shell::GetInstance()->toast_manager()->Cancel(data->id); 195 ash::Shell::GetInstance()->toast_manager()->Cancel(data->id);
188 } 196 }
189 197
190 } // namespace arc 198 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698