-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CrOS Network] Add NetworkDetailedViewController class
This CL continues the effort to refactor network quick settings, it adds new classes NetworkDetailedViewController and shows NetworkDetailedNetworkView when quickSettingsNetworkRevamp is enabled. screenshot: https://screenshot.googleplex.com/4DQzW752UZVNEpS.png also built and deployed to test device Bug: b/207089013 Test: Added a unittest for NetworkDetailedViewController and ran CQ, Change-Id: I1be4b192d167a6ab27bf0f466c7effc7057f35a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3559031 Reviewed-by: Chad Duffin <chadduffin@chromium.org> Reviewed-by: Alex Newcomer <newcomer@chromium.org> Commit-Queue: Theo Johnson-kanu <tjohnsonkanu@google.com> Cr-Commit-Position: refs/heads/main@{#988012}
- Loading branch information
Theo Johnson-Kanu
authored and
Chromium LUCI CQ
committed
Apr 1, 2022
1 parent
59ac9f2
commit 87b021b
Showing
8 changed files
with
185 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2022 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/network_detailed_view_controller.h" | ||
|
||
#include "ash/constants/ash_features.h" | ||
#include "ash/strings/grit/ash_strings.h" | ||
#include "ash/system/network/network_detailed_network_view.h" | ||
#include "ash/system/network/network_list_view_controller.h" | ||
#include "ash/system/tray/detailed_view_delegate.h" | ||
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
#include "ui/views/view.h" | ||
|
||
namespace ash { | ||
namespace tray { | ||
|
||
NetworkDetailedViewController::NetworkDetailedViewController( | ||
UnifiedSystemTrayController* tray_controller) | ||
: detailed_view_delegate_( | ||
std::make_unique<DetailedViewDelegate>(tray_controller)) { | ||
DCHECK(ash::features::IsQuickSettingsNetworkRevampEnabled()); | ||
} | ||
|
||
NetworkDetailedViewController::~NetworkDetailedViewController() = default; | ||
|
||
views::View* NetworkDetailedViewController::CreateView() { | ||
DCHECK(!network_detailed_view_); | ||
std::unique_ptr<tray::NetworkDetailedNetworkView> view = | ||
NetworkDetailedNetworkView::Factory::Create(detailed_view_delegate_.get(), | ||
/*delegate=*/this); | ||
network_detailed_view_ = view.get(); | ||
network_list_view_controller_ = | ||
NetworkListViewController::Factory::Create(view.get()); | ||
|
||
// We are expected to return an unowned pointer that the caller is responsible | ||
// for deleting. | ||
return view.release()->GetAsView(); | ||
} | ||
|
||
std::u16string NetworkDetailedViewController::GetAccessibleName() const { | ||
return l10n_util::GetStringUTF16( | ||
IDS_ASH_QUICK_SETTINGS_BUBBLE_NETWORK_SETTINGS_ACCESSIBLE_DESCRIPTION); | ||
} | ||
|
||
void NetworkDetailedViewController::OnNetworkListItemSelected( | ||
const chromeos::network_config::mojom::NetworkStatePropertiesPtr& network) { | ||
} | ||
|
||
void NetworkDetailedViewController::OnMobileToggleClicked(bool new_state) {} | ||
|
||
void NetworkDetailedViewController::OnWifiToggleClicked(bool new_state) {} | ||
|
||
} // namespace tray | ||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2022 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_NETWORK_DETAILED_VIEW_CONTROLLER_H_ | ||
#define ASH_SYSTEM_NETWORK_NETWORK_DETAILED_VIEW_CONTROLLER_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "ash/ash_export.h" | ||
#include "ash/system/network/network_detailed_network_view.h" | ||
#include "ash/system/network/network_detailed_view.h" | ||
#include "ash/system/network/network_list_view_controller.h" | ||
#include "ash/system/tray/detailed_view_delegate.h" | ||
#include "ash/system/unified/detailed_view_controller.h" | ||
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" | ||
|
||
namespace views { | ||
class View; | ||
} // namespace views | ||
|
||
namespace ash { | ||
namespace tray { | ||
|
||
// This class encapsulates the logic to update the detailed Network device | ||
// page within the quick settings and translate user interaction with the | ||
// detailed view into Network state changes. | ||
class ASH_EXPORT NetworkDetailedViewController | ||
: public DetailedViewController, | ||
public NetworkDetailedNetworkView::Delegate { | ||
public: | ||
explicit NetworkDetailedViewController( | ||
UnifiedSystemTrayController* tray_controller); | ||
NetworkDetailedViewController(const NetworkDetailedViewController&) = delete; | ||
NetworkDetailedViewController& operator=( | ||
const NetworkDetailedViewController&) = delete; | ||
~NetworkDetailedViewController() override; | ||
|
||
// DetailedViewControllerBase: | ||
views::View* CreateView() override; | ||
std::u16string GetAccessibleName() const override; | ||
|
||
private: | ||
// NetworkDetailedView::Delegate: | ||
void OnNetworkListItemSelected( | ||
const chromeos::network_config::mojom::NetworkStatePropertiesPtr& network) | ||
override; | ||
|
||
// NetworkDetailedNetworkView::Delegate: | ||
void OnMobileToggleClicked(bool new_state) override; | ||
void OnWifiToggleClicked(bool new_state) override; | ||
|
||
const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_; | ||
|
||
NetworkDetailedNetworkView* network_detailed_view_ = nullptr; | ||
std::unique_ptr<NetworkListViewController> network_list_view_controller_; | ||
}; | ||
|
||
} // namespace tray | ||
} // namespace ash | ||
|
||
#endif // ASH_SYSTEM_NETWORK_NETWORK_DETAILED_VIEW_CONTROLLER_H_ |
45 changes: 45 additions & 0 deletions
45
ash/system/network/network_detailed_view_controller_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2022 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/network_detailed_view_controller.h" | ||
|
||
#include <memory> | ||
|
||
#include "ash/constants/ash_features.h" | ||
#include "ash/test/ash_test_base.h" | ||
#include "base/test/scoped_feature_list.h" | ||
|
||
namespace ash { | ||
namespace tray { | ||
|
||
class NetworkDetailedViewControllerTest : public AshTestBase { | ||
public: | ||
void SetUp() override { | ||
AshTestBase::SetUp(); | ||
|
||
feature_list_.InitAndEnableFeature(features::kQuickSettingsNetworkRevamp); | ||
|
||
network_detailed_view_controller_ = | ||
std::make_unique<NetworkDetailedViewController>( | ||
/*tray_controller=*/nullptr); | ||
} | ||
|
||
void TearDown() override { | ||
network_detailed_view_controller_.reset(); | ||
|
||
AshTestBase::TearDown(); | ||
} | ||
|
||
private: | ||
base::test::ScopedFeatureList feature_list_; | ||
std::unique_ptr<NetworkDetailedViewController> | ||
network_detailed_view_controller_; | ||
}; | ||
|
||
TEST_F(NetworkDetailedViewControllerTest, CanConstruct) { | ||
EXPECT_TRUE(true); | ||
} | ||
|
||
} // namespace tray | ||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters