Commit 9738ab66 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

System Tray > Network: Fix secondary user logic

Checking IsUserPrimary() before login is incorrect, we need to also
check IsActiveUserSessionStarted() anywhere we want to hide or disable
UI for the secondary user.

Bug was introduced in https://chromium-review.googlesource.com/1089585

Bug: 853715
Change-Id: Id7cb90da16e62be6f23d7df7ce499c8e4fef4786
Reviewed-on: https://chromium-review.googlesource.com/1104983
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568163}
parent 80c6537f
...@@ -116,12 +116,10 @@ void ShowCellularSettings() { ...@@ -116,12 +116,10 @@ void ShowCellularSettings() {
cellular_network ? cellular_network->guid() : std::string()); cellular_network ? cellular_network->guid() : std::string());
} }
// Only enable toggles and "add wifi" for the primary user since secondary bool IsSecondaryUser() {
// users can not change network configurations.
bool GetDefaultToggleEnabled() {
SessionController* session_controller = Shell::Get()->session_controller(); SessionController* session_controller = Shell::Get()->session_controller();
return !session_controller->IsActiveUserSessionStarted() || return session_controller->IsActiveUserSessionStarted() &&
session_controller->IsUserPrimary(); !session_controller->IsUserPrimary();
} }
} // namespace } // namespace
...@@ -311,7 +309,7 @@ class MobileHeaderRowView : public NetworkListView::SectionHeaderRowView, ...@@ -311,7 +309,7 @@ class MobileHeaderRowView : public NetworkListView::SectionHeaderRowView,
network_state_handler_->GetTechnologyState( network_state_handler_->GetTechnologyState(
NetworkTypePattern::Tether()); NetworkTypePattern::Tether());
bool default_toggle_enabled = GetDefaultToggleEnabled(); bool default_toggle_enabled = !IsSecondaryUser();
// If Cellular is available, toggle state and subtitle reflect Cellular. // If Cellular is available, toggle state and subtitle reflect Cellular.
if (cellular_state != NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) { if (cellular_state != NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) {
...@@ -747,7 +745,7 @@ bool NetworkListView::ShouldMobileDataSectionBeShown() { ...@@ -747,7 +745,7 @@ bool NetworkListView::ShouldMobileDataSectionBeShown() {
// Secondary users cannot enable Bluetooth, and Tether is only UNINITIALIZED // Secondary users cannot enable Bluetooth, and Tether is only UNINITIALIZED
// if Bluetooth is disabled. Hide the section in this case. // if Bluetooth is disabled. Hide the section in this case.
if (handler->IsTechnologyUninitialized(NetworkTypePattern::Tether()) && if (handler->IsTechnologyUninitialized(NetworkTypePattern::Tether()) &&
!Shell::Get()->session_controller()->IsUserPrimary()) { IsSecondaryUser()) {
return false; return false;
} }
...@@ -934,7 +932,7 @@ int NetworkListView::UpdateSectionHeaderRow(NetworkTypePattern pattern, ...@@ -934,7 +932,7 @@ int NetworkListView::UpdateSectionHeaderRow(NetworkTypePattern pattern,
*separator_view = nullptr; *separator_view = nullptr;
} }
bool default_toggle_enabled = GetDefaultToggleEnabled(); bool default_toggle_enabled = !IsSecondaryUser();
// Mobile updates its toggle state independently. // Mobile updates its toggle state independently.
if (!pattern.MatchesPattern(NetworkTypePattern::Mobile())) if (!pattern.MatchesPattern(NetworkTypePattern::Mobile()))
(*view)->SetToggleState(default_toggle_enabled, enabled /* is_on */); (*view)->SetToggleState(default_toggle_enabled, enabled /* is_on */);
......
...@@ -53,6 +53,12 @@ constexpr int kBubbleMargin = 8; ...@@ -53,6 +53,12 @@ constexpr int kBubbleMargin = 8;
// Elevation used for the bubble shadow effect (tiny). // Elevation used for the bubble shadow effect (tiny).
constexpr int kBubbleShadowElevation = 2; constexpr int kBubbleShadowElevation = 2;
bool IsSecondaryUser() {
SessionController* session_controller = Shell::Get()->session_controller();
return session_controller->IsActiveUserSessionStarted() &&
!session_controller->IsUserPrimary();
}
} // namespace } // namespace
// A bubble which displays network info. // A bubble which displays network info.
...@@ -235,8 +241,7 @@ void NetworkStateListDetailedView::HandleViewClicked(views::View* view) { ...@@ -235,8 +241,7 @@ void NetworkStateListDetailedView::HandleViewClicked(views::View* view) {
bool can_connect = network && !network->IsConnectingOrConnected(); bool can_connect = network && !network->IsConnectingOrConnected();
if (network->IsDefaultCellular()) if (network->IsDefaultCellular())
can_connect = false; // Default Cellular network is not connectable. can_connect = false; // Default Cellular network is not connectable.
if (!network->connectable() && if (!network->connectable() && IsSecondaryUser()) {
!Shell::Get()->session_controller()->IsUserPrimary()) {
// Secondary users can only connect to fully configured networks. // Secondary users can only connect to fully configured networks.
can_connect = false; can_connect = false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment