blob: 778cad0e5086b2344048d44035c297186e1abcdb [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/accessibility/accessibility_observer.h"
#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/system/tray/tray_background_view.h"
#include "base/macros.h"
#include "ui/views/controls/image_view.h"
namespace views {
class ImageView;
namespace ash {
// A button in the tray that lets users start/stop Select-to-Speak.
class ASH_EXPORT SelectToSpeakTray : public TrayBackgroundView,
public AccessibilityObserver,
public SessionObserver {
explicit SelectToSpeakTray(Shelf* shelf);
~SelectToSpeakTray() override;
// TrayBackgroundView:
base::string16 GetAccessibleNameForTray() override;
const char* GetClassName() const override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override {}
void ClickedOutsideBubble() override {}
bool PerformAction(const ui::Event& event) override;
// AccessibilityObserver:
void OnAccessibilityStatusChanged() override;
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
friend class SelectToSpeakTrayTest;
// Updates the icons color depending on if the user is logged-in or not.
void UpdateIconsForSession();
// Sets the icon when select-to-speak is activated (speaking) / deactivated.
// Also updates visibility when select-to-speak is enabled / disabled.
void CheckStatusAndUpdateIcon();
gfx::ImageSkia inactive_image_;
gfx::ImageSkia selecting_image_;
gfx::ImageSkia speaking_image_;
// Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_;
ScopedSessionObserver session_observer_{this};
} // namespace ash