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

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

Issue 2883283004: Merged Tether and cellular network types in System Tray. (Closed)
Patch Set: khorimoto@ and stevenjb@ comments 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 21ee550dcaa381752f3125300e4702d199a957f9..0578d88fd92031af0dd30de30ca68aac49c124ad 100644
--- a/ash/system/network/network_list.cc
+++ b/ash/system/network/network_list.cc
@@ -178,44 +178,35 @@ class NetworkListView::SectionHeaderRowView : public views::View,
namespace {
-class CellularHeaderRowView : public NetworkListView::SectionHeaderRowView {
+class MobileHeaderRowView : public NetworkListView::SectionHeaderRowView {
public:
- CellularHeaderRowView()
+ MobileHeaderRowView()
: SectionHeaderRowView(IDS_ASH_STATUS_TRAY_NETWORK_MOBILE) {}
- ~CellularHeaderRowView() override {}
+ ~MobileHeaderRowView() override {}
- const char* GetClassName() const override { return "CellularHeaderRowView"; }
+ const char* GetClassName() const override { return "MobileHeaderRowView"; }
protected:
void OnToggleToggled(bool is_on) override {
NetworkStateHandler* handler =
NetworkHandler::Get()->network_state_handler();
- handler->SetTechnologyEnabled(NetworkTypePattern::Cellular(), is_on,
- chromeos::network_handler::ErrorCallback());
+ // When cellular network technology is available on a device, Tether is
+ // treated as a subset of Cellular technology. Otherwise, Tether has to
+ // be explicity enabled and disabled.
+ if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular())) {
+ 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);
+ DISALLOW_COPY_AND_ASSIGN(MobileHeaderRowView);
};
-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:
@@ -298,10 +289,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) {}
@@ -431,10 +420,8 @@ void NetworkListView::UpdateNetworkIcons() {
info->connecting = network->IsConnectingState();
if (network->Matches(NetworkTypePattern::WiFi()))
info->type = NetworkInfo::Type::WIFI;
- else if (network->Matches(NetworkTypePattern::Cellular()))
- info->type = NetworkInfo::Type::CELLULAR;
- else if (network->Matches(NetworkTypePattern::Tether()))
- info->type = NetworkInfo::Type::TETHER;
+ else if (network->Matches(NetworkTypePattern::Mobile()))
+ info->type = NetworkInfo::Type::MOBILE;
if (prohibited_by_policy) {
info->tooltip =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED);
@@ -515,11 +502,15 @@ NetworkListView::UpdateNetworkListEntries() {
UpdateNetworkChildren(NetworkInfo::Type::UNKNOWN, index);
index += new_guids->size();
- if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular())) {
- index = UpdateSectionHeaderRow(
- NetworkTypePattern::Cellular(),
- handler->IsTechnologyEnabled(NetworkTypePattern::Cellular()), index,
- &cellular_header_view_, &cellular_separator_view_);
+ if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular()) ||
+ handler->IsTechnologyAvailable(NetworkTypePattern::Tether())) {
+ bool is_enabled =
+ handler->IsTechnologyEnabled(NetworkTypePattern::Cellular()) ||
+ handler->IsTechnologyEnabled(NetworkTypePattern::Tether());
+
+ index = UpdateSectionHeaderRow(NetworkTypePattern::Cellular(), is_enabled,
+ index, &cellular_header_view_,
+ &cellular_separator_view_);
}
// Cellular initializing.
@@ -533,31 +524,12 @@ NetworkListView::UpdateNetworkListEntries() {
if (cellular_message_id)
++index;
- // Add cellular networks.
+ // Add cellular and Tether networks.
std::unique_ptr<std::set<std::string>> new_cellular_guids =
- UpdateNetworkChildren(NetworkInfo::Type::CELLULAR, index);
+ UpdateNetworkChildren(NetworkInfo::Type::MOBILE, 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,
@@ -693,10 +665,8 @@ int NetworkListView::UpdateSectionHeaderRow(NetworkTypePattern pattern,
SectionHeaderRowView** view,
views::Separator** separator_view) {
if (!*view) {
- if (pattern.Equals(NetworkTypePattern::Cellular()))
- *view = new CellularHeaderRowView();
- else if (pattern.Equals(NetworkTypePattern::Tether()))
- *view = new TetherHeaderRowView();
+ if (pattern.MatchesPattern(NetworkTypePattern::Mobile()))
+ *view = new MobileHeaderRowView();
else if (pattern.Equals(NetworkTypePattern::WiFi()))
*view = new WifiHeaderRowView();
else

Powered by Google App Engine
This is Rietveld 408576698