1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71

ash / system / network / network_list_network_item_view.h [blame]

// Copyright 2022 The Chromium Authors
// 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_LIST_NETWORK_ITEM_VIEW_H_
#define ASH_SYSTEM_NETWORK_NETWORK_LIST_NETWORK_ITEM_VIEW_H_

#include "ash/ash_export.h"
#include "ash/system/network/network_icon_animation_observer.h"
#include "ash/system/network/network_list_item_view.h"
#include "ash/system/tray/hover_highlight_view.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/views/view.h"

namespace ash {

class ViewClickListener;

// This class encapsulates the logic of configuring the view shown for a single
// network (Mobile, Wifi and Ethernet) in the detailed Network page within the
// quick settings.
class ASH_EXPORT NetworkListNetworkItemView
    : public NetworkListItemView,
      public network_icon::AnimationObserver {
  METADATA_HEADER(NetworkListNetworkItemView, NetworkListItemView)

 public:
  explicit NetworkListNetworkItemView(ViewClickListener* listener);
  NetworkListNetworkItemView(const NetworkListNetworkItemView&) = delete;
  NetworkListNetworkItemView& operator=(const NetworkListNetworkItemView&) =
      delete;
  ~NetworkListNetworkItemView() override;

  // NetworkListItemView:
  void UpdateViewForNetwork(
      const chromeos::network_config::mojom::NetworkStatePropertiesPtr&
          network_properties) override;

 private:
  friend class NetworkListNetworkItemViewTest;

  // network_icon::AnimationObserver:
  void NetworkIconChanged() override;

  // ash::NetworkListItemView
  void OnThemeChanged() override;

  void SetupCellularSubtext();
  void SetupNetworkSubtext();
  void UpdateDisabledTextColor();
  void AddPowerStatusView();
  void AddPolicyView();
  std::u16string GenerateAccessibilityLabel(const std::u16string& label);
  std::u16string GenerateAccessibilityDescription();
  std::u16string GenerateAccessibilityDescriptionForEthernet(
      const std::u16string& connection_status);
  std::u16string GenerateAccessibilityDescriptionForWifi(
      const std::u16string& connection_status,
      int signal_strength);
  std::u16string GenerateAccessibilityDescriptionForCellular(
      const std::u16string& connection_status,
      int signal_strength);
  std::u16string GenerateAccessibilityDescriptionForTether(
      const std::u16string& connection_status,
      int signal_strength);
};

}  // namespace ash

#endif  // ASH_SYSTEM_NETWORK_NETWORK_LIST_NETWORK_ITEM_VIEW_H_