Reland: Add browser_test for extension app API with missing schema
[chromium-blink-merge.git] / ash / wm / system_modal_container_layout_manager.h
blob6350337dce6224ebf52f7da2605e3b5be86ae038
1 // Copyright (c) 2012 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_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
6 #define ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
8 #include <vector>
10 #include "ash/ash_export.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ui/aura/layout_manager.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/keyboard/keyboard_controller_observer.h"
18 namespace aura {
19 class Window;
20 class EventFilter;
22 namespace gfx {
23 class Rect;
25 namespace views {
26 class Widget;
29 namespace ash {
31 // LayoutManager for the modal window container.
32 // System modal windows which are centered on the screen will be kept centered
33 // when the container size changes.
34 class ASH_EXPORT SystemModalContainerLayoutManager
35 : public aura::LayoutManager,
36 public aura::WindowObserver,
37 public keyboard::KeyboardControllerObserver {
38 public:
39 explicit SystemModalContainerLayoutManager(aura::Window* container);
40 virtual ~SystemModalContainerLayoutManager();
42 bool has_modal_background() const { return modal_background_ != NULL; }
44 // Overridden from aura::LayoutManager:
45 virtual void OnWindowResized() OVERRIDE;
46 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
47 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
48 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
49 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
50 bool visibile) OVERRIDE;
51 virtual void SetChildBounds(aura::Window* child,
52 const gfx::Rect& requested_bounds) OVERRIDE;
54 // Overridden from aura::WindowObserver:
55 virtual void OnWindowPropertyChanged(aura::Window* window,
56 const void* key,
57 intptr_t old) OVERRIDE;
58 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
60 // Overridden from keyboard::KeyboardControllerObserver:
61 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE;
63 // Can a given |window| receive and handle input events?
64 bool CanWindowReceiveEvents(aura::Window* window);
66 // Activates next modal window if any. Returns false if there
67 // are no more modal windows in this layout manager.
68 bool ActivateNextModalWindow();
70 // Creates modal background window, which is a partially-opaque
71 // fullscreen window. If there is already a modal background window,
72 // it will bring it the top.
73 void CreateModalBackground();
75 void DestroyModalBackground();
77 // Is the |window| modal background?
78 static bool IsModalBackground(aura::Window* window);
80 private:
81 void AddModalWindow(aura::Window* window);
82 void RemoveModalWindow(aura::Window* window);
84 // Reposition the dialogs to become visible after the work area changes.
85 void PositionDialogsAfterWorkAreaResize();
87 // Get the usable bounds rectangle for enclosed dialogs.
88 gfx::Rect GetUsableDialogArea();
90 // Gets the new bounds for a |window| to use which are either centered (if the
91 // window was previously centered) or fitted to the screen.
92 gfx::Rect GetCenteredAndOrFittedBounds(const aura::Window* window);
94 // Returns true if |window_bounds| is centered.
95 bool DialogIsCentered(const gfx::Rect& window_bounds);
97 aura::Window* modal_window() {
98 return !modal_windows_.empty() ? modal_windows_.back() : NULL;
101 // The container that owns the layout manager.
102 aura::Window* container_;
104 // A widget that dims the windows behind the modal window(s) being
105 // shown in |container_|.
106 views::Widget* modal_background_;
108 // A stack of modal windows. Only the topmost can receive events.
109 std::vector<aura::Window*> modal_windows_;
111 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager);
114 } // namespace ash
116 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_