| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/desktop.h" | 5 #include "ui/aura/desktop.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "ui/aura/desktop_delegate.h" | 10 #include "ui/aura/desktop_delegate.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool Desktop::OnKeyEvent(const KeyEvent& event) { | 93 bool Desktop::OnKeyEvent(const KeyEvent& event) { |
| 94 return window_->HandleKeyEvent(event); | 94 return window_->HandleKeyEvent(event); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Desktop::OnHostResized(const gfx::Size& size) { | 97 void Desktop::OnHostResized(const gfx::Size& size) { |
| 98 gfx::Rect bounds(0, 0, size.width(), size.height()); | 98 gfx::Rect bounds(0, 0, size.width(), size.height()); |
| 99 compositor_->WidgetSizeChanged(size); | 99 compositor_->WidgetSizeChanged(size); |
| 100 window_->SetBounds(bounds); | 100 window_->SetBounds(bounds); |
| 101 FOR_EACH_OBSERVER(Observer, observers_, OnDesktopResized(size)); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void Desktop::ScheduleDraw() { | 104 void Desktop::ScheduleDraw() { |
| 104 if (!schedule_paint_factory_.HasWeakPtrs()) { | 105 if (!schedule_paint_factory_.HasWeakPtrs()) { |
| 105 MessageLoop::current()->PostTask( | 106 MessageLoop::current()->PostTask( |
| 106 FROM_HERE, | 107 FROM_HERE, |
| 107 base::Bind(&Desktop::Draw, schedule_paint_factory_.GetWeakPtr())); | 108 base::Bind(&Desktop::Draw, schedule_paint_factory_.GetWeakPtr())); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Reset active_window_ before invoking SetActiveWindow so that we don't | 158 // Reset active_window_ before invoking SetActiveWindow so that we don't |
| 158 // attempt to notify it while running its destructor. | 159 // attempt to notify it while running its destructor. |
| 159 active_window_ = NULL; | 160 active_window_ = NULL; |
| 160 SetActiveWindow(delegate_->GetTopmostWindowToActivate(window), NULL); | 161 SetActiveWindow(delegate_->GetTopmostWindowToActivate(window), NULL); |
| 161 } | 162 } |
| 162 | 163 |
| 163 MessageLoop::Dispatcher* Desktop::GetDispatcher() { | 164 MessageLoop::Dispatcher* Desktop::GetDispatcher() { |
| 164 return host_.get(); | 165 return host_.get(); |
| 165 } | 166 } |
| 166 | 167 |
| 168 void Desktop::AddObserver(Desktop::Observer* observer) { |
| 169 observers_.AddObserver(observer); |
| 170 } |
| 171 |
| 172 void Desktop::RemoveObserver(Desktop::Observer* observer) { |
| 173 observers_.RemoveObserver(observer); |
| 174 } |
| 175 |
| 176 bool Desktop::HasObserver(Desktop::Observer* observer) { |
| 177 return observers_.HasObserver(observer); |
| 178 } |
| 179 |
| 167 // static | 180 // static |
| 168 Desktop* Desktop::GetInstance() { | 181 Desktop* Desktop::GetInstance() { |
| 169 if (!instance_) { | 182 if (!instance_) { |
| 170 instance_ = new Desktop; | 183 instance_ = new Desktop; |
| 171 instance_->Init(); | 184 instance_->Init(); |
| 172 } | 185 } |
| 173 return instance_; | 186 return instance_; |
| 174 } | 187 } |
| 175 | 188 |
| 176 } // namespace aura | 189 } // namespace aura |
| OLD | NEW |