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 {
namespace {
void SetNetworkEnabled(bool enabled) {
// Returns true if the network is actually toggled.
bool SetNetworkEnabled(bool enabled) {
const NetworkState* network =
NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
NetworkTypePattern::NonVirtual());
......@@ -31,22 +32,23 @@ void SetNetworkEnabled(bool enabled) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::Cellular(), false,
chromeos::network_handler::ErrorCallback());
return;
return true;
}
if (!enabled && network && network->Matches(NetworkTypePattern::Tether())) {
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::Tether(), false,
chromeos::network_handler::ErrorCallback());
return;
return true;
}
if (network && !network->Matches(NetworkTypePattern::WiFi()))
return;
return false;
NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
NetworkTypePattern::WiFi(), enabled,
chromeos::network_handler::ErrorCallback());
return true;
}
} // namespace
......@@ -65,16 +67,17 @@ FeaturePodButton* NetworkFeaturePodController::CreateButton() {
void NetworkFeaturePodController::OnIconPressed() {
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 (!was_enabled)
tray_controller_->ShowNetworkDetailedView();
// Also, if the network could not be toggled e.g. Ethernet, show network list.
if (!was_enabled || !can_toggle)
tray_controller_->ShowNetworkDetailedView(!can_toggle /* force */);
}
void NetworkFeaturePodController::OnLabelPressed() {
SetNetworkEnabled(true);
tray_controller_->ShowNetworkDetailedView();
tray_controller_->ShowNetworkDetailedView(true /* force */);
}
SystemTrayItemUmaType NetworkFeaturePodController::GetUmaType() const {
......
......@@ -53,15 +53,9 @@ void QuietModeFeaturePodController::OnIconPressed() {
MessageCenter* message_center = MessageCenter::Get();
bool is_quiet_mode = message_center->IsQuietMode();
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() {
MessageCenter::Get()->SetQuietMode(true);
tray_controller_->ShowNotifierSettingsView();
}
......
......@@ -238,8 +238,8 @@ void UnifiedSystemTrayController::ShowUserChooserWidget() {
unified_view_->SetDetailedView(new UserChooserView(this));
}
void UnifiedSystemTrayController::ShowNetworkDetailedView() {
if (!IsExpanded())
void UnifiedSystemTrayController::ShowNetworkDetailedView(bool force) {
if (!force && !IsExpanded())
return;
Shell::Get()->metrics()->RecordUserMetricsAction(
......@@ -286,9 +286,6 @@ void UnifiedSystemTrayController::ShowAudioDetailedView() {
}
void UnifiedSystemTrayController::ShowNotifierSettingsView() {
if (!IsExpanded())
return;
DCHECK(Shell::Get()->session_controller()->ShouldShowNotificationTray());
DCHECK(!Shell::Get()->session_controller()->IsScreenLocked());
ShowDetailedView(std::make_unique<UnifiedNotifierSettingsController>(this));
......
......@@ -71,9 +71,11 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
// Show user selector popup widget. Called from the view.
void ShowUserChooserWidget();
// Show the detailed view of network. Called from the view.
void ShowNetworkDetailedView();
// Show the detailed view of bluetooth. Called from the view.
// Show the detailed view of network. If |force| is true, it shows the
// detailed view even if it's collapsed. 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();
// Show the detailed view of cast. Called from the view.
void ShowCastDetailedView();
......
......@@ -71,7 +71,7 @@ void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
break;
case mojom::TrayItem::kNetwork:
tray_->ShowBubble(false /* show_by_click */);
tray_->bubble_->controller_->ShowNetworkDetailedView();
tray_->bubble_->controller_->ShowNetworkDetailedView(true /* force */);
break;
}
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