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_LOCK_LAYOUT_MANAGER_H_
6 #define ASH_WM_LOCK_LAYOUT_MANAGER_H_
8 #include "ash/ash_export.h"
9 #include "ash/shell_delegate.h"
10 #include "ash/snap_to_pixel_layout_manager.h"
11 #include "ash/wm/wm_types.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/window_observer.h"
17 #include "ui/gfx/rect.h"
18 #include "ui/keyboard/keyboard_controller.h"
19 #include "ui/keyboard/keyboard_controller_observer.h"
36 // LockLayoutManager is used for the windows created in LockScreenContainer.
37 // For Chrome OS this includes out-of-box/login/lock/multi-profile login use
38 // cases. LockScreenContainer does not use default work area definition.
39 // By default work area is defined as display area minus shelf, docked windows
40 // and minus virtual keyboard bounds.
41 // For windows in LockScreenContainer work area is display area minus virtual
42 // keyboard bounds (only if keyboard overscroll is disabled). If keyboard
43 // overscroll is enabled then work area always equals to display area size since
44 // virtual keyboard changes inner workspace of each WebContents.
45 // For all windows in LockScreenContainer default wm::WindowState is replaced
46 // with LockWindowState.
47 class ASH_EXPORT LockLayoutManager
48 : public SnapToPixelLayoutManager
,
49 public aura::WindowObserver
,
50 public VirtualKeyboardStateObserver
,
51 public keyboard::KeyboardControllerObserver
{
53 explicit LockLayoutManager(aura::Window
* window
);
54 virtual ~LockLayoutManager();
56 // Overridden from aura::LayoutManager:
57 virtual void OnWindowResized() OVERRIDE
;
58 virtual void OnWindowAddedToLayout(aura::Window
* child
) OVERRIDE
;
59 virtual void OnWillRemoveWindowFromLayout(aura::Window
* child
) OVERRIDE
;
60 virtual void OnWindowRemovedFromLayout(aura::Window
* child
) OVERRIDE
;
61 virtual void OnChildWindowVisibilityChanged(aura::Window
* child
,
62 bool visibile
) OVERRIDE
;
63 virtual void SetChildBounds(aura::Window
* child
,
64 const gfx::Rect
& requested_bounds
) OVERRIDE
;
66 // Overriden from aura::WindowObserver:
67 virtual void OnWindowHierarchyChanged(
68 const WindowObserver::HierarchyChangeParams
& params
) OVERRIDE
;
69 virtual void OnWindowPropertyChanged(aura::Window
* window
,
71 intptr_t old
) OVERRIDE
;
72 virtual void OnWindowStackingChanged(aura::Window
* window
) OVERRIDE
;
73 virtual void OnWindowDestroying(aura::Window
* window
) OVERRIDE
;
74 virtual void OnWindowBoundsChanged(aura::Window
* window
,
75 const gfx::Rect
& old_bounds
,
76 const gfx::Rect
& new_bounds
) OVERRIDE
;
78 // VirtualKeyboardStateObserver overrides:
79 virtual void OnVirtualKeyboardStateChanged(bool activated
) OVERRIDE
;
81 // keyboard::KeyboardControllerObserver overrides:
82 virtual void OnKeyboardBoundsChanging(const gfx::Rect
& new_bounds
) OVERRIDE
;
85 // Adjusts the bounds of all managed windows when the display area changes.
86 // This happens when the display size, work area insets has changed.
87 void AdjustWindowsForWorkAreaChange(const wm::WMEvent
* event
);
89 aura::Window
* window_
;
90 aura::Window
* root_window_
;
92 // True is subscribed as keyboard controller observer.
93 bool is_observing_keyboard_
;
95 // The bounds of the keyboard.
96 gfx::Rect keyboard_bounds_
;
98 DISALLOW_COPY_AND_ASSIGN(LockLayoutManager
);
103 #endif // ASH_WM_LOCK_LAYOUT_MANAGER_H_