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

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: for comments in #2 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
« no previous file with comments | « ui/arc/notification/arc_notification_item.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
16 // Whether to use custom notification.
17 constexpr bool use_custom_notification = true;
yoshiki 2016/06/16 02:44:50 We use custom notification only for non-standard n
xiyuan 2016/06/20 23:04:58 Added a use_custom_notification field to notificat
18
15 ArcNotificationManager::ArcNotificationManager(ArcBridgeService* bridge_service, 19 ArcNotificationManager::ArcNotificationManager(ArcBridgeService* bridge_service,
16 const AccountId& main_profile_id) 20 const AccountId& main_profile_id)
17 : ArcNotificationManager(bridge_service, 21 : ArcNotificationManager(bridge_service,
18 main_profile_id, 22 main_profile_id,
19 message_center::MessageCenter::Get()) {} 23 message_center::MessageCenter::Get()) {}
20 24
21 ArcNotificationManager::ArcNotificationManager( 25 ArcNotificationManager::ArcNotificationManager(
22 ArcBridgeService* bridge_service, 26 ArcBridgeService* bridge_service,
23 const AccountId& main_profile_id, 27 const AccountId& main_profile_id,
24 message_center::MessageCenter* message_center) 28 message_center::MessageCenter* message_center)
(...skipping 30 matching lines...) Expand all
55 item->OnClosedFromAndroid(false /* by_user */); 59 item->OnClosedFromAndroid(false /* by_user */);
56 } 60 }
57 ready_ = false; 61 ready_ = false;
58 } 62 }
59 63
60 void ArcNotificationManager::OnNotificationPosted( 64 void ArcNotificationManager::OnNotificationPosted(
61 mojom::ArcNotificationDataPtr data) { 65 mojom::ArcNotificationDataPtr data) {
62 const std::string& key = data->key; 66 const std::string& key = data->key;
63 auto it = items_.find(key); 67 auto it = items_.find(key);
64 if (it == items_.end()) { 68 if (it == items_.end()) {
65 // Show a notification on the primary loged-in user's desktop. 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
« no previous file with comments | « ui/arc/notification/arc_notification_item.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698