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

Unified Diff: ash/system/network/network_list.cc

Issue 2883283004: Merged Tether and cellular network types in System Tray. (Closed)
Patch Set: Merged Tether and cellular network types in System Tray. 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: ash/system/network/network_list.cc
diff --git a/ash/system/network/network_list.cc b/ash/system/network/network_list.cc
index c5ff03bd42ad68efb3800cf5f8986e9afadbd953..64032c3b750b2edf99daa691b918a4025bc32e0b 100644
--- a/ash/system/network/network_list.cc
+++ b/ash/system/network/network_list.cc
@@ -219,31 +219,19 @@ class CellularHeaderRowView : public NetworkListView::SectionHeaderRowView {
void OnToggleToggled(bool is_on) override {
NetworkStateHandler* handler =
NetworkHandler::Get()->network_state_handler();
- handler->SetTechnologyEnabled(NetworkTypePattern::Cellular(), is_on,
- chromeos::network_handler::ErrorCallback());
+ if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular())) {
Ryan Hansberry 2017/05/23 01:14:29 Awesome :). Please add a comment explaining this b
stevenjb 2017/05/23 22:11:07 Yes please. Specifically we should explain that wh
lesliewatkins 2017/05/26 23:49:32 Done.
+ handler->SetTechnologyEnabled(NetworkTypePattern::Cellular(), is_on,
+ chromeos::network_handler::ErrorCallback());
+ } else {
+ handler->SetTechnologyEnabled(NetworkTypePattern::Tether(), is_on,
+ chromeos::network_handler::ErrorCallback());
+ }
}
private:
DISALLOW_COPY_AND_ASSIGN(CellularHeaderRowView);
};
-class TetherHeaderRowView : public NetworkListView::SectionHeaderRowView {
- public:
- TetherHeaderRowView()
- : SectionHeaderRowView(IDS_ASH_STATUS_TRAY_NETWORK_TETHER) {}
-
- ~TetherHeaderRowView() override {}
-
- const char* GetClassName() const override { return "TetherHeaderRowView"; }
-
- protected:
- void OnToggleToggled(bool is_on) override {
- // TODO (hansberry): Persist toggle to settings/preferences.
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TetherHeaderRowView);
-};
class WifiHeaderRowView : public NetworkListView::SectionHeaderRowView {
public:
@@ -326,10 +314,8 @@ NetworkListView::NetworkListView(SystemTrayItem* owner, LoginStatus login)
no_wifi_networks_view_(nullptr),
no_cellular_networks_view_(nullptr),
cellular_header_view_(nullptr),
- tether_header_view_(nullptr),
wifi_header_view_(nullptr),
cellular_separator_view_(nullptr),
- tether_separator_view_(nullptr),
wifi_separator_view_(nullptr),
connection_warning_(nullptr) {}
@@ -457,12 +443,12 @@ void NetworkListView::UpdateNetworkIcons() {
prohibited_by_policy;
info->connected = network->IsConnectedState();
info->connecting = network->IsConnectingState();
- if (network->Matches(NetworkTypePattern::WiFi()))
+ if (network->Matches(NetworkTypePattern::WiFi())) {
info->type = NetworkInfo::Type::WIFI;
- else if (network->Matches(NetworkTypePattern::Cellular()))
+ } else if (network->Matches(NetworkTypePattern::Cellular()) ||
+ network->Matches(NetworkTypePattern::Tether())) {
stevenjb 2017/05/23 22:11:07 So, we discussed possible changes to NetworkTypePa
Ryan Hansberry 2017/05/27 00:16:22 Ping.
lesliewatkins 2017/05/30 18:29:51 Done.
info->type = NetworkInfo::Type::CELLULAR;
- else if (network->Matches(NetworkTypePattern::Tether()))
- info->type = NetworkInfo::Type::TETHER;
+ }
if (prohibited_by_policy) {
info->tooltip =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED);
@@ -543,11 +529,14 @@ NetworkListView::UpdateNetworkListEntries() {
UpdateNetworkChildren(NetworkInfo::Type::UNKNOWN, index);
index += new_guids->size();
- if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular())) {
+ if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular()) ||
+ handler->IsTechnologyAvailable(NetworkTypePattern::Tether())) {
index = UpdateSectionHeaderRow(
NetworkTypePattern::Cellular(),
- handler->IsTechnologyEnabled(NetworkTypePattern::Cellular()), index,
- &cellular_header_view_, &cellular_separator_view_);
+ handler->IsTechnologyEnabled(NetworkTypePattern::Cellular()) ||
+ (!handler->IsTechnologyAvailable(NetworkTypePattern::Cellular()) &&
Ryan Hansberry 2017/05/23 01:14:29 This is correct but might be confusing in the futu
stevenjb 2017/05/23 22:11:07 Or add an anonymous helper function: IsMobileTechn
lesliewatkins 2017/05/26 23:49:32 I'm not sure what you mean by this, as there is no
+ handler->IsTechnologyEnabled(NetworkTypePattern::Tether())),
+ index, &cellular_header_view_, &cellular_separator_view_);
}
// Cellular initializing.
@@ -561,31 +550,14 @@ NetworkListView::UpdateNetworkListEntries() {
if (cellular_message_id)
++index;
- // Add cellular networks.
+ // Add cellular and Tether networks.
+ // TODO (hansberry): Audit existing usage of NonVirtual and consider changing
+ // it to include Tether. See crbug.com/693647.
std::unique_ptr<std::set<std::string>> new_cellular_guids =
UpdateNetworkChildren(NetworkInfo::Type::CELLULAR, index);
index += new_cellular_guids->size();
new_guids->insert(new_cellular_guids->begin(), new_cellular_guids->end());
- // TODO (hansberry): Audit existing usage of NonVirtual and consider changing
- // it to include Tether. See crbug.com/693647.
- if (handler->IsTechnologyAvailable(NetworkTypePattern::Tether())) {
- index = UpdateSectionHeaderRow(
- NetworkTypePattern::Tether(),
- handler->IsTechnologyEnabled(NetworkTypePattern::Tether()), index,
- &tether_header_view_, &tether_separator_view_);
-
- // TODO (hansberry): Should a message similar to
- // IDS_ASH_STATUS_TRAY_NO_CELLULAR_NETWORKS be shown if Tether technology is
- // enabled but no networks are around?
-
- // Add Tether networks.
- std::unique_ptr<std::set<std::string>> new_tether_guids =
- UpdateNetworkChildren(NetworkInfo::Type::TETHER, index);
- index += new_tether_guids->size();
- new_guids->insert(new_tether_guids->begin(), new_tether_guids->end());
- }
-
index = UpdateSectionHeaderRow(
NetworkTypePattern::WiFi(),
handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()), index,
@@ -748,10 +720,9 @@ int NetworkListView::UpdateSectionHeaderRow(NetworkTypePattern pattern,
SectionHeaderRowView** view,
views::Separator** separator_view) {
if (!*view) {
- if (pattern.Equals(NetworkTypePattern::Cellular()))
+ if (pattern.Equals(NetworkTypePattern::Cellular()) ||
+ pattern.Equals(NetworkTypePattern::Tether()))
stevenjb 2017/05/23 22:11:07 This could use Pattern::Mobile and then we won't n
lesliewatkins 2017/05/30 18:29:51 Done.
*view = new CellularHeaderRowView();
- else if (pattern.Equals(NetworkTypePattern::Tether()))
- *view = new TetherHeaderRowView();
else if (pattern.Equals(NetworkTypePattern::WiFi()))
*view = new WifiHeaderRowView();
else

Powered by Google App Engine
This is Rietveld 408576698