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

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

Issue 2183283002: ui/arc/notification: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | 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/common/system/toast/toast_manager.h" 7 #include "ash/common/system/toast/toast_manager.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.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"
(...skipping 19 matching lines...) Expand all
30 arc_bridge_service()->notifications()->AddObserver(this); 30 arc_bridge_service()->notifications()->AddObserver(this);
31 } 31 }
32 32
33 ArcNotificationManager::~ArcNotificationManager() { 33 ArcNotificationManager::~ArcNotificationManager() {
34 arc_bridge_service()->notifications()->RemoveObserver(this); 34 arc_bridge_service()->notifications()->RemoveObserver(this);
35 } 35 }
36 36
37 void ArcNotificationManager::OnInstanceReady() { 37 void ArcNotificationManager::OnInstanceReady() {
38 DCHECK(!ready_); 38 DCHECK(!ready_);
39 39
40 auto notifications_instance = 40 auto* notifications_instance =
41 arc_bridge_service()->notifications()->instance(); 41 arc_bridge_service()->notifications()->instance();
42 if (!notifications_instance) { 42 if (!notifications_instance) {
43 VLOG(2) << "Request to refresh app list when bridge service is not ready."; 43 VLOG(2) << "Request to refresh app list when bridge service is not ready.";
44 return; 44 return;
45 } 45 }
46 46
47 notifications_instance->Init(binding_.CreateInterfacePtrAndBind()); 47 notifications_instance->Init(binding_.CreateInterfacePtrAndBind());
48 ready_ = true; 48 ready_ = true;
49 } 49 }
50 50
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 VLOG(3) << "Chrome requests to remove a notification (key: " << key 103 VLOG(3) << "Chrome requests to remove a notification (key: " << key
104 << "), but it is already gone."; 104 << "), but it is already gone.";
105 return; 105 return;
106 } 106 }
107 107
108 // The removed ArcNotificationItem needs to live in this scope, since the 108 // The removed ArcNotificationItem needs to live in this scope, since the
109 // given argument |key| may be a part of the removed item. 109 // given argument |key| may be a part of the removed item.
110 std::unique_ptr<ArcNotificationItem> item = std::move(it->second); 110 std::unique_ptr<ArcNotificationItem> item = std::move(it->second);
111 items_.erase(it); 111 items_.erase(it);
112 112
113 auto notifications_instance = 113 auto* notifications_instance =
114 arc_bridge_service()->notifications()->instance(); 114 arc_bridge_service()->notifications()->instance();
115 115
116 // On shutdown, the ARC channel may quit earlier then notifications. 116 // On shutdown, the ARC channel may quit earlier then notifications.
117 if (!notifications_instance) { 117 if (!notifications_instance) {
118 VLOG(2) << "ARC Notification (key: " << key 118 VLOG(2) << "ARC Notification (key: " << key
119 << ") is closed, but the ARC channel has already gone."; 119 << ") is closed, but the ARC channel has already gone.";
120 return; 120 return;
121 } 121 }
122 122
123 notifications_instance->SendNotificationEventToAndroid( 123 notifications_instance->SendNotificationEventToAndroid(
124 key, mojom::ArcNotificationEvent::CLOSED); 124 key, mojom::ArcNotificationEvent::CLOSED);
125 } 125 }
126 126
127 void ArcNotificationManager::SendNotificationClickedOnChrome( 127 void ArcNotificationManager::SendNotificationClickedOnChrome(
128 const std::string& key) { 128 const std::string& key) {
129 if (items_.find(key) == items_.end()) { 129 if (items_.find(key) == items_.end()) {
130 VLOG(3) << "Chrome requests to fire a click event on notification (key: " 130 VLOG(3) << "Chrome requests to fire a click event on notification (key: "
131 << key << "), but it is gone."; 131 << key << "), but it is gone.";
132 return; 132 return;
133 } 133 }
134 134
135 auto notifications_instance = 135 auto* notifications_instance =
136 arc_bridge_service()->notifications()->instance(); 136 arc_bridge_service()->notifications()->instance();
137 137
138 // On shutdown, the ARC channel may quit earlier then notifications. 138 // On shutdown, the ARC channel may quit earlier then notifications.
139 if (!notifications_instance) { 139 if (!notifications_instance) {
140 VLOG(2) << "ARC Notification (key: " << key 140 VLOG(2) << "ARC Notification (key: " << key
141 << ") is clicked, but the ARC channel has already gone."; 141 << ") is clicked, but the ARC channel has already gone.";
142 return; 142 return;
143 } 143 }
144 144
145 notifications_instance->SendNotificationEventToAndroid( 145 notifications_instance->SendNotificationEventToAndroid(
146 key, mojom::ArcNotificationEvent::BODY_CLICKED); 146 key, mojom::ArcNotificationEvent::BODY_CLICKED);
147 } 147 }
148 148
149 void ArcNotificationManager::SendNotificationButtonClickedOnChrome( 149 void ArcNotificationManager::SendNotificationButtonClickedOnChrome(
150 const std::string& key, 150 const std::string& key,
151 int button_index) { 151 int button_index) {
152 if (items_.find(key) == items_.end()) { 152 if (items_.find(key) == items_.end()) {
153 VLOG(3) << "Chrome requests to fire a click event on notification (key: " 153 VLOG(3) << "Chrome requests to fire a click event on notification (key: "
154 << key << "), but it is gone."; 154 << key << "), but it is gone.";
155 return; 155 return;
156 } 156 }
157 157
158 auto notifications_instance = 158 auto* notifications_instance =
159 arc_bridge_service()->notifications()->instance(); 159 arc_bridge_service()->notifications()->instance();
160 160
161 // On shutdown, the ARC channel may quit earlier then notifications. 161 // On shutdown, the ARC channel may quit earlier then notifications.
162 if (!notifications_instance) { 162 if (!notifications_instance) {
163 VLOG(2) << "ARC Notification (key: " << key 163 VLOG(2) << "ARC Notification (key: " << key
164 << ")'s button is clicked, but the ARC channel has already gone."; 164 << ")'s button is clicked, but the ARC channel has already gone.";
165 return; 165 return;
166 } 166 }
167 167
168 arc::mojom::ArcNotificationEvent command; 168 arc::mojom::ArcNotificationEvent command;
(...skipping 25 matching lines...) Expand all
194 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) { 194 void ArcNotificationManager::OnToastPosted(mojom::ArcToastDataPtr data) {
195 ash::WmShell::Get()->toast_manager()->Show( 195 ash::WmShell::Get()->toast_manager()->Show(
196 ash::ToastData(data->id, data->text, data->duration, data->dismiss_text)); 196 ash::ToastData(data->id, data->text, data->duration, data->dismiss_text));
197 } 197 }
198 198
199 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) { 199 void ArcNotificationManager::OnToastCancelled(mojom::ArcToastDataPtr data) {
200 ash::WmShell::Get()->toast_manager()->Cancel(data->id); 200 ash::WmShell::Get()->toast_manager()->Cancel(data->id);
201 } 201 }
202 202
203 } // namespace arc 203 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698