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 72 73 74 75 76 77 78 79 80
|
// Copyright 2021 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_BLUETOOTH_BLUETOOTH_DEVICE_LIST_CONTROLLER_IMPL_H_
#define ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DEVICE_LIST_CONTROLLER_IMPL_H_
#include <string>
#include <vector>
#include "ash/ash_export.h"
#include "ash/system/bluetooth/bluetooth_device_list_controller.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
namespace views {
class View;
} // namespace views
namespace ash {
class BluetoothDetailedView;
class BluetoothDeviceListItemView;
// BluetoothDeviceListController implementation.
class ASH_EXPORT BluetoothDeviceListControllerImpl
: public BluetoothDeviceListController {
public:
explicit BluetoothDeviceListControllerImpl(
BluetoothDetailedView* bluetooth_detailed_view);
BluetoothDeviceListControllerImpl(const BluetoothDeviceListControllerImpl&) =
delete;
BluetoothDeviceListControllerImpl& operator=(
const BluetoothDeviceListControllerImpl&) = delete;
~BluetoothDeviceListControllerImpl() override;
private:
friend class BluetoothDeviceListControllerTest;
// BluetoothDeviceListController:
void UpdateBluetoothEnabledState(bool enabled) override;
void UpdateDeviceList(
const PairedBluetoothDevicePropertiesPtrs& connected,
const PairedBluetoothDevicePropertiesPtrs& previously_connected) override;
// Creates a sub-header with text represented by the |text_id| message ID when
// |sub_header| is |nullptr|, otherwise uses the provided |sub_header|. The
// used sub-header is then moved to index |index| within the device list and
// returned.
views::View* CreateSubHeaderIfMissingAndReorder(views::View* sub_header,
int text_id,
size_t index);
// Creates and initializes a view for each of the device properties within
// |device_property_list| if a view does not already exist, otherwise re-using
// the existing view to avoid disrupting a11y. Each view will be reordered to
// start at |index| and will be removed from |previous_views|. The index of
// the position after the final view that was added is returned.
size_t CreateViewsIfMissingAndReorder(
const PairedBluetoothDevicePropertiesPtrs& device_property_list,
base::flat_map<std::string,
raw_ptr<BluetoothDeviceListItemView, CtnExperimental>>*
previous_views,
size_t index);
const raw_ptr<BluetoothDetailedView> bluetooth_detailed_view_;
bool is_bluetooth_enabled_ = false;
base::flat_map<std::string,
raw_ptr<BluetoothDeviceListItemView, CtnExperimental>>
device_id_to_view_map_;
raw_ptr<views::View> connected_sub_header_ = nullptr;
raw_ptr<views::View> no_device_connected_sub_header_ = nullptr;
raw_ptr<views::View> previously_connected_sub_header_ = nullptr;
};
} // namespace ash
#endif // ASH_SYSTEM_BLUETOOTH_BLUETOOTH_DEVICE_LIST_CONTROLLER_IMPL_H_
|