ambient_container_view.cc 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2019 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/ambient/ui/ambient_container_view.h"
  5. #include <memory>
  6. #include <utility>
  7. #include "ash/ambient/metrics/ambient_multi_screen_metrics_recorder.h"
  8. #include "ash/ambient/resources/ambient_animation_static_resources.h"
  9. #include "ash/ambient/ui/ambient_animation_view.h"
  10. #include "ash/ambient/ui/ambient_view_delegate.h"
  11. #include "ash/ambient/ui/ambient_view_ids.h"
  12. #include "ash/ambient/ui/photo_view.h"
  13. #include "ash/ambient/util/ambient_util.h"
  14. #include "ash/public/cpp/ambient/ambient_metrics.h"
  15. #include "ash/public/cpp/shell_window_ids.h"
  16. #include "base/check.h"
  17. #include "ui/aura/window.h"
  18. #include "ui/base/metadata/metadata_impl_macros.h"
  19. #include "ui/views/accessibility/accessibility_paint_checks.h"
  20. #include "ui/views/background.h"
  21. #include "ui/views/layout/fill_layout.h"
  22. #include "ui/views/view.h"
  23. #include "ui/views/widget/widget.h"
  24. namespace ash {
  25. AmbientContainerView::AmbientContainerView(
  26. AmbientViewDelegateImpl* delegate,
  27. AmbientAnimationProgressTracker* progress_tracker,
  28. std::unique_ptr<AmbientAnimationStaticResources> animation_static_resources,
  29. AmbientMultiScreenMetricsRecorder* multi_screen_metrics_recorder) {
  30. DCHECK(delegate);
  31. DCHECK(multi_screen_metrics_recorder);
  32. // TODO(crbug.com/1218186): Remove this, this is in place temporarily to be
  33. // able to submit accessibility checks, but this focusable View needs to
  34. // add a name so that the screen reader knows what to announce.
  35. SetProperty(views::kSkipAccessibilityPaintChecks, true);
  36. SetID(AmbientViewID::kAmbientContainerView);
  37. // TODO(b/139954108): Choose a better dark mode theme color.
  38. SetBackground(views::CreateSolidBackground(SK_ColorBLACK));
  39. // Updates focus behavior to receive key press events.
  40. SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
  41. SetLayoutManager(std::make_unique<views::FillLayout>());
  42. View* main_rendering_view = nullptr;
  43. AmbientAnimationTheme theme =
  44. animation_static_resources
  45. ? animation_static_resources->GetAmbientAnimationTheme()
  46. : AmbientAnimationTheme::kSlideshow;
  47. if (animation_static_resources) {
  48. main_rendering_view = AddChildView(std::make_unique<AmbientAnimationView>(
  49. delegate, progress_tracker, std::move(animation_static_resources),
  50. multi_screen_metrics_recorder));
  51. } else {
  52. main_rendering_view = AddChildView(std::make_unique<PhotoView>(delegate));
  53. multi_screen_metrics_recorder->RegisterScreen(/*animation=*/nullptr);
  54. }
  55. orientation_metrics_recorder_ =
  56. std::make_unique<ambient::AmbientOrientationMetricsRecorder>(
  57. main_rendering_view, theme);
  58. }
  59. AmbientContainerView::~AmbientContainerView() = default;
  60. BEGIN_METADATA(AmbientContainerView, views::View)
  61. END_METADATA
  62. } // namespace ash