Index: ash/system/tray/tray_details_view.cc |
diff --git a/ash/system/tray/tray_details_view.cc b/ash/system/tray/tray_details_view.cc |
index f4507f0779185c5f8924c021d5a87d7975fa7729..fab29e5104418d8f915e3b7046a7d3f9c267e0b5 100644 |
--- a/ash/system/tray/tray_details_view.cc |
+++ b/ash/system/tray/tray_details_view.cc |
@@ -17,6 +17,7 @@ |
#include "base/containers/adapters.h" |
#include "base/memory/ptr_util.h" |
#include "third_party/skia/include/core/SkDrawLooper.h" |
+#include "ui/accessibility/ax_node_data.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/compositor/paint_context.h" |
@@ -240,13 +241,14 @@ const int kTitleRowPaddingBottom = |
//////////////////////////////////////////////////////////////////////////////// |
// TrayDetailsView::InfoLabel: |
-TrayDetailsView::InfoLabel::InfoLabel(int message_id) |
- : label_(TrayPopupUtils::CreateDefaultLabel()) { |
+TrayDetailsView::InfoLabel::InfoLabel(int message_id, |
+ InfoLabelDelegate* delegate) |
+ : ActionableView(nullptr /*owner*/, TrayPopupInkDropStyle::FILL_BOUNDS), |
+ label_(TrayPopupUtils::CreateDefaultLabel()), |
+ message_id_(message_id), |
+ delegate_(delegate) { |
SetLayoutManager(new views::FillLayout); |
- TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); |
- style.SetupLabel(label_); |
- |
TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView(); |
tri_view->SetInsets(gfx::Insets(0, |
kMenuExtraMarginFromLeftEdge + |
@@ -256,17 +258,53 @@ TrayDetailsView::InfoLabel::InfoLabel(int message_id) |
tri_view->SetContainerVisible(TriView::Container::START, false); |
tri_view->SetContainerVisible(TriView::Container::END, false); |
tri_view->AddView(TriView::Container::CENTER, label_); |
+ |
AddChildView(tri_view); |
- SetMessage(message_id); |
+ Update(message_id); |
} |
-TrayDetailsView::InfoLabel::~InfoLabel() {} |
+void TrayDetailsView::InfoLabel::Update(int message_id) { |
+ message_id_ = message_id; |
+ |
+ TrayPopupItemStyle::FontStyle font_style; |
Kyle Horimoto
2017/07/10 18:37:08
nit: Use a reference:
TrayPopupItemStyle::FontSty
lesliewatkins
2017/07/12 21:49:50
This gives a compiler error-- references have to b
|
+ |
+ if (IsClickable()) { |
+ SetInkDropMode(InkDropHostView::InkDropMode::ON); |
+ font_style = TrayPopupItemStyle::FontStyle::CLICKABLE_SYSTEM_INFO; |
+ } else { |
+ SetInkDropMode(InkDropHostView::InkDropMode::OFF); |
+ font_style = TrayPopupItemStyle::FontStyle::SYSTEM_INFO; |
+ } |
+ |
+ TrayPopupItemStyle style(font_style); |
Kyle Horimoto
2017/07/10 18:37:07
nit: Use const:
const TrayPopupItemStyle style(fo
lesliewatkins
2017/07/12 21:49:50
Done.
|
+ style.SetupLabel(label_); |
-void TrayDetailsView::InfoLabel::SetMessage(int message_id) { |
label_->SetText(l10n_util::GetStringUTF16(message_id)); |
} |
+bool TrayDetailsView::InfoLabel::PerformAction(const ui::Event& event) { |
+ if (delegate_) |
Kyle Horimoto
2017/07/10 18:37:08
nit: if (delegate_), DCHECK(IsClickable())
lesliewatkins
2017/07/12 21:49:50
Just because it has a delegate doesn't mean it's c
|
+ delegate_->OnLabelClicked(this); |
Kyle Horimoto
2017/07/10 18:37:07
/* parameter_name */
lesliewatkins
2017/07/12 21:49:50
Done.
|
+ return true; |
+} |
+ |
+void TrayDetailsView::InfoLabel::GetAccessibleNodeData( |
+ ui::AXNodeData* node_data) { |
+ if (IsClickable()) |
+ node_data->role = ui::AX_ROLE_BUTTON; |
+ else |
+ node_data->role = ui::AX_ROLE_LABEL_TEXT; |
+} |
+ |
+const int& TrayDetailsView::InfoLabel::message_id() { |
+ return message_id_; |
+} |
+ |
+bool TrayDetailsView::InfoLabel::IsClickable() { |
James Cook
2017/07/10 18:43:03
This seems like it should be a delegate method. In
lesliewatkins
2017/07/12 21:49:50
I just had this call delegate_->IsClickable(messag
|
+ return message_id() == IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// TrayDetailsView: |