OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/chromeos/net/tether_notification_presenter.h" | 5 #include "chrome/browser/chromeos/net/tether_notification_presenter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 message_center_->RemoveNotification(std::string(kActiveHostNotificationId), | 185 message_center_->RemoveNotification(std::string(kActiveHostNotificationId), |
186 false /* by_user */); | 186 false /* by_user */); |
187 } | 187 } |
188 | 188 |
189 void TetherNotificationPresenter::OnNotificationClicked( | 189 void TetherNotificationPresenter::OnNotificationClicked( |
190 const std::string& notification_id) { | 190 const std::string& notification_id) { |
191 PA_LOG(INFO) << "Notification with ID " << notification_id << " was clicked."; | 191 PA_LOG(INFO) << "Notification with ID " << notification_id << " was clicked."; |
192 settings_ui_delegate_->ShowSettingsSubPageForProfile(profile_, | 192 settings_ui_delegate_->ShowSettingsSubPageForProfile(profile_, |
193 kTetherSettingsSubpage); | 193 kTetherSettingsSubpage); |
| 194 message_center_->RemoveNotification(notification_id, true /* by_user */); |
194 } | 195 } |
195 | 196 |
196 void TetherNotificationPresenter::OnNotificationButtonClicked( | 197 void TetherNotificationPresenter::OnNotificationButtonClicked( |
197 const std::string& notification_id, | 198 const std::string& notification_id, |
198 int button_index) { | 199 int button_index) { |
199 PA_LOG(INFO) << "Button at index " << button_index | 200 PA_LOG(INFO) << "Button at index " << button_index |
200 << " of notification with ID " << notification_id | 201 << " of notification with ID " << notification_id |
201 << " was clicked."; | 202 << " was clicked."; |
202 | 203 |
203 if (notification_id == kPotentialHotspotNotificationId && button_index == 0) { | 204 if (notification_id == kPotentialHotspotNotificationId && button_index == 0) { |
204 network_connect_->ConnectToNetworkId(hotspot_nearby_device_.GetDeviceId()); | 205 network_connect_->ConnectToNetworkId(hotspot_nearby_device_.GetDeviceId()); |
205 } | 206 } |
| 207 message_center_->RemoveNotification(notification_id, true /* by_user */); |
206 } | 208 } |
207 | 209 |
208 void TetherNotificationPresenter::SetSettingsUiDelegateForTesting( | 210 void TetherNotificationPresenter::SetSettingsUiDelegateForTesting( |
209 std::unique_ptr<SettingsUiDelegate> settings_ui_delegate) { | 211 std::unique_ptr<SettingsUiDelegate> settings_ui_delegate) { |
210 settings_ui_delegate_ = std::move(settings_ui_delegate); | 212 settings_ui_delegate_ = std::move(settings_ui_delegate); |
211 } | 213 } |
212 | 214 |
213 void TetherNotificationPresenter::ShowNotification( | 215 void TetherNotificationPresenter::ShowNotification( |
214 std::unique_ptr<message_center::Notification> notification) { | 216 std::unique_ptr<message_center::Notification> notification) { |
215 std::string notification_id = notification->id(); | 217 std::string notification_id = notification->id(); |
216 if (message_center_->FindVisibleNotificationById(notification_id)) { | 218 if (message_center_->FindVisibleNotificationById(notification_id)) { |
217 message_center_->UpdateNotification(notification_id, | 219 message_center_->UpdateNotification(notification_id, |
218 std::move(notification)); | 220 std::move(notification)); |
219 } else { | 221 } else { |
220 message_center_->AddNotification(std::move(notification)); | 222 message_center_->AddNotification(std::move(notification)); |
221 } | 223 } |
222 } | 224 } |
223 | 225 |
224 } // namespace tether | 226 } // namespace tether |
225 | 227 |
226 } // namespace chromeos | 228 } // namespace chromeos |
OLD | NEW |