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

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

Issue 1603753003: Support buttons on ARC Notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 years, 10 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_manager.h ('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 "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "ui/arc/notification/arc_notification_item.h" 8 #include "ui/arc/notification/arc_notification_item.h"
9 9
10 namespace arc { 10 namespace arc {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 data->key, main_profile_id_); 49 data->key, main_profile_id_);
50 items_.set(data->key, make_scoped_ptr(item)); 50 items_.set(data->key, make_scoped_ptr(item));
51 } 51 }
52 item->UpdateWithArcNotificationData(*data); 52 item->UpdateWithArcNotificationData(*data);
53 } 53 }
54 54
55 void ArcNotificationManager::OnNotificationRemoved(const mojo::String& key) { 55 void ArcNotificationManager::OnNotificationRemoved(const mojo::String& key) {
56 ItemMap::iterator it = items_.find(key.get()); 56 ItemMap::iterator it = items_.find(key.get());
57 if (it == items_.end()) { 57 if (it == items_.end()) {
58 VLOG(3) << "Android requests to remove a notification (key: " << key 58 VLOG(3) << "Android requests to remove a notification (key: " << key
59 << "), but it is already gone."; 59 << "), but it has already gone.";
dcheng 2016/01/26 08:42:08 Nit: "it is" here and elsewhere is probably more i
60 return; 60 return;
61 } 61 }
62 62
63 scoped_ptr<ArcNotificationItem> item(items_.take_and_erase(it)); 63 scoped_ptr<ArcNotificationItem> item(items_.take_and_erase(it));
64 item->OnClosedFromAndroid(); 64 item->OnClosedFromAndroid();
65 } 65 }
66 66
67 void ArcNotificationManager::SendNotificationRemovedFromChrome( 67 void ArcNotificationManager::SendNotificationRemovedFromChrome(
68 const std::string& key) { 68 const std::string& key) {
69 ItemMap::iterator it = items_.find(key); 69 ItemMap::iterator it = items_.find(key);
70 if (it == items_.end()) { 70 if (it == items_.end()) {
71 VLOG(3) << "Chrome requests to remove a notification (key: " << key 71 VLOG(3) << "Chrome requests to remove a notification (key: " << key
72 << "), but it is already gone."; 72 << "), but it has already gone.";
73 return; 73 return;
74 } 74 }
75 75
76 scoped_ptr<ArcNotificationItem> item(items_.take_and_erase(it)); 76 scoped_ptr<ArcNotificationItem> item(items_.take_and_erase(it));
77 77
78 arc_bridge_->notifications_instance()->SendNotificationEventToAndroid( 78 arc_bridge_->notifications_instance()->SendNotificationEventToAndroid(
79 key, ARC_NOTIFICATION_EVENT_CLOSED); 79 key, ARC_NOTIFICATION_EVENT_CLOSED);
80 } 80 }
81 81
82 void ArcNotificationManager::SendNotificationClickedOnChrome( 82 void ArcNotificationManager::SendNotificationClickedOnChrome(
83 const std::string& key) { 83 const std::string& key) {
84 if (!items_.contains(key)) { 84 if (!items_.contains(key)) {
85 VLOG(3) << "Chrome requests to fire a click event on notification (key: " 85 VLOG(3) << "Chrome requests to fire a click event on notification (key: "
86 << key << "), but it is gone."; 86 << key << "), but it has gone.";
87 return; 87 return;
88 } 88 }
89 89
90 arc_bridge_->notifications_instance()->SendNotificationEventToAndroid( 90 arc_bridge_->notifications_instance()->SendNotificationEventToAndroid(
91 key, ARC_NOTIFICATION_EVENT_BODY_CLICKED); 91 key, ARC_NOTIFICATION_EVENT_BODY_CLICKED);
92 } 92 }
93 93
94 void ArcNotificationManager::SendNotificationButtonClickedOnChrome(
95 const std::string& key, int button_index) {
96 if (!items_.contains(key)) {
97 VLOG(3) << "Chrome requests to fire a click event on notification (key: "
98 << key << "), but it has gone.";
99 return;
100 }
101
102 arc::ArcNotificationEvent command;
103 switch (button_index) {
104 case 0:
105 command = ARC_NOTIFICATION_EVENT_BUTTON1_CLICKED;
106 break;
107 case 1:
108 command = ARC_NOTIFICATION_EVENT_BUTTON2_CLICKED;
109 break;
110 case 2:
111 command = ARC_NOTIFICATION_EVENT_BUTTON3_CLICKED;
112 break;
113 case 3:
114 command = ARC_NOTIFICATION_EVENT_BUTTON4_CLICKED;
115 break;
116 case 4:
117 command = ARC_NOTIFICATION_EVENT_BUTTON5_CLICKED;
118 break;
119 default:
120 VLOG(3) << "Invalid button index (key: " << key << ", index: " <<
121 button_index << ").";
122 return;
123 }
124
125 arc_bridge_->notifications_instance()->SendNotificationEventToAndroid(
126 key, command);
127 }
128
94 } // namespace arc 129 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_notification_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698