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

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

Issue 2767253005: Implement TOGGLE_EXPANSION action for the ARC notifications. (Closed)
Patch Set: rebase Created 3 years, 8 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/system/toast/toast_manager.h" 10 #include "ash/common/system/toast/toast_manager.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 notifications_instance->OpenNotificationSettings(key); 240 notifications_instance->OpenNotificationSettings(key);
241 } 241 }
242 242
243 bool ArcNotificationManager::IsOpeningSettingsSupported() const { 243 bool ArcNotificationManager::IsOpeningSettingsSupported() const {
244 const auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD( 244 const auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD(
245 arc_bridge_service()->notifications(), OpenNotificationSettings); 245 arc_bridge_service()->notifications(), OpenNotificationSettings);
246 return notifications_instance != nullptr; 246 return notifications_instance != nullptr;
247 } 247 }
248 248
249 void ArcNotificationManager::SendNotificationToggleExpansionOnChrome(
250 const std::string& key) {
251 if (items_.find(key) == items_.end()) {
252 VLOG(3) << "Chrome requests to fire a click event on notification (key: "
253 << key << "), but it is gone.";
254 return;
255 }
256
257 auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD(
258 arc_bridge_service()->notifications(), SendNotificationEventToAndroid);
259
260 // On shutdown, the ARC channel may quit earlier than notifications.
261 if (!notifications_instance) {
262 VLOG(2) << "ARC Notification (key: " << key
263 << ") is clicked, but the ARC channel has already gone.";
264 return;
265 }
266
267 notifications_instance->SendNotificationEventToAndroid(
268 key, mojom::ArcNotificationEvent::TOGGLE_EXPANSION);
269 }
270
249 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) { 271 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) {
250 const base::string16 text16( 272 const base::string16 text16(
251 base::UTF8ToUTF16(data->text.has_value() ? *data->text : std::string())); 273 base::UTF8ToUTF16(data->text.has_value() ? *data->text : std::string()));
252 const base::string16 dismiss_text16(base::UTF8ToUTF16( 274 const base::string16 dismiss_text16(base::UTF8ToUTF16(
253 data->dismiss_text.has_value() ? *data->dismiss_text : std::string())); 275 data->dismiss_text.has_value() ? *data->dismiss_text : std::string()));
254 ash::Shell::GetInstance()->toast_manager()->Show( 276 ash::Shell::GetInstance()->toast_manager()->Show(
255 ash::ToastData(data->id, text16, data->duration, dismiss_text16)); 277 ash::ToastData(data->id, text16, data->duration, dismiss_text16));
256 } 278 }
257 279
258 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { 280 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) {
259 ash::Shell::GetInstance()->toast_manager()->Cancel(data->id); 281 ash::Shell::GetInstance()->toast_manager()->Cancel(data->id);
260 } 282 }
261 283
262 } // namespace arc 284 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_notification_manager.h ('k') | ui/message_center/views/custom_notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698