audio_detailed_view.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2014 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. #ifndef ASH_SYSTEM_AUDIO_AUDIO_DETAILED_VIEW_H_
  5. #define ASH_SYSTEM_AUDIO_AUDIO_DETAILED_VIEW_H_
  6. #include <map>
  7. #include <memory>
  8. #include "ash/accessibility/accessibility_observer.h"
  9. #include "ash/ash_export.h"
  10. #include "ash/system/tray/tray_detailed_view.h"
  11. #include "ash/system/tray/tray_toggle_button.h"
  12. #include "base/callback.h"
  13. #include "chromeos/ash/components/audio/audio_device.h"
  14. #include "components/soda/soda_installer.h"
  15. #include "ui/views/controls/button/toggle_button.h"
  16. #include "ui/views/view.h"
  17. namespace gfx {
  18. struct VectorIcon;
  19. }
  20. namespace ash {
  21. class MicGainSliderController;
  22. class UnifiedAudioDetailedViewControllerSodaTest;
  23. class UnifiedAudioDetailedViewControllerTest;
  24. class ASH_EXPORT AudioDetailedView : public TrayDetailedView,
  25. public AccessibilityObserver,
  26. public speech::SodaInstaller::Observer {
  27. public:
  28. explicit AudioDetailedView(DetailedViewDelegate* delegate);
  29. AudioDetailedView(const AudioDetailedView&) = delete;
  30. AudioDetailedView& operator=(const AudioDetailedView&) = delete;
  31. ~AudioDetailedView() override;
  32. void Update();
  33. // views::View:
  34. const char* GetClassName() const override;
  35. using NoiseCancellationCallback =
  36. base::RepeatingCallback<void(uint64_t, views::View*)>;
  37. static void SetMapNoiseCancellationToggleCallbackForTest(
  38. NoiseCancellationCallback* map_noise_cancellation_toggle_callback);
  39. // AccessibilityObserver:
  40. void OnAccessibilityStatusChanged() override;
  41. private:
  42. friend class UnifiedAudioDetailedViewControllerSodaTest;
  43. friend class UnifiedAudioDetailedViewControllerTest;
  44. // Helper function to add non-clickable header rows within the scrollable
  45. // list.
  46. void AddAudioSubHeader(const gfx::VectorIcon& icon, int text_id);
  47. void CreateItems();
  48. void UpdateScrollableList();
  49. void UpdateAudioDevices();
  50. void OnInputNoiseCancellationTogglePressed();
  51. std::unique_ptr<views::View> CreateNoiseCancellationToggleRow(
  52. const AudioDevice& device);
  53. // TrayDetailedView:
  54. void HandleViewClicked(views::View* view) override;
  55. // SodaInstaller::Observer:
  56. void OnSodaInstalled(speech::LanguageCode language_code) override;
  57. void OnSodaInstallError(speech::LanguageCode language_code,
  58. speech::SodaInstaller::ErrorCode error_code) override;
  59. void OnSodaProgress(speech::LanguageCode language_code,
  60. int combined_progress) override;
  61. void MaybeShowSodaMessage(speech::LanguageCode language_code,
  62. std::u16string message);
  63. typedef std::map<views::View*, AudioDevice> AudioDeviceMap;
  64. std::unique_ptr<MicGainSliderController> mic_gain_controller_;
  65. AudioDeviceList output_devices_;
  66. AudioDeviceList input_devices_;
  67. AudioDeviceMap device_map_;
  68. HoverHighlightView* live_caption_view_ = nullptr;
  69. };
  70. } // namespace ash
  71. #endif // ASH_SYSTEM_AUDIO_AUDIO_DETAILED_VIEW_H_