bluetooth_detailed_view_impl.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright 2021 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. #ifndef ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_IMPL_H_
  5. #define ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_IMPL_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/system/bluetooth/bluetooth_detailed_view.h"
  8. #include "ash/system/bluetooth/bluetooth_device_list_controller.h"
  9. #include "ash/system/tray/tray_detailed_view.h"
  10. #include "base/memory/weak_ptr.h"
  11. namespace views {
  12. class Button;
  13. class ToggleButton;
  14. class View;
  15. } // namespace views
  16. namespace ash {
  17. class BluetoothDeviceListItemView;
  18. class BluetoothDisabledDetailedView;
  19. class DetailedViewDelegate;
  20. class TriView;
  21. // BluetoothDetailedView implementation.
  22. class ASH_EXPORT BluetoothDetailedViewImpl : public BluetoothDetailedView,
  23. public TrayDetailedView {
  24. public:
  25. BluetoothDetailedViewImpl(DetailedViewDelegate* detailed_view_delegate,
  26. BluetoothDetailedView::Delegate* delegate);
  27. BluetoothDetailedViewImpl(const BluetoothDetailedViewImpl&) = delete;
  28. BluetoothDetailedViewImpl& operator=(const BluetoothDetailedViewImpl&) =
  29. delete;
  30. ~BluetoothDetailedViewImpl() override;
  31. private:
  32. friend class BluetoothDetailedViewTest;
  33. // Used for testing. Starts at 1 because view IDs should not be 0.
  34. enum class BluetoothDetailedViewChildId {
  35. kToggleButton = 1,
  36. kDisabledView = 2,
  37. kSettingsButton = 3,
  38. kPairNewDeviceView = 4,
  39. kPairNewDeviceClickableView = 5,
  40. };
  41. // BluetoothDetailedView:
  42. views::View* GetAsView() override;
  43. void UpdateBluetoothEnabledState(bool enabled) override;
  44. BluetoothDeviceListItemView* AddDeviceListItem() override;
  45. ash::TriView* AddDeviceListSubHeader(const gfx::VectorIcon& icon,
  46. int text_id) override;
  47. void NotifyDeviceListChanged() override;
  48. views::View* device_list() override;
  49. // TrayDetailedView:
  50. void HandleViewClicked(views::View* view) override;
  51. // views::View:
  52. const char* GetClassName() const override;
  53. // Creates and configures the Bluetooth disabled view.
  54. void CreateDisabledView();
  55. // Creates and configures the pair new device view containing the button and
  56. // the following separator line.
  57. void CreatePairNewDeviceView();
  58. // Creates and configures the Bluetooth toggle button and the settings button.
  59. void CreateTitleRowButtons();
  60. // Attempts to close the quick settings and open the Bluetooth settings.
  61. void OnSettingsClicked();
  62. // Propagates user interaction with the Bluetooth toggle button.
  63. void OnToggleClicked();
  64. views::Button* settings_button_ = nullptr;
  65. views::ToggleButton* toggle_button_ = nullptr;
  66. views::View* pair_new_device_view_ = nullptr;
  67. BluetoothDisabledDetailedView* disabled_view_ = nullptr;
  68. base::WeakPtrFactory<BluetoothDetailedViewImpl> weak_factory_{this};
  69. };
  70. } // namespace ash
  71. #endif // ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DETAILED_VIEW_IMPL_H_