locale_feature_pod_controller.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2018 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. #include "ash/system/locale/locale_feature_pod_controller.h"
  5. #include "ash/resources/vector_icons/vector_icons.h"
  6. #include "ash/shell.h"
  7. #include "ash/strings/grit/ash_strings.h"
  8. #include "ash/system/model/locale_model.h"
  9. #include "ash/system/model/system_tray_model.h"
  10. #include "ash/system/unified/feature_pod_button.h"
  11. #include "ash/system/unified/unified_system_tray_controller.h"
  12. #include "base/i18n/case_conversion.h"
  13. #include "base/strings/utf_string_conversions.h"
  14. #include "ui/base/l10n/l10n_util.h"
  15. namespace ash {
  16. LocaleFeaturePodController::LocaleFeaturePodController(
  17. UnifiedSystemTrayController* tray_controller)
  18. : tray_controller_(tray_controller) {}
  19. LocaleFeaturePodController::~LocaleFeaturePodController() = default;
  20. FeaturePodButton* LocaleFeaturePodController::CreateButton() {
  21. auto* button = new FeaturePodButton(this, /*is_togglable=*/false);
  22. const bool visible =
  23. !Shell::Get()->system_tray_model()->locale()->locale_list().empty();
  24. button->SetVisible(visible);
  25. if (visible) {
  26. button->SetVectorIcon(kUnifiedMenuLocaleIcon);
  27. button->SetIconAndLabelTooltips(
  28. l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCALE_TOOLTIP));
  29. button->SetLabel(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCALE));
  30. button->ShowDetailedViewArrow();
  31. button->DisableLabelButtonFocus();
  32. button->SetSubLabel(base::i18n::ToUpper(base::UTF8ToUTF16(
  33. l10n_util::GetLanguage(Shell::Get()
  34. ->system_tray_model()
  35. ->locale()
  36. ->current_locale_iso_code()))));
  37. }
  38. return button;
  39. }
  40. void LocaleFeaturePodController::OnIconPressed() {
  41. tray_controller_->ShowLocaleDetailedView();
  42. }
  43. SystemTrayItemUmaType LocaleFeaturePodController::GetUmaType() const {
  44. return SystemTrayItemUmaType::UMA_LOCALE;
  45. }
  46. } // namespace ash