Standardize usage of virtual/override/final specifiers.
[chromium-blink-merge.git] / ash / wm / maximize_mode / maximize_mode_window_manager.h
blobc6cba668ab8fc79c45c1235ccc06a51dd2f7af88
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.
5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
8 #include <map>
9 #include <set>
11 #include "ash/ash_export.h"
12 #include "ash/shell_observer.h"
13 #include "ash/wm/window_state.h"
14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h"
16 #include "ui/aura/window_observer.h"
17 #include "ui/events/event_handler.h"
18 #include "ui/gfx/display_observer.h"
20 namespace ui {
21 class TouchEvent;
24 namespace ash {
25 class MaximizeModeController;
26 class MaximizeModeWindowState;
28 // A window manager which - when created - will force all windows into maximized
29 // mode. Exception are panels and windows which cannot be maximized.
30 // Windows which cannot be maximized / resized are centered with a layer placed
31 // behind the window so that no other windows are visible and/or obscured.
32 // With the destruction of the manager all windows will be restored to their
33 // original state.
34 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
35 public gfx::DisplayObserver,
36 public ShellObserver,
37 public ui::EventHandler {
38 public:
39 // This should only be deleted by the creator (ash::Shell).
40 ~MaximizeModeWindowManager() override;
42 // Returns the number of maximized & tracked windows by this manager.
43 int GetNumberOfManagedWindows();
45 // Adds a window which needs to be maximized. This is used by other window
46 // managers for windows which needs to get tracked due to (upcoming) state
47 // changes.
48 // The call gets ignored if the window was already or should not be handled.
49 void AddWindow(aura::Window* window);
51 // Called from a window state object when it gets destroyed.
52 void WindowStateDestroyed(aura::Window* window);
54 // ShellObserver overrides:
55 void OnOverviewModeStarting() override;
56 void OnOverviewModeEnding() override;
58 // Overridden from WindowObserver:
59 void OnWindowDestroying(aura::Window* window) override;
60 void OnWindowAdded(aura::Window* window) override;
61 void OnWindowBoundsChanged(aura::Window* window,
62 const gfx::Rect& old_bounds,
63 const gfx::Rect& new_bounds) override;
65 // gfx::DisplayObserver overrides:
66 void OnDisplayAdded(const gfx::Display& display) override;
67 void OnDisplayRemoved(const gfx::Display& display) override;
68 void OnDisplayMetricsChanged(const gfx::Display& display,
69 uint32_t metrics) override;
71 // ui::EventHandler override:
72 void OnTouchEvent(ui::TouchEvent* event) override;
74 protected:
75 friend class MaximizeModeController;
77 // The object should only be created by the ash::Shell.
78 MaximizeModeWindowManager();
80 private:
81 typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
83 // Maximize all windows and restore their current state.
84 void MaximizeAllWindows();
86 // Restore all windows to their previous state.
87 void RestoreAllWindows();
89 // Set whether to defer bounds updates on all tracked windows. When set to
90 // false bounds will be updated as they may be stale.
91 void SetDeferBoundsUpdates(bool defer_bounds_updates);
93 // If the given window should be handled by us, this function will maximize it
94 // and add it to the list of known windows (remembering the initial show
95 // state).
96 // Note: If the given window cannot be handled by us the function will return
97 // immediately.
98 void MaximizeAndTrackWindow(aura::Window* window);
100 // Remove a window from our tracking list.
101 void ForgetWindow(aura::Window* window);
103 // Returns true when the given window should be modified in any way by us.
104 bool ShouldHandleWindow(aura::Window* window);
106 // Add window creation observers to track creation of new windows.
107 void AddWindowCreationObservers();
109 // Remove Window creation observers.
110 void RemoveWindowCreationObservers();
112 // Change the internal state (e.g. observers) when the display configuration
113 // changes.
114 void DisplayConfigurationChanged();
116 // Returns true when the |window| is a container window.
117 bool IsContainerWindow(aura::Window* window);
119 // Add a backdrop behind the currently active window on each desktop.
120 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
122 // Every window which got touched by our window manager gets added here.
123 WindowToState window_state_map_;
125 // All container windows which have to be tracked.
126 std::set<aura::Window*> observed_container_windows_;
128 // True if all backdrops are hidden.
129 bool backdrops_hidden_;
131 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
134 } // namespace ash
136 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_