Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / ash / wm / base_layout_manager.h
blob7ed9da663a13b01a6a8b0dba58f97622431c1012
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_BASE_LAYOUT_MANAGER_H_
6 #define ASH_WM_BASE_LAYOUT_MANAGER_H_
8 #include <set>
10 #include "ash/ash_export.h"
11 #include "ash/shell_observer.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "ui/aura/client/activation_change_observer.h"
15 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/root_window_observer.h"
17 #include "ui/aura/window_observer.h"
18 #include "ui/base/events/event_handler.h"
19 #include "ui/base/ui_base_types.h"
21 namespace aura {
22 class RootWindow;
23 class Window;
26 namespace ash {
27 namespace internal {
29 // BaseLayoutManager is the simplest possible implementation for a window
30 // layout manager. It listens for changes to kShowStateKey and resizes the
31 // window appropriately. Subclasses should be sure to invoke the base class
32 // for adding and removing windows, otherwise show state will not be tracked
33 // properly.
34 class ASH_EXPORT BaseLayoutManager
35 : public aura::LayoutManager,
36 public aura::RootWindowObserver,
37 public ash::ShellObserver,
38 public aura::WindowObserver,
39 public aura::client::ActivationChangeObserver {
40 public:
41 typedef std::set<aura::Window*> WindowSet;
43 explicit BaseLayoutManager(aura::RootWindow* root_window);
44 virtual ~BaseLayoutManager();
46 const WindowSet& windows() const { return windows_; }
48 // Given a |window| and tentative |restore_bounds|, returns new bounds that
49 // ensure that at least a few pixels of the screen background are visible
50 // outside the edges of the window.
51 static gfx::Rect BoundsWithScreenEdgeVisible(aura::Window* window,
52 const gfx::Rect& restore_bounds);
54 // LayoutManager overrides:
55 virtual void OnWindowResized() OVERRIDE;
56 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
57 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
58 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
59 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
60 bool visible) OVERRIDE;
61 virtual void SetChildBounds(aura::Window* child,
62 const gfx::Rect& requested_bounds) OVERRIDE;
64 // RootWindowObserver overrides:
65 virtual void OnRootWindowResized(const aura::RootWindow* root,
66 const gfx::Size& old_size) OVERRIDE;
68 // ash::ShellObserver overrides:
69 virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE;
71 // WindowObserver overrides:
72 virtual void OnWindowPropertyChanged(aura::Window* window,
73 const void* key,
74 intptr_t old) OVERRIDE;
75 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
77 // aura::client::ActivationChangeObserver overrides:
78 virtual void OnWindowActivated(aura::Window* gained_active,
79 aura::Window* lost_active) OVERRIDE;
81 protected:
82 // Invoked from OnWindowPropertyChanged() if |kShowStateKey| changes.
83 virtual void ShowStateChanged(aura::Window* window,
84 ui::WindowShowState last_show_state);
86 private:
87 // Update window bounds based on a change in show state.
88 void UpdateBoundsFromShowState(aura::Window* window);
90 // Adjusts the window sizes when the screen changes its size or its
91 // work area insets.
92 void AdjustWindowSizesForScreenChange();
94 // Set of windows we're listening to.
95 WindowSet windows_;
97 aura::RootWindow* root_window_;
99 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManager);
102 } // namespace internal
103 } // namespace ash
105 #endif // ASH_WM_BASE_LAYOUT_MANAGER_H_