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

Unified Diff: chromeos/components/tether/tether_connector.cc

Issue 2917803002: Tether: Display a 'setup required' notification when appropriate. (Closed)
Patch Set: Rebase. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/components/tether/tether_connector.cc
diff --git a/chromeos/components/tether/tether_connector.cc b/chromeos/components/tether/tether_connector.cc
index 02cd147560589b4960b50ff46f56aba88f10dea7..7eb23adf49c332b01d4602a39b2ed32562d96d6e 100644
--- a/chromeos/components/tether/tether_connector.cc
+++ b/chromeos/components/tether/tether_connector.cc
@@ -7,9 +7,12 @@
#include "base/bind.h"
#include "chromeos/components/tether/active_host.h"
#include "chromeos/components/tether/device_id_tether_network_guid_map.h"
+#include "chromeos/components/tether/host_scan_cache.h"
+#include "chromeos/components/tether/notification_presenter.h"
#include "chromeos/components/tether/tether_host_fetcher.h"
#include "chromeos/components/tether/wifi_hotspot_connector.h"
#include "chromeos/network/network_handler.h"
+#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "components/proximity_auth/logging/logging.h"
@@ -24,7 +27,9 @@ TetherConnector::TetherConnector(
TetherHostFetcher* tether_host_fetcher,
BleConnectionManager* connection_manager,
TetherHostResponseRecorder* tether_host_response_recorder,
- DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map)
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map,
+ HostScanCache* host_scan_cache,
+ NotificationPresenter* notification_presenter)
: network_state_handler_(network_state_handler),
wifi_hotspot_connector_(wifi_hotspot_connector),
active_host_(active_host),
@@ -32,6 +37,8 @@ TetherConnector::TetherConnector(
connection_manager_(connection_manager),
tether_host_response_recorder_(tether_host_response_recorder),
device_id_tether_network_guid_map_(device_id_tether_network_guid_map),
+ host_scan_cache_(host_scan_cache),
+ notification_presenter_(notification_presenter),
weak_ptr_factory_(this) {}
TetherConnector::~TetherConnector() {
@@ -71,6 +78,13 @@ void TetherConnector::ConnectToNetwork(
device_id_pending_connection_));
}
+ if (host_scan_cache_->DoesHostRequireSetup(tether_network_guid)) {
+ const std::string& device_name =
+ network_state_handler_->GetNetworkStateFromGuid(tether_network_guid)
+ ->name();
+ notification_presenter_->NotifySetupRequired(device_name);
+ }
+
device_id_pending_connection_ = device_id;
success_callback_ = success_callback;
error_callback_ = error_callback;
@@ -185,6 +199,8 @@ void TetherConnector::OnTetherHostToConnectFetched(
DCHECK(device_id == tether_host_to_connect->GetDeviceId());
+ // TODO (hansberry): Indicate to ConnectTetheringOperation if first-time setup
+ // is required, so that it can adjust its timeout duration.
connect_tethering_operation_ =
ConnectTetheringOperation::Factory::NewInstance(
*tether_host_to_connect, connection_manager_,
@@ -197,6 +213,8 @@ void TetherConnector::SetConnectionFailed(const std::string& error_name) {
DCHECK(!device_id_pending_connection_.empty());
DCHECK(!error_callback_.is_null());
+ notification_presenter_->RemoveSetupRequiredNotification();
+
// Save a copy of the callback before resetting it below.
network_handler::StringResultCallback error_callback = error_callback_;
@@ -215,6 +233,8 @@ void TetherConnector::SetConnectionSucceeded(
DCHECK(device_id_pending_connection_ == device_id);
DCHECK(!success_callback_.is_null());
+ notification_presenter_->RemoveSetupRequiredNotification();
+
// Save a copy of the callback before resetting it below.
base::Closure success_callback = success_callback_;
« no previous file with comments | « chromeos/components/tether/tether_connector.h ('k') | chromeos/components/tether/tether_connector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698