Chromium Code Reviews| 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..5a20cb4ee402526247ca7a527f1de2318228f9bd 100644 |
| --- a/ash/system/network/network_list.cc |
| +++ b/ash/system/network/network_list.cc |
| @@ -178,44 +178,42 @@ 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()); |
| + // The Mobile network type contains both Cellular and Tether technologies, |
| + // though one or both of these may be unavailable. When Cellular technology |
| + // is available, the enabled value of Tether depends on the enabled value of |
| + // Cellular, so the toggle should only explicitly change the enabled value |
| + // of Cellular. |
| + // However, if Cellular technology is not available but Tether technology is |
| + // available, the toggle should explicitly change the enabled value of |
| + // Tether. |
| + if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular())) { |
| + handler->SetTechnologyEnabled(NetworkTypePattern::Cellular(), is_on, |
| + chromeos::network_handler::ErrorCallback()); |
| + } else { |
| + DCHECK(handler->IsTechnologyAvailable(NetworkTypePattern::Tether())); |
| + |
| + 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 +296,8 @@ NetworkListView::NetworkListView(SystemTrayItem* owner, LoginStatus login) |
| no_wifi_networks_view_(nullptr), |
| no_cellular_networks_view_(nullptr), |
|
Kyle Horimoto
2017/06/05 17:49:30
These "cellular" views need to be renamed appropri
lesliewatkins
2017/06/05 19:41:42
Done.
|
| 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 +427,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 +509,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. |
|
Kyle Horimoto
2017/06/05 17:49:30
stevenjb@: Should this "initializing" section be c
|
| @@ -533,31 +531,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 +672,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 |