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