network_list_item_view.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/system/network/network_list_item_view.h"
  5. #include <string>
  6. #include "ash/constants/ash_features.h"
  7. #include "ash/strings/grit/ash_strings.h"
  8. #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
  9. #include "ui/base/l10n/l10n_util.h"
  10. #include "ui/base/metadata/metadata_impl_macros.h"
  11. namespace ash {
  12. namespace {
  13. using chromeos::network_config::mojom::ActivationStateType;
  14. using chromeos::network_config::mojom::NetworkType;
  15. } // namespace
  16. NetworkListItemView::NetworkListItemView(ViewClickListener* listener)
  17. : HoverHighlightView(listener) {
  18. DCHECK(ash::features::IsQuickSettingsNetworkRevampEnabled());
  19. }
  20. NetworkListItemView::~NetworkListItemView() = default;
  21. std::u16string NetworkListItemView::GetLabel() {
  22. if (network_properties_->type == NetworkType::kCellular) {
  23. ActivationStateType activation_state =
  24. network_properties_->type_state->get_cellular()->activation_state;
  25. if (activation_state == ActivationStateType::kActivating) {
  26. return l10n_util::GetStringFUTF16(
  27. IDS_ASH_STATUS_TRAY_NETWORK_LIST_ACTIVATING,
  28. base::UTF8ToUTF16(network_properties_->name));
  29. }
  30. }
  31. // Otherwise just show the network name or 'Ethernet'.
  32. if (network_properties_->type == NetworkType::kEthernet)
  33. return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ETHERNET);
  34. return base::UTF8ToUTF16(network_properties_->name);
  35. }
  36. BEGIN_METADATA(NetworkListItemView, HoverHighlightView)
  37. END_METADATA
  38. } // namespace ash