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 #include "ash/system/tray/tray_info_label.h"
6 
7 #include "ash/style/ash_color_provider.h"
8 #include "ash/system/tray/tray_popup_utils.h"
9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/views/layout/fill_layout.h"
11 
12 namespace ash {
13 
TrayInfoLabel(int message_id)14 TrayInfoLabel::TrayInfoLabel(int message_id)
15     : label_(TrayPopupUtils::CreateDefaultLabel()) {
16   SetLayoutManager(std::make_unique<views::FillLayout>());
17 
18   TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
19   tri_view->SetInsets(gfx::Insets(0,
20                                   kMenuExtraMarginFromLeftEdge +
21                                       kTrayPopupPaddingHorizontal -
22                                       kTrayPopupLabelHorizontalPadding,
23                                   0, kTrayPopupPaddingHorizontal));
24   tri_view->SetContainerVisible(TriView::Container::START, false);
25   tri_view->SetContainerVisible(TriView::Container::END, false);
26   tri_view->AddView(TriView::Container::CENTER, label_);
27 
28   AddChildView(tri_view);
29   SetFocusBehavior(FocusBehavior::NEVER);
30   Update(message_id);
31 }
32 
33 TrayInfoLabel::~TrayInfoLabel() = default;
34 
Update(int message_id)35 void TrayInfoLabel::Update(int message_id) {
36   label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
37       AshColorProvider::ContentLayerType::kTextColorPrimary));
38   TrayPopupUtils::SetLabelFontList(label_,
39                                    TrayPopupUtils::FontStyle::kSystemInfo);
40   label_->SetText(l10n_util::GetStringUTF16(message_id));
41 }
42 
GetClassName() const43 const char* TrayInfoLabel::GetClassName() const {
44   return "TrayInfoLabel";
45 }
46 
47 }  // namespace ash
48