Commit 787203dc authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add UnifiedNetworkDetailedViewController.

This CL implements DetailedViewController for the network detailed view.
The change is a step to remove the reference to SystemTray from
UnifiedSystemTray. It fixes the behavior of the back button, and enables
further UnifiedSysetmTray specific tweaks to the detailed view.

To implement the common behavior for UnifiedSystemTray detailed views,
this CL also adds UnifiedDetailedViewDelegate.

TEST=manual
BUG=835733

Change-Id: I2c005db58e410d33a36e6b6e16083b30917bc053
Reviewed-on: https://chromium-review.googlesource.com/1071490Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561798}
parent bcef67c0
......@@ -671,6 +671,8 @@ component("ash") {
"system/network/tray_network_state_observer.h",
"system/network/tray_vpn.cc",
"system/network/tray_vpn.h",
"system/network/unified_network_detailed_view_controller.cc",
"system/network/unified_network_detailed_view_controller.h",
"system/network/vpn_feature_pod_controller.cc",
"system/network/vpn_feature_pod_controller.h",
"system/network/vpn_list.cc",
......@@ -901,6 +903,8 @@ component("ash") {
"system/unified/top_shortcut_button.h",
"system/unified/top_shortcuts_view.cc",
"system/unified/top_shortcuts_view.h",
"system/unified/unified_detailed_view_delegate.cc",
"system/unified/unified_detailed_view_delegate.h",
"system/unified/unified_message_center_view.cc",
"system/unified/unified_message_center_view.h",
"system/unified/unified_slider_view.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/network/unified_network_detailed_view_controller.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/system/network/network_list.h"
#include "ash/system/unified/unified_detailed_view_delegate.h"
namespace ash {
UnifiedNetworkDetailedViewController::UnifiedNetworkDetailedViewController(
UnifiedSystemTrayController* tray_controller)
: detailed_view_delegate_(
std::make_unique<UnifiedDetailedViewDelegate>(tray_controller)),
network_state_observer_(
std::make_unique<TrayNetworkStateObserver>(this)) {}
UnifiedNetworkDetailedViewController::~UnifiedNetworkDetailedViewController() =
default;
views::View* UnifiedNetworkDetailedViewController::CreateView() {
DCHECK(!view_);
view_ = new tray::NetworkListView(
detailed_view_delegate_.get(),
Shell::Get()->session_controller()->login_status());
view_->Init();
return view_;
}
void UnifiedNetworkDetailedViewController::NetworkStateChanged(
bool notify_a11y) {
if (view_)
view_->Update();
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_NETWORK_UNIFIED_NETWORK_DETAILED_VIEW_CONTROLLER_H_
#define ASH_SYSTEM_NETWORK_UNIFIED_NETWORK_DETAILED_VIEW_CONTROLLER_H_
#include "ash/system/network/tray_network_state_observer.h"
#include "ash/system/unified/detailed_view_controller.h"
namespace ash {
namespace tray {
class NetworkListView;
} // namespace tray
class DetailedViewDelegate;
class UnifiedSystemTrayController;
// Controller of Network detailed view in UnifiedSystemTray.
class UnifiedNetworkDetailedViewController
: public DetailedViewController,
public TrayNetworkStateObserver::Delegate {
public:
explicit UnifiedNetworkDetailedViewController(
UnifiedSystemTrayController* tray_controller);
~UnifiedNetworkDetailedViewController() override;
// DetailedViewControllerBase:
views::View* CreateView() override;
// TrayNetworkStateObserver::Delegate:
void NetworkStateChanged(bool notify_a11y) override;
private:
const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_;
const std::unique_ptr<TrayNetworkStateObserver> network_state_observer_;
tray::NetworkListView* view_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(UnifiedNetworkDetailedViewController);
};
} // namespace ash
#endif // ASH_SYSTEM_NETWORK_UNIFIED_NETWORK_DETAILED_VIEW_CONTROLLER_H_
......@@ -356,10 +356,6 @@ TrayAudio* SystemTray::GetTrayAudio() const {
return tray_audio_;
}
TrayNetwork* SystemTray::GetTrayNetwork() const {
return tray_network_;
}
TrayBluetooth* SystemTray::GetTrayBluetooth() const {
return tray_bluetooth_;
}
......
......@@ -124,8 +124,6 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView,
// Returns TrayAudio object if present or null otherwise.
TrayAudio* GetTrayAudio() const;
// Returns TrayNetwork object if present or null otherwise.
TrayNetwork* GetTrayNetwork() const;
// Returns TrayBluetooth object if present or null otherwise.
TrayBluetooth* GetTrayBluetooth() const;
// Returns TrayCast object if present or null otherwise.
......
......@@ -279,10 +279,8 @@ void TrayDetailedView::CreateTitleRow(int string_id) {
tri_view_ = TrayPopupUtils::CreateDefaultRowView();
if (!features::IsSystemTrayUnifiedEnabled()) {
back_button_ = CreateBackButton();
tri_view_->AddView(TriView::Container::START, back_button_);
}
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
auto* label = TrayPopupUtils::CreateDefaultLabel();
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/unified/unified_detailed_view_delegate.h"
#include "ash/system/unified/unified_system_tray_controller.h"
namespace ash {
UnifiedDetailedViewDelegate::UnifiedDetailedViewDelegate(
UnifiedSystemTrayController* tray_controller)
: tray_controller_(tray_controller) {}
UnifiedDetailedViewDelegate::~UnifiedDetailedViewDelegate() = default;
void UnifiedDetailedViewDelegate::TransitionToMainView(bool restore_focus) {
tray_controller_->TransitionToMainView();
}
void UnifiedDetailedViewDelegate::CloseBubble() {
tray_controller_->CloseBubble();
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_UNIFIED_UNIFIED_DETAILED_VIEW_DELEGATE_H_
#define ASH_SYSTEM_UNIFIED_UNIFIED_DETAILED_VIEW_DELEGATE_H_
#include "ash/system/tray/detailed_view_delegate.h"
#include "base/macros.h"
namespace ash {
class UnifiedSystemTrayController;
// Default implementation of DetailedViewDelegate for UnifiedSystemTray.
class UnifiedDetailedViewDelegate : public DetailedViewDelegate {
public:
explicit UnifiedDetailedViewDelegate(
UnifiedSystemTrayController* tray_controller);
~UnifiedDetailedViewDelegate() override;
// DetailedViewDelegate:
void TransitionToMainView(bool restore_focus) override;
void CloseBubble() override;
private:
UnifiedSystemTrayController* const tray_controller_;
DISALLOW_COPY_AND_ASSIGN(UnifiedDetailedViewDelegate);
};
} // namespace ash
#endif // ASH_SYSTEM_UNIFIED_UNIFIED_DETAILED_VIEW_DELEGATE_H_
......@@ -20,6 +20,7 @@
#include "ash/system/network/network_feature_pod_controller.h"
#include "ash/system/network/tray_network.h"
#include "ash/system/network/tray_vpn.h"
#include "ash/system/network/unified_network_detailed_view_controller.h"
#include "ash/system/network/vpn_feature_pod_controller.h"
#include "ash/system/night_light/night_light_feature_pod_controller.h"
#include "ash/system/rotation/rotation_lock_feature_pod_controller.h"
......@@ -218,8 +219,8 @@ void UnifiedSystemTrayController::ShowUserChooserWidget() {
}
void UnifiedSystemTrayController::ShowNetworkDetailedView() {
// TODO(tetsui): Implement Network's own DetailedViewController.
ShowSystemTrayItemDetailedView(system_tray_->GetTrayNetwork());
ShowDetailedView(
std::make_unique<UnifiedNetworkDetailedViewController>(this));
}
void UnifiedSystemTrayController::ShowBluetoothDetailedView() {
......@@ -247,6 +248,16 @@ void UnifiedSystemTrayController::ShowIMEDetailedView() {
ShowSystemTrayItemDetailedView(system_tray_->GetTrayIME());
}
void UnifiedSystemTrayController::TransitionToMainView() {
detailed_view_controller_.reset();
unified_view_->ResetDetailedView();
}
void UnifiedSystemTrayController::CloseBubble() {
if (unified_view_->GetWidget())
unified_view_->GetWidget()->Close();
}
void UnifiedSystemTrayController::AnimationEnded(
const gfx::Animation* animation) {
UpdateExpandedAmount();
......
......@@ -77,6 +77,13 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
// If you want to add a new detailed view, add here.
// Show the main view back from a detailed view. Called from a detailed view
// controller.
void TransitionToMainView();
// Close the bubble. Called from a detailed view controller.
void CloseBubble();
// gfx::AnimationDelegate:
void AnimationEnded(const gfx::Animation* animation) override;
void AnimationProgressed(const gfx::Animation* animation) override;
......
......@@ -165,6 +165,12 @@ void UnifiedSystemTrayView::SetDetailedView(views::View* detailed_view) {
Layout();
}
void UnifiedSystemTrayView::ResetDetailedView() {
detailed_view_container_->RemoveAllChildViews(true /* delete_children */);
system_tray_container_->SetVisible(true);
Layout();
}
void UnifiedSystemTrayView::SetExpandedAmount(double expanded_amount) {
DCHECK(0.0 <= expanded_amount && expanded_amount <= 1.0);
if (expanded_amount == 1.0 || expanded_amount == 0.0)
......
......@@ -60,6 +60,10 @@ class UnifiedSystemTrayView : public views::View {
// Hide the main view and show the given |detailed_view|.
void SetDetailedView(views::View* detailed_view);
// Remove the detailed view set by SetDetailedView, and show the main view.
// It deletes |detailed_view| and children.
void ResetDetailedView();
// Change the expanded state. 0.0 if collapsed, and 1.0 if expanded.
// Otherwise, it shows intermediate state.
void SetExpandedAmount(double expanded_amount);
......
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