| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "athena/env/public/athena_env.h" | 5 #include "athena/env/public/athena_env.h" |
| 6 | 6 |
| 7 #include <vector> |
| 8 |
| 7 #include "athena/util/fill_layout_manager.h" | 9 #include "athena/util/fill_layout_manager.h" |
| 8 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
| 11 #include "ui/aura/client/default_capture_client.h" | 13 #include "ui/aura/client/default_capture_client.h" |
| 12 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
| 13 #include "ui/aura/test/test_screen.h" | 15 #include "ui/aura/test/test_screen.h" |
| 14 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 15 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
| 16 #include "ui/aura/window_tree_host_observer.h" | 18 #include "ui/aura/window_tree_host_observer.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 244 |
| 243 ScreenForShutdown::Create(screen_.get()); | 245 ScreenForShutdown::Create(screen_.get()); |
| 244 screen_.reset(); | 246 screen_.reset(); |
| 245 aura::Env::DeleteInstance(); | 247 aura::Env::DeleteInstance(); |
| 246 | 248 |
| 247 display_configurator_->RemoveObserver(this); | 249 display_configurator_->RemoveObserver(this); |
| 248 display_configurator_.reset(); | 250 display_configurator_.reset(); |
| 249 } | 251 } |
| 250 | 252 |
| 251 private: | 253 private: |
| 254 struct Finder { |
| 255 explicit Finder(const base::Closure& c) : closure(c) {} |
| 256 bool operator()(const base::Closure& other) { |
| 257 return closure.Equals(other); |
| 258 } |
| 259 base::Closure closure; |
| 260 }; |
| 261 |
| 262 // AthenaEnv: |
| 252 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } | 263 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } |
| 253 | 264 |
| 254 // AthenaEnv: | |
| 255 virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) OVERRIDE { | 265 virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) OVERRIDE { |
| 256 screen_->SetWorkAreaInsets(insets); | 266 screen_->SetWorkAreaInsets(insets); |
| 257 } | 267 } |
| 258 | 268 |
| 269 virtual void AddTerminatingCallback(const base::Closure& closure) OVERRIDE { |
| 270 if (closure.is_null()) |
| 271 return; |
| 272 DCHECK(terminating_callbacks_.end() == |
| 273 std::find_if(terminating_callbacks_.begin(), |
| 274 terminating_callbacks_.end(), |
| 275 Finder(closure))); |
| 276 terminating_callbacks_.push_back(closure); |
| 277 } |
| 278 |
| 279 virtual void RemoveTerminatingCallback( |
| 280 const base::Closure& closure) OVERRIDE { |
| 281 std::vector<base::Closure>::iterator iter = |
| 282 std::find_if(terminating_callbacks_.begin(), |
| 283 terminating_callbacks_.end(), |
| 284 Finder(closure)); |
| 285 if (iter != terminating_callbacks_.end()) |
| 286 terminating_callbacks_.erase(iter); |
| 287 } |
| 288 |
| 289 virtual void OnTerminating() OVERRIDE { |
| 290 for (std::vector<base::Closure>::iterator iter = |
| 291 terminating_callbacks_.begin(); |
| 292 iter != terminating_callbacks_.end(); |
| 293 ++iter) { |
| 294 iter->Run(); |
| 295 } |
| 296 } |
| 297 |
| 259 // ui::DisplayConfigurator::Observer: | 298 // ui::DisplayConfigurator::Observer: |
| 260 virtual void OnDisplayModeChanged(const std::vector< | 299 virtual void OnDisplayModeChanged(const std::vector< |
| 261 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE { | 300 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE { |
| 262 gfx::Size size = GetPrimaryDisplaySize(); | 301 gfx::Size size = GetPrimaryDisplaySize(); |
| 263 if (!size.IsEmpty()) | 302 if (!size.IsEmpty()) |
| 264 host_->UpdateRootWindowSize(size); | 303 host_->UpdateRootWindowSize(size); |
| 265 } | 304 } |
| 266 | 305 |
| 267 // aura::WindowTreeHostObserver: | 306 // aura::WindowTreeHostObserver: |
| 268 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE { | 307 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 283 scoped_ptr<aura::WindowTreeHost> host_; | 322 scoped_ptr<aura::WindowTreeHost> host_; |
| 284 | 323 |
| 285 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; | 324 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; |
| 286 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; | 325 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; |
| 287 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 326 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 288 scoped_ptr<wm::CursorManager> cursor_manager_; | 327 scoped_ptr<wm::CursorManager> cursor_manager_; |
| 289 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; | 328 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; |
| 290 scoped_ptr<ui::DisplayConfigurator> display_configurator_; | 329 scoped_ptr<ui::DisplayConfigurator> display_configurator_; |
| 291 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; | 330 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; |
| 292 | 331 |
| 332 std::vector<base::Closure> terminating_callbacks_; |
| 333 |
| 293 DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl); | 334 DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl); |
| 294 }; | 335 }; |
| 295 | 336 |
| 296 } // namespace | 337 } // namespace |
| 297 | 338 |
| 298 // static | 339 // static |
| 299 void AthenaEnv::Create() { | 340 void AthenaEnv::Create() { |
| 300 DCHECK(!instance); | 341 DCHECK(!instance); |
| 301 new AthenaEnvImpl(); | 342 new AthenaEnvImpl(); |
| 302 } | 343 } |
| 303 | 344 |
| 304 AthenaEnv* AthenaEnv::Get() { | 345 AthenaEnv* AthenaEnv::Get() { |
| 305 DCHECK(instance); | 346 DCHECK(instance); |
| 306 return instance; | 347 return instance; |
| 307 } | 348 } |
| 308 | 349 |
| 309 // static | 350 // static |
| 310 | 351 |
| 311 // static | 352 // static |
| 312 void AthenaEnv::Shutdown() { | 353 void AthenaEnv::Shutdown() { |
| 313 DCHECK(instance); | 354 DCHECK(instance); |
| 314 delete instance; | 355 delete instance; |
| 315 } | 356 } |
| 316 | 357 |
| 317 } // namespace athena | 358 } // namespace athena |
| OLD | NEW |