blob: f16e818dce36b6a47b76d7c232296d04217ac1b1 [file] [log] [blame]
James Cookb263b512018-03-07 22:30:331// 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#ifndef ASH_ACCESSIBILITY_ACCESSIBILITY_PANEL_LAYOUT_MANAGER_H_
6#define ASH_ACCESSIBILITY_ACCESSIBILITY_PANEL_LAYOUT_MANAGER_H_
7
8#include "ash/ash_export.h"
9#include "ash/shell_observer.h"
10#include "base/macros.h"
11#include "ui/aura/layout_manager.h"
12#include "ui/display/display_observer.h"
13#include "ui/wm/public/activation_change_observer.h"
14
15namespace aura {
16class Window;
17}
18
19namespace ash {
20
21// AccessibilityPanelLayoutManager manages the container window used for the
22// ChromeVox spoken feedback panel, which sits at the top of the display. It
23// insets the display work area bounds when ChromeVox is visible. The ChromeVox
24// panel is created by Chrome because spoken feedback is implemented by an
25// extension. Exported for test.
26class ASH_EXPORT AccessibilityPanelLayoutManager
27 : public aura::LayoutManager,
28 public display::DisplayObserver,
29 public ::wm::ActivationChangeObserver,
30 public ash::ShellObserver {
31 public:
32 // Height of the panel in DIPs. Public for test.
33 static constexpr int kPanelHeight = 35;
34
35 AccessibilityPanelLayoutManager();
36 ~AccessibilityPanelLayoutManager() override;
37
38 // Sets whether the panel covers the entire display.
39 void SetPanelFullscreen(bool fullscreen);
40
41 // aura::LayoutManager:
42 void OnWindowResized() override {}
43 void OnWindowAddedToLayout(aura::Window* child) override;
44 void OnWillRemoveWindowFromLayout(aura::Window* child) override {}
45 void OnWindowRemovedFromLayout(aura::Window* child) override;
46 void OnChildWindowVisibilityChanged(aura::Window* child,
47 bool visible) override;
48 void SetChildBounds(aura::Window* child,
49 const gfx::Rect& requested_bounds) override;
50
51 // DisplayObserver:
52 void OnDisplayAdded(const display::Display& new_display) override {}
53 void OnDisplayRemoved(const display::Display& old_display) override {}
54 void OnDisplayMetricsChanged(const display::Display& display,
55 uint32_t changed_metrics) override;
56
57 // ::wm::ActivationChangeObserver:
58 void OnWindowActivated(ActivationReason reason,
59 aura::Window* gained_active,
60 aura::Window* lost_active) override;
61
62 // ShellObserver:
63 void OnFullscreenStateChanged(bool is_fullscreen,
64 aura::Window* root_window) override;
65
66 aura::Window* panel_window_for_test() { return panel_window_; }
67
68 private:
69 // Updates the panel window bounds.
70 void UpdateWindowBounds();
71
72 // Updates the display work area to account for the panel.
73 void UpdateWorkArea();
74
75 // The panel being managed (e.g. the ChromeVoxPanel's native aura window).
76 aura::Window* panel_window_ = nullptr;
77
78 // Whether the panel itself is filling the display.
79 bool panel_fullscreen_ = false;
80
81 DISALLOW_COPY_AND_ASSIGN(AccessibilityPanelLayoutManager);
82};
83
84} // namespace ash
85
86#endif // ASH_ACCESSIBILITY_ACCESSIBILITY_PANEL_LAYOUT_MANAGER_H_