Password manager internals page: Introduce logger in renderer
[chromium-blink-merge.git] / ui / aura / window_observer.h
blob926e5c4428a5b25a9ad09b0ae3f713a927b3cb25
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 UI_AURA_WINDOW_OBSERVER_H_
6 #define UI_AURA_WINDOW_OBSERVER_H_
8 #include "base/basictypes.h"
9 #include "ui/aura/aura_export.h"
11 namespace gfx {
12 class Rect;
13 } // namespace gfx
15 namespace aura {
17 class Window;
19 class AURA_EXPORT WindowObserver {
20 public:
21 struct HierarchyChangeParams {
22 enum HierarchyChangePhase {
23 HIERARCHY_CHANGING,
24 HIERARCHY_CHANGED
27 Window* target; // The window that was added or removed.
28 Window* new_parent;
29 Window* old_parent;
30 HierarchyChangePhase phase;
31 Window* receiver; // The window receiving the notification.
34 // Called when a window is added or removed. Notifications are sent to the
35 // following hierarchies in this order:
36 // 1. |target|.
37 // 2. |target|'s child hierarchy.
38 // 3. |target|'s parent hierarchy in its |old_parent|
39 // (only for Changing notifications).
40 // 3. |target|'s parent hierarchy in its |new_parent|.
41 // (only for Changed notifications).
42 // This sequence is performed via the Changing and Changed notifications below
43 // before and after the change is committed.
44 virtual void OnWindowHierarchyChanging(const HierarchyChangeParams& params) {}
45 virtual void OnWindowHierarchyChanged(const HierarchyChangeParams& params) {}
47 // Invoked when |new_window| has been added as a child of this window.
48 virtual void OnWindowAdded(Window* new_window) {}
50 // Invoked prior to removing |window| as a child of this window.
51 virtual void OnWillRemoveWindow(Window* window) {}
53 // Invoked when this window's parent window changes. |parent| may be NULL.
54 virtual void OnWindowParentChanged(Window* window, Window* parent) {}
56 // Invoked when SetProperty(), ClearProperty(), or
57 // NativeWidgetAura::SetNativeWindowProperty() is called on the window.
58 // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty)
59 // or a const char* (SetNativeWindowProperty). Either way, it can simply be
60 // compared for equality with the property constant. |old| is the old property
61 // value, which must be cast to the appropriate type before use.
62 virtual void OnWindowPropertyChanged(Window* window,
63 const void* key,
64 intptr_t old) {}
66 // Invoked when SetVisible() is invoked on a window. |visible| is the
67 // value supplied to SetVisible(). If |visible| is true, window->IsVisible()
68 // may still return false. See description in Window::IsVisible() for details.
69 virtual void OnWindowVisibilityChanging(Window* window, bool visible) {}
70 virtual void OnWindowVisibilityChanged(Window* window, bool visible) {}
72 // Invoked when SetBounds() is invoked on |window|. |old_bounds| and
73 // |new_bounds| are in parent coordinates.
74 virtual void OnWindowBoundsChanged(Window* window,
75 const gfx::Rect& old_bounds,
76 const gfx::Rect& new_bounds) {}
78 // Invoked when SetTransform() is invoked on |window|.
79 virtual void OnWindowTransforming(Window* window) {}
80 virtual void OnWindowTransformed(Window* window) {}
82 // Invoked when |window|'s position among its siblings in the stacking order
83 // has changed.
84 virtual void OnWindowStackingChanged(Window* window) {}
86 // Invoked when a region of |window| is scheduled to be redrawn.
87 virtual void OnWindowPaintScheduled(Window* window,
88 const gfx::Rect& region) {}
90 // Invoked when the Window is being destroyed (i.e. from the start of its
91 // destructor). This is called before the window is removed from its parent.
92 virtual void OnWindowDestroying(Window* window) {}
94 // Invoked when the Window has been destroyed (i.e. at the end of
95 // its destructor). This is called after the window is removed from
96 // its parent. Window automatically removes its WindowObservers
97 // before calling this method, so the following code is no op.
99 // void MyWindowObserver::OnWindowDestroyed(aura::Window* window) {
100 // window->RemoveObserver(this);
101 // }
102 virtual void OnWindowDestroyed(Window* window) {}
104 // Called when a Window has been added to a RootWindow.
105 virtual void OnWindowAddedToRootWindow(Window* window) {}
107 // Called when a Window is about to be removed from a root Window.
108 // |new_root| contains the new root Window if it is being added to one
109 // atomically.
110 virtual void OnWindowRemovingFromRootWindow(Window* window,
111 Window* new_root) {}
113 protected:
114 virtual ~WindowObserver() {}
117 } // namespace aura
119 #endif // UI_AURA_WINDOW_OBSERVER_H_