-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
nearby_share_feature_pod_controller.h
66 lines (52 loc) · 2.3 KB
/
nearby_share_feature_pod_controller.h
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
// Copyright 2020 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_NEARBY_SHARE_NEARBY_SHARE_FEATURE_POD_CONTROLLER_H_
#define ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_FEATURE_POD_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/constants/quick_settings_catalogs.h"
#include "ash/system/nearby_share/nearby_share_controller_impl.h"
#include "ash/system/unified/feature_pod_controller_base.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
namespace ash {
class NearbyShareDelegate;
class UnifiedSystemTrayController;
// Controller for a feature pod button that toggles the high visibility mode of
// Nearby Share.
class ASH_EXPORT NearbyShareFeaturePodController
: public FeaturePodControllerBase,
public NearbyShareControllerImpl::Observer {
public:
explicit NearbyShareFeaturePodController(
UnifiedSystemTrayController* tray_controller);
NearbyShareFeaturePodController(const NearbyShareFeaturePodController&) =
delete;
NearbyShareFeaturePodController& operator=(
const NearbyShareFeaturePodController&) = delete;
~NearbyShareFeaturePodController() override;
// FeaturePodControllerBase:
FeaturePodButton* CreateButton() override;
std::unique_ptr<FeatureTile> CreateTile(bool compact = false) override;
QsFeatureCatalogName GetCatalogName() override;
void OnIconPressed() override;
void OnLabelPressed() override;
// NearbyShareController::Observer
void OnHighVisibilityEnabledChanged(bool enabled) override;
private:
void UpdateButton(bool enabled);
base::TimeDelta RemainingHighVisibilityTime() const;
// Countdown timer fires periodically to update the remaining time until
// |shutoff_time_| as displayed by the pod button sub-label.
base::RepeatingTimer countdown_timer_;
base::TimeTicks shutoff_time_;
UnifiedSystemTrayController* const tray_controller_;
NearbyShareDelegate* const nearby_share_delegate_;
NearbyShareControllerImpl* const nearby_share_controller_;
FeaturePodButton* button_ = nullptr;
FeatureTile* tile_ = nullptr;
base::WeakPtrFactory<NearbyShareFeaturePodController> weak_ptr_factory_{this};
};
} // namespace ash
#endif // ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_FEATURE_POD_CONTROLLER_H_