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

Unified Diff: chromeos/network/network_state_handler.cc

Issue 2701463003: Create a Tether section in the system tray network list. (Closed)
Patch Set: Use NetworkStateHandler::GetTechnologyState and explicitly fetch the Tether networks in NetworkList… Created 3 years, 10 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
« no previous file with comments | « chromeos/network/network_state_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_state_handler.cc
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index cb8e51d850e9130f4b0ab7af79679cd49738a885..436b382be870cd2adcd73a4ae267bfac63840785 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/format_macros.h"
#include "base/guid.h"
#include "base/json/json_string_value_serializer.h"
@@ -19,6 +20,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
+#include "chromeos/chromeos_switches.h"
#include "chromeos/network/device_state.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
@@ -133,7 +135,18 @@ NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState(
state = TECHNOLOGY_UNINITIALIZED;
else if (shill_property_handler_->IsTechnologyAvailable(technology))
state = TECHNOLOGY_AVAILABLE;
- else
+ else if (technology == kTypeTether) {
Ryan Hansberry 2017/02/16 22:42:20 (holding off on writing a test until I get the cle
+ bool isTetherAvailable = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableTether);
+ if (isTetherAvailable) {
+ // TODO (hansberry): Figure this one out.
+ bool isTetherEnabled = true;
+ if (isTetherEnabled) {
+ return TECHNOLOGY_ENABLED;
+ }
+ return TECHNOLOGY_AVAILABLE;
+ }
+ } else
state = TECHNOLOGY_UNAVAILABLE;
VLOG(2) << "GetTechnologyState: " << type.ToDebugString() << " = " << state;
return state;
@@ -200,6 +213,10 @@ bool NetworkStateHandler::GetScanningByType(
const NetworkState* NetworkStateHandler::GetNetworkState(
const std::string& service_path) const {
const NetworkState* network = GetModifiableNetworkState(service_path);
+ // This is a hack that I don't intend to keep here.
+ if (!network) {
+ return GetNetworkStateFromGuid(service_path);
+ }
if (network && !network->update_received())
return nullptr;
return network;
@@ -289,6 +306,16 @@ void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type,
DCHECK(list);
list->clear();
int count = 0;
+
+ if (NetworkTypePattern::Tether().MatchesPattern(type)) {
Ryan Hansberry 2017/02/16 22:42:20 Should there actually just be a GetTetherNetworkLi
Ryan Hansberry 2017/02/17 19:29:42 Ping.
stevenjb 2017/02/17 20:11:10 That seems fine also, although this would allow us
Ryan Hansberry 2017/02/17 23:28:13 Done.
+ for (auto iter = tether_network_list_.begin();
+ iter != tether_network_list_.end(); ++iter) {
+ list->push_back((*iter)->AsNetworkState());
+ if (limit > 0 && ++count >= limit)
+ return;
+ }
+ }
+
// Sort the network list if necessary.
if (!network_list_sorted_)
SortNetworkList();
@@ -1028,6 +1055,9 @@ std::string NetworkStateHandler::GetTechnologyForType(
if (type.MatchesType(shill::kTypeCellular))
return shill::kTypeCellular;
+ if (type.MatchesType(kTypeTether))
+ return kTypeTether;
+
NOTREACHED();
return std::string();
}
« no previous file with comments | « chromeos/network/network_state_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698