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

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

Issue 2347293002: arc: Add InstanceHelper::GetInstanceForMethod() (Closed)
Patch Set: No more DCHECK 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 unified diff | Download patch
« no previous file with comments | « components/arc/storage_manager/arc_storage_manager.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 <memory>
8 #include <utility>
9
7 #include "ash/common/system/toast/toast_manager.h" 10 #include "ash/common/system/toast/toast_manager.h"
8 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
9 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
10 #include "base/stl_util.h" 13 #include "base/stl_util.h"
11 #include "mojo/common/common_type_converters.h" 14 #include "mojo/common/common_type_converters.h"
12 #include "ui/arc/notification/arc_custom_notification_item.h" 15 #include "ui/arc/notification/arc_custom_notification_item.h"
13 #include "ui/arc/notification/arc_notification_item.h" 16 #include "ui/arc/notification/arc_notification_item.h"
14 17
15 namespace arc { 18 namespace arc {
16 19
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 203 }
201 204
202 void ArcNotificationManager::CreateNotificationWindow(const std::string& key) { 205 void ArcNotificationManager::CreateNotificationWindow(const std::string& key) {
203 if (items_.find(key) == items_.end()) { 206 if (items_.find(key) == items_.end()) {
204 VLOG(3) << "Chrome requests to create window on notification (key: " << key 207 VLOG(3) << "Chrome requests to create window on notification (key: " << key
205 << "), but it is gone."; 208 << "), but it is gone.";
206 return; 209 return;
207 } 210 }
208 211
209 auto* notifications_instance = 212 auto* notifications_instance =
210 arc_bridge_service()->notifications()->instance(); 213 arc_bridge_service()->notifications()->GetInstanceForMethod(
211 // On shutdown, the ARC channel may quit earlier then notifications. 214 "CreateNotificationWindow", kMinVersionNotificationWindow);
212 if (!notifications_instance) { 215 if (!notifications_instance)
213 VLOG(2) << "Request to create window for ARC Notification (key: " << key
214 << "), but the ARC channel has already gone.";
215 return; 216 return;
216 }
217
218 if (arc_bridge_service()->notifications()->version() <
219 kMinVersionNotificationWindow) {
220 VLOG(2)
221 << "NotificationInstance does not support CreateNotificationWindow.";
222 return;
223 }
224 217
225 notifications_instance->CreateNotificationWindow(key); 218 notifications_instance->CreateNotificationWindow(key);
226 } 219 }
227 220
228 void ArcNotificationManager::CloseNotificationWindow(const std::string& key) { 221 void ArcNotificationManager::CloseNotificationWindow(const std::string& key) {
229 if (items_.find(key) == items_.end()) { 222 if (items_.find(key) == items_.end()) {
230 VLOG(3) << "Chrome requests to close window on notification (key: " << key 223 VLOG(3) << "Chrome requests to close window on notification (key: " << key
231 << "), but it is gone."; 224 << "), but it is gone.";
232 return; 225 return;
233 } 226 }
234 227
235 auto* notifications_instance = 228 auto* notifications_instance =
236 arc_bridge_service()->notifications()->instance(); 229 arc_bridge_service()->notifications()->GetInstanceForMethod(
237 // On shutdown, the ARC channel may quit earlier then notifications. 230 "CloseNotificationWindow", kMinVersionNotificationWindow);
238 if (!notifications_instance) { 231 if (!notifications_instance)
239 VLOG(2) << "Request to close window for ARC Notification (key: " << key
240 << "), but the ARC channel has already gone.";
241 return; 232 return;
242 }
243
244 if (arc_bridge_service()->notifications()->version() <
245 kMinVersionNotificationWindow) {
246 VLOG(2) << "NotificationInstance does not support CloseNotificationWindow.";
247 return;
248 }
249 233
250 notifications_instance->CloseNotificationWindow(key); 234 notifications_instance->CloseNotificationWindow(key);
251 } 235 }
252 236
253 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) { 237 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) {
254 ash::WmShell::Get()->toast_manager()->Show( 238 ash::WmShell::Get()->toast_manager()->Show(
255 ash::ToastData(data->id, data->text.To<base::string16>(), data->duration, 239 ash::ToastData(data->id, data->text.To<base::string16>(), data->duration,
256 data->dismiss_text.To<base::string16>())); 240 data->dismiss_text.To<base::string16>()));
257 } 241 }
258 242
259 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { 243 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) {
260 ash::WmShell::Get()->toast_manager()->Cancel(data->id); 244 ash::WmShell::Get()->toast_manager()->Cancel(data->id);
261 } 245 }
262 246
263 } // namespace arc 247 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/storage_manager/arc_storage_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698