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

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

Issue 2805393002: TetherNotificationPresenter: Connect to a network when the 'Connect' button is pressed. (Closed)
Patch Set: 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 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // TODO(khorimoto): Add tether icon. 55 // TODO(khorimoto): Add tether icon.
56 gfx::Image() /* icon */, base::string16() /* display_source */, 56 gfx::Image() /* icon */, base::string16() /* display_source */,
57 GURL() /* origin_url */, 57 GURL() /* origin_url */,
58 message_center::NotifierId( 58 message_center::NotifierId(
59 message_center::NotifierId::NotifierType::SYSTEM_COMPONENT, 59 message_center::NotifierId::NotifierType::SYSTEM_COMPONENT,
60 kTetherNotifierId), 60 kTetherNotifierId),
61 rich_notification_data, nullptr); 61 rich_notification_data, nullptr);
62 } 62 }
63 63
64 TetherNotificationPresenter::TetherNotificationPresenter() 64 TetherNotificationPresenter::TetherNotificationPresenter()
65 : TetherNotificationPresenter(message_center::MessageCenter::Get()) {} 65 : TetherNotificationPresenter(message_center::MessageCenter::Get(),
66 NetworkConnect::Get()) {}
stevenjb 2017/04/10 19:55:51 We shouldn't provide this extra constructor. We sh
Ryan Hansberry 2017/04/10 22:28:55 Done.
66 67
67 TetherNotificationPresenter::TetherNotificationPresenter( 68 TetherNotificationPresenter::TetherNotificationPresenter(
68 message_center::MessageCenter* message_center) 69 message_center::MessageCenter* message_center,
69 : message_center_(message_center), weak_ptr_factory_(this) { 70 NetworkConnect* network_connect)
71 : message_center_(message_center),
72 network_connect_(network_connect),
73 weak_ptr_factory_(this) {
70 message_center_->AddObserver(this); 74 message_center_->AddObserver(this);
71 } 75 }
72 76
73 TetherNotificationPresenter::~TetherNotificationPresenter() { 77 TetherNotificationPresenter::~TetherNotificationPresenter() {
74 message_center_->RemoveObserver(this); 78 message_center_->RemoveObserver(this);
75 } 79 }
76 80
77 void TetherNotificationPresenter::NotifyPotentialHotspotNearby( 81 void TetherNotificationPresenter::NotifyPotentialHotspotNearby(
78 const cryptauth::RemoteDevice& remote_device) { 82 const cryptauth::RemoteDevice& remote_device) {
79 PA_LOG(INFO) << "Displaying \"potential hotspot nearby\" notification for " 83 PA_LOG(INFO) << "Displaying \"potential hotspot nearby\" notification for "
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // TODO(khorimoto): Open the settings page. 149 // TODO(khorimoto): Open the settings page.
146 } 150 }
147 151
148 void TetherNotificationPresenter::OnNotificationButtonClicked( 152 void TetherNotificationPresenter::OnNotificationButtonClicked(
149 const std::string& notification_id, 153 const std::string& notification_id,
150 int button_index) { 154 int button_index) {
151 PA_LOG(INFO) << "Button at index " << button_index 155 PA_LOG(INFO) << "Button at index " << button_index
152 << " of notification with ID " << notification_id 156 << " of notification with ID " << notification_id
153 << " was clicked."; 157 << " was clicked.";
154 158
155 // Only the "potential hotspot nearby" notification has a button, and it only 159 if (notification_id == kPotentialHotspotNotificationId && button_index == 0) {
156 // has one button (index 0). 160 // TODO (hansberry): Only directly start a connection if this is not the
157 DCHECK(std::string(kPotentialHotspotNotificationId) == notification_id); 161 // first time the user has connected to a host.
158 DCHECK(0 == button_index); 162 network_connect_->ConnectToNetworkId(hotspot_nearby_device_.GetDeviceId());
159 163 }
160 // TODO(khorimoto): Start a connection.
161 } 164 }
162 165
163 void TetherNotificationPresenter::ShowNotification( 166 void TetherNotificationPresenter::ShowNotification(
164 std::unique_ptr<message_center::Notification> notification) { 167 std::unique_ptr<message_center::Notification> notification) {
165 std::string notification_id = notification->id(); 168 std::string notification_id = notification->id();
166 if (message_center_->FindVisibleNotificationById(notification_id)) { 169 if (message_center_->FindVisibleNotificationById(notification_id)) {
167 message_center_->UpdateNotification(notification_id, 170 message_center_->UpdateNotification(notification_id,
168 std::move(notification)); 171 std::move(notification));
169 } else { 172 } else {
170 message_center_->AddNotification(std::move(notification)); 173 message_center_->AddNotification(std::move(notification));
171 } 174 }
172 } 175 }
173 176
174 } // namespace tether 177 } // namespace tether
175 178
176 } // namespace chromeos 179 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698