Reland: Add browser_test for extension app API with missing schema
[chromium-blink-merge.git] / ash / wm / maximize_mode / maximize_mode_window_manager.h
blob2b421c5754c8c2074d75f780dc069cbc117dc909
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 MaximizeModeWindowState;
26 class Shell;
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 virtual ~MaximizeModeWindowManager();
42 // Returns the number of maximized & tracked windows by this manager.
43 int GetNumberOfManagedWindows();
45 // Called from a window state object when it gets destroyed.
46 void WindowStateDestroyed(aura::Window* window);
48 // ShellObserver overrides:
49 virtual void OnOverviewModeStarting() OVERRIDE;
50 virtual void OnOverviewModeEnding() OVERRIDE;
52 // Overridden from WindowObserver:
53 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
54 virtual void OnWindowAdded(aura::Window* window) OVERRIDE;
55 virtual void OnWindowBoundsChanged(aura::Window* window,
56 const gfx::Rect& old_bounds,
57 const gfx::Rect& new_bounds) OVERRIDE;
59 // aura::DisplayObserver overrides:
60 virtual void OnDisplayBoundsChanged(
61 const gfx::Display& display) OVERRIDE;
62 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
63 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
65 // ui::EventHandler override:
66 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
68 protected:
69 friend class ash::Shell;
71 // The object should only be created by the ash::Shell.
72 MaximizeModeWindowManager();
74 private:
75 typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
77 // Maximize all windows and restore their current state.
78 void MaximizeAllWindows();
80 // Restore all windows to their previous state.
81 void RestoreAllWindows();
83 // If the given window should be handled by us, this function will maximize it
84 // and add it to the list of known windows (remembering the initial show
85 // state).
86 // Note: If the given window cannot be handled by us the function will return
87 // immediately.
88 void MaximizeAndTrackWindow(aura::Window* window);
90 // Remove a window from our tracking list.
91 void ForgetWindow(aura::Window* window);
93 // Returns true when the given window should be modified in any way by us.
94 bool ShouldHandleWindow(aura::Window* window);
96 // Add window creation observers to track creation of new windows.
97 void AddWindowCreationObservers();
99 // Remove Window creation observers.
100 void RemoveWindowCreationObservers();
102 // Change the internal state (e.g. observers) when the display configuration
103 // changes.
104 void DisplayConfigurationChanged();
106 // Returns true when the |window| is a container window.
107 bool IsContainerWindow(aura::Window* window);
109 // Add a backdrop behind the currently active window on each desktop.
110 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
112 // Every window which got touched by our window manager gets added here.
113 WindowToState window_state_map_;
115 // All container windows which have to be tracked.
116 std::set<aura::Window*> observed_container_windows_;
118 // True if all backdrops are hidden.
119 bool backdrops_hidden_;
121 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
124 } // namespace ash
126 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_