login_shelf_widget.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2022 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_SHELF_LOGIN_SHELF_WIDGET_H_
  5. #define ASH_SHELF_LOGIN_SHELF_WIDGET_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/session/session_observer.h"
  8. #include "ash/shelf/shelf_component.h"
  9. #include "ui/views/widget/widget.h"
  10. namespace ash {
  11. class Shelf;
  12. class LoginShelfView;
  13. // The widget showing the login shelf. Exists separately from `ShelfWidget` so
  14. // that the login shelf can be focused without stacking the shelf widget above
  15. // other shelf components.
  16. class ASH_EXPORT LoginShelfWidget : public ShelfComponent,
  17. public views::Widget,
  18. public SessionObserver {
  19. public:
  20. LoginShelfWidget(Shelf* shelf, aura::Window* container);
  21. LoginShelfWidget(const LoginShelfWidget&) = delete;
  22. LoginShelfWidget& operator=(const LoginShelfWidget&) = delete;
  23. ~LoginShelfWidget() override;
  24. // Specifies whether the default focused view is the login shelf's last
  25. // focusable child.
  26. void SetDefaultLastFocusableChild(bool reverse);
  27. void SetLoginShelfButtonOpacity(float target_opacity);
  28. // Called when shelf layout manager detects a locale change.
  29. void HandleLocaleChange();
  30. // ShelfComponent:
  31. void CalculateTargetBounds() override;
  32. gfx::Rect GetTargetBounds() const override;
  33. void UpdateLayout(bool animate) override;
  34. void UpdateTargetBoundsForGesture(int shelf_position) override {}
  35. LoginShelfView* login_shelf_view() { return login_shelf_view_; }
  36. private:
  37. // views::Widget:
  38. bool OnNativeWidgetActivationChanged(bool active) override;
  39. // SessionObserver:
  40. void OnSessionStateChanged(session_manager::SessionState state) override;
  41. void OnUserSessionAdded(const AccountId& account_id) override;
  42. const base::raw_ptr<Shelf> shelf_;
  43. class LoginShelfWidgetDelegate;
  44. base::raw_ptr<LoginShelfWidgetDelegate> delegate_;
  45. ScopedSessionObserver scoped_session_observer_;
  46. base::raw_ptr<LoginShelfView> login_shelf_view_ = nullptr;
  47. // The target widget bounds in screen coordinates.
  48. gfx::Rect target_bounds_;
  49. };
  50. } // namespace ash
  51. #endif // ASH_SHELF_LOGIN_SHELF_WIDGET_H_