OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 |
| 5 #ifndef ASH_SYSTEM_TRAY_TRAY_INFO_LABEL_H_ |
| 6 #define ASH_SYSTEM_TRAY_TRAY_INFO_LABEL_H_ |
| 7 |
| 8 #include "ash/system/tray/actionable_view.h" |
| 9 #include "ui/views/controls/label.h" |
| 10 |
| 11 namespace ash { |
| 12 |
| 13 // A view containing only a label, which is to be inserted as a |
| 14 // row within a system menu detailed view (e.g., the "Scanning for devices..." |
| 15 // message that can appear at the top of the Bluetooth detailed view). |
| 16 // TrayInfoLabel can be clickable; this property is configured by its delegate. |
| 17 class TrayInfoLabel : public ActionableView { |
| 18 public: |
| 19 // A delegate for determining whether or not a TrayInfoLabel is clickable, and |
| 20 // handling actions when it is clicked. |
| 21 class Delegate { |
| 22 public: |
| 23 virtual ~Delegate() {} |
| 24 virtual void OnLabelClicked(int message_id) = 0; |
| 25 virtual bool IsLabelClickable(int message_id) const = 0; |
| 26 }; |
| 27 |
| 28 // |delegate| may be null, which results in a TrayInfoLabel which cannot be |
| 29 // clicked. |
| 30 TrayInfoLabel(Delegate* delegate, int message_id); |
| 31 ~TrayInfoLabel() override{}; |
| 32 |
| 33 // Updates the TrayInfoLabel to display the message associated with |
| 34 // |message_id|. This may update text styling if the delegate indicates that |
| 35 // the TrayInfoLabel should be clickable. |
| 36 void Update(int message_id); |
| 37 |
| 38 // ActionableView: |
| 39 bool PerformAction(const ui::Event& event) override; |
| 40 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 41 |
| 42 private: |
| 43 friend class TrayInfoLabelTest; |
| 44 |
| 45 bool IsClickable(); |
| 46 |
| 47 views::Label* const label_; |
| 48 int message_id_; |
| 49 |
| 50 Delegate* delegate_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(TrayInfoLabel); |
| 53 }; |
| 54 |
| 55 } // namespace ash |
| 56 |
| 57 #endif // ASH_SYSTEM_TRAY_TRAY_INFO_LABEL_H_ |
OLD | NEW |