Chromium Code Reviews| Index: ash/system/tray/tray_info_label.h |
| diff --git a/ash/system/tray/tray_info_label.h b/ash/system/tray/tray_info_label.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..00f6eb1c3140f3cc9021a3be19c91fe44dfb6ab6 |
| --- /dev/null |
| +++ b/ash/system/tray/tray_info_label.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
|
James Cook
2017/07/18 17:26:10
super-nit: no (c)
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_SYSTEM_TRAY_TRAY_INFO_LABEL_H_ |
| +#define ASH_SYSTEM_TRAY_TRAY_INFO_LABEL_H_ |
| + |
| +#include "ash/system/tray/actionable_view.h" |
| +#include "ui/views/controls/label.h" |
| + |
| +namespace ash { |
| + |
| +class TrayInfoLabelTest; |
|
Kyle Horimoto
2017/07/18 17:10:05
nit: You don't need to forward declare friend clas
|
| + |
| +// A view containing only a label, which is to be inserted as a |
| +// row within a system menu detailed view (e.g., the "Scanning for devices..." |
| +// message that can appear at the top of the Bluetooth detailed view). |
| +// TrayInfoLabel can be clickable; this property is configured by its delegate. |
| +class TrayInfoLabel : public ActionableView { |
| + public: |
| + // A delegate for determining whether or not a TrayInfoLabel is clickable, and |
| + // handling actions when it is clicked. |
| + class Delegate { |
| + public: |
| + virtual ~Delegate(){}; |
|
James Cook
2017/07/18 17:26:10
nit: space after ) and no ;
|
| + virtual void OnLabelClicked(int message_id) = 0; |
| + virtual bool IsLabelClickable(int message_id) const = 0; |
| + }; |
| + |
| + // |delegate| may be null, which results in a TrayInfoLabel which cannot be |
| + // clicked. |
| + TrayInfoLabel(Delegate* delegate, int message_id); |
| + ~TrayInfoLabel() override{}; |
| + |
| + // Updates the TrayInfoLabel to display the message associated with |
| + // |message_id|. This may update text styling if the delegate indicates that |
| + // the TrayInfoLabel should be clickable. |
| + void Update(int message_id); |
| + |
| + // ActionableView: |
| + bool PerformAction(const ui::Event& event) override; |
| + void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| + |
| + private: |
| + friend class TrayInfoLabelTest; |
| + |
| + bool IsClickable(); |
| + |
| + views::Label* const label_; |
| + int message_id_; |
| + |
| + Delegate* delegate_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TrayInfoLabel); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_SYSTEM_TRAY_TRAY_INFO_LABEL_H_ |