Chromium Code Reviews| Index: ui/aura/window.cc |
| diff --git a/ui/aura/window.cc b/ui/aura/window.cc |
| index 07c48e64fc089fbc2a43102b87cbb791ca4dba68..56f8f2cbc67c8658f9ee992ba87114ce643e6d14 100644 |
| --- a/ui/aura/window.cc |
| +++ b/ui/aura/window.cc |
| @@ -13,6 +13,7 @@ |
| #include "ui/aura/event_filter.h" |
| #include "ui/aura/layout_manager.h" |
| #include "ui/aura/window_delegate.h" |
| +#include "ui/aura/window_observer.h" |
| #include "ui/aura/window_types.h" |
| #include "ui/base/animation/multi_animation.h" |
| #include "ui/gfx/canvas_skia.h" |
| @@ -35,6 +36,8 @@ Window::Window(WindowDelegate* delegate) |
| } |
| Window::~Window() { |
| + FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowClosing(this)); |
| + |
| // Let the delegate know we're in the processing of destroying. |
| if (delegate_) |
| delegate_->OnWindowDestroying(); |
| @@ -114,10 +117,14 @@ void Window::Restore() { |
| void Window::Activate() { |
| // If we support minimization need to ensure this restores the window first. |
| aura::Desktop::GetInstance()->SetActiveWindow(this, this); |
| + FOR_EACH_OBSERVER(WindowObserver, observers_, |
|
sky
2011/10/12 22:05:38
This should be up in the Desktop, not here (there
sadrul
2011/10/12 22:59:58
Removed this, added DesktopObserver::OnActiveWindo
|
| + OnWindowActivationChanged(this, true)); |
| } |
| void Window::Deactivate() { |
| aura::Desktop::GetInstance()->Deactivate(this); |
| + FOR_EACH_OBSERVER(WindowObserver, observers_, |
|
sky
2011/10/12 22:05:38
Same comment, this should be in Desktop.
sadrul
2011/10/12 22:59:58
Done.
|
| + OnWindowActivationChanged(this, false)); |
| } |
| bool Window::IsActive() const { |
| @@ -259,6 +266,14 @@ bool Window::OnKeyEvent(KeyEvent* event) { |
| return IsVisible() && delegate_->OnKeyEvent(event); |
| } |
| +void Window::AddObserver(WindowObserver* observer) { |
| + observers_.AddObserver(observer); |
| +} |
| + |
| +void Window::RemoveObserver(WindowObserver* observer) { |
| + observers_.RemoveObserver(observer); |
| +} |
| + |
| bool Window::HitTest(const gfx::Point& point) { |
| gfx::Rect local_bounds(gfx::Point(), bounds().size()); |
| // TODO(beng): hittest masks. |
| @@ -371,6 +386,9 @@ void Window::SetVisible(bool visible) { |
| if (delegate_) |
| delegate_->OnWindowVisibilityChanged(is_visible); |
| } |
| + |
| + FOR_EACH_OBSERVER(WindowObserver, observers_, |
| + OnWindowVisibilityChanged(this, visible)); |
| } |
| void Window::SchedulePaint() { |