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

Side by Side Diff: chrome/browser/chromeos/net/tether_notification_presenter.cc

Issue 2953973002: [CrOS Tether] Remove notifications when they have been tapped. (Closed)
Patch Set: Created 3 years, 6 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 | chrome/browser/chromeos/net/tether_notification_presenter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/net/tether_notification_presenter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698