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