Commit fe7b0602 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Fix DND and network button behavior.

This CL fixes two issues:
* Fix do-not-disturb button to turn on DND automatically on the label
  click.
* Fix network button to ignore the icon click when Ethernet is
  connected.

TEST=manual
BUG=859831,861709

Change-Id: I064db9687084ac21aa9a059b7cd90f740e734d4d
Reviewed-on: https://chromium-review.googlesource.com/1139849
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575957}
parent 74a1c955
...@@ -20,7 +20,8 @@ namespace ash { ...@@ -20,7 +20,8 @@ namespace ash {
namespace { namespace {
void SetNetworkEnabled(bool enabled) { // Returns true if the network is actually toggled.
bool SetNetworkEnabled(bool enabled) {
const NetworkState* network = const NetworkState* network =
NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
NetworkTypePattern::NonVirtual()); NetworkTypePattern::NonVirtual());
...@@ -31,22 +32,23 @@ void SetNetworkEnabled(bool enabled) { ...@@ -31,22 +32,23 @@ void SetNetworkEnabled(bool enabled) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::Cellular(), false, NetworkTypePattern::Cellular(), false,
chromeos::network_handler::ErrorCallback()); chromeos::network_handler::ErrorCallback());
return; return true;
} }
if (!enabled && network && network->Matches(NetworkTypePattern::Tether())) { if (!enabled && network && network->Matches(NetworkTypePattern::Tether())) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::Tether(), false, NetworkTypePattern::Tether(), false,
chromeos::network_handler::ErrorCallback()); chromeos::network_handler::ErrorCallback());
return; return true;
} }
if (network && !network->Matches(NetworkTypePattern::WiFi())) if (network && !network->Matches(NetworkTypePattern::WiFi()))
return; return false;
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::WiFi(), enabled, NetworkTypePattern::WiFi(), enabled,
chromeos::network_handler::ErrorCallback()); chromeos::network_handler::ErrorCallback());
return true;
} }
} // namespace } // namespace
...@@ -65,16 +67,17 @@ FeaturePodButton* NetworkFeaturePodController::CreateButton() { ...@@ -65,16 +67,17 @@ FeaturePodButton* NetworkFeaturePodController::CreateButton() {
void NetworkFeaturePodController::OnIconPressed() { void NetworkFeaturePodController::OnIconPressed() {
bool was_enabled = button_->IsToggled(); bool was_enabled = button_->IsToggled();
SetNetworkEnabled(!was_enabled); bool can_toggle = SetNetworkEnabled(!was_enabled);
// If network was disabled, show network list as well as enabling network. // If network was disabled, show network list as well as enabling network.
if (!was_enabled) // Also, if the network could not be toggled e.g. Ethernet, show network list.
tray_controller_->ShowNetworkDetailedView(); if (!was_enabled || !can_toggle)
tray_controller_->ShowNetworkDetailedView(!can_toggle /* force */);
} }
void NetworkFeaturePodController::OnLabelPressed() { void NetworkFeaturePodController::OnLabelPressed() {
SetNetworkEnabled(true); SetNetworkEnabled(true);
tray_controller_->ShowNetworkDetailedView(); tray_controller_->ShowNetworkDetailedView(true /* force */);
} }
SystemTrayItemUmaType NetworkFeaturePodController::GetUmaType() const { SystemTrayItemUmaType NetworkFeaturePodController::GetUmaType() const {
......
...@@ -53,15 +53,9 @@ void QuietModeFeaturePodController::OnIconPressed() { ...@@ -53,15 +53,9 @@ void QuietModeFeaturePodController::OnIconPressed() {
MessageCenter* message_center = MessageCenter::Get(); MessageCenter* message_center = MessageCenter::Get();
bool is_quiet_mode = message_center->IsQuietMode(); bool is_quiet_mode = message_center->IsQuietMode();
message_center->SetQuietMode(!is_quiet_mode); message_center->SetQuietMode(!is_quiet_mode);
// If quiet mode was disabled, show notifier settings as well as enabling
// quiet mode.
if (!is_quiet_mode)
tray_controller_->ShowNotifierSettingsView();
} }
void QuietModeFeaturePodController::OnLabelPressed() { void QuietModeFeaturePodController::OnLabelPressed() {
MessageCenter::Get()->SetQuietMode(true);
tray_controller_->ShowNotifierSettingsView(); tray_controller_->ShowNotifierSettingsView();
} }
......
...@@ -238,8 +238,8 @@ void UnifiedSystemTrayController::ShowUserChooserWidget() { ...@@ -238,8 +238,8 @@ void UnifiedSystemTrayController::ShowUserChooserWidget() {
unified_view_->SetDetailedView(new UserChooserView(this)); unified_view_->SetDetailedView(new UserChooserView(this));
} }
void UnifiedSystemTrayController::ShowNetworkDetailedView() { void UnifiedSystemTrayController::ShowNetworkDetailedView(bool force) {
if (!IsExpanded()) if (!force && !IsExpanded())
return; return;
Shell::Get()->metrics()->RecordUserMetricsAction( Shell::Get()->metrics()->RecordUserMetricsAction(
...@@ -286,9 +286,6 @@ void UnifiedSystemTrayController::ShowAudioDetailedView() { ...@@ -286,9 +286,6 @@ void UnifiedSystemTrayController::ShowAudioDetailedView() {
} }
void UnifiedSystemTrayController::ShowNotifierSettingsView() { void UnifiedSystemTrayController::ShowNotifierSettingsView() {
if (!IsExpanded())
return;
DCHECK(Shell::Get()->session_controller()->ShouldShowNotificationTray()); DCHECK(Shell::Get()->session_controller()->ShouldShowNotificationTray());
DCHECK(!Shell::Get()->session_controller()->IsScreenLocked()); DCHECK(!Shell::Get()->session_controller()->IsScreenLocked());
ShowDetailedView(std::make_unique<UnifiedNotifierSettingsController>(this)); ShowDetailedView(std::make_unique<UnifiedNotifierSettingsController>(this));
......
...@@ -71,9 +71,11 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate { ...@@ -71,9 +71,11 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
// Show user selector popup widget. Called from the view. // Show user selector popup widget. Called from the view.
void ShowUserChooserWidget(); void ShowUserChooserWidget();
// Show the detailed view of network. Called from the view. // Show the detailed view of network. If |force| is true, it shows the
void ShowNetworkDetailedView(); // detailed view even if it's collapsed. Called from the view.
// Show the detailed view of bluetooth. Called from the view. void ShowNetworkDetailedView(bool force);
// Show the detailed view of bluetooth. If collapsed, it doesn't show the
// detailed view. Called from the view.
void ShowBluetoothDetailedView(); void ShowBluetoothDetailedView();
// Show the detailed view of cast. Called from the view. // Show the detailed view of cast. Called from the view.
void ShowCastDetailedView(); void ShowCastDetailedView();
......
...@@ -71,7 +71,7 @@ void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item, ...@@ -71,7 +71,7 @@ void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
break; break;
case mojom::TrayItem::kNetwork: case mojom::TrayItem::kNetwork:
tray_->ShowBubble(false /* show_by_click */); tray_->ShowBubble(false /* show_by_click */);
tray_->bubble_->controller_->ShowNetworkDetailedView(); tray_->bubble_->controller_->ShowNetworkDetailedView(true /* force */);
break; break;
} }
std::move(cb).Run(); std::move(cb).Run();
......
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