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/common/fill_layout_manager.h" | 9 #include "athena/common/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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 | 242 |
241 ScreenForShutdown::Create(screen_.get()); | 243 ScreenForShutdown::Create(screen_.get()); |
242 screen_.reset(); | 244 screen_.reset(); |
243 aura::Env::DeleteInstance(); | 245 aura::Env::DeleteInstance(); |
244 | 246 |
245 display_configurator_->RemoveObserver(this); | 247 display_configurator_->RemoveObserver(this); |
246 display_configurator_.reset(); | 248 display_configurator_.reset(); |
247 } | 249 } |
248 | 250 |
249 private: | 251 private: |
252 struct Finder { | |
253 explicit Finder(const base::Closure& c) : closure(c) {} | |
254 bool operator()(const base::Closure& other) { | |
255 return closure.Equals(other); | |
256 } | |
257 base::Closure closure; | |
258 }; | |
259 | |
260 // AthenaEnv: | |
250 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } | 261 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } |
251 | 262 |
252 // AthenaEnv: | |
253 virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) OVERRIDE { | 263 virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) OVERRIDE { |
254 screen_->SetWorkAreaInsets(insets); | 264 screen_->SetWorkAreaInsets(insets); |
255 } | 265 } |
256 | 266 |
267 virtual void AddTerminatingCallback(const base::Closure& closure) OVERRIDE { | |
Jun Mukai
2014/09/10 00:07:10
Rather than bundling terminating callbacks here, i
oshima
2014/09/10 00:47:49
I'd like to use callback for a couple of reasons.
Jun Mukai
2014/09/10 00:51:48
Okay, in that case.
I imagine that this type of t
| |
268 if (closure.is_null()) | |
269 return; | |
270 DCHECK(terminating_callbacks_.end() == | |
271 std::find_if(terminating_callbacks_.begin(), | |
272 terminating_callbacks_.end(), | |
273 Finder(closure))); | |
274 terminating_callbacks_.push_back(closure); | |
275 } | |
276 | |
277 virtual void RemoveTerminatingCallback( | |
278 const base::Closure& closure) OVERRIDE { | |
279 std::vector<base::Closure>::iterator iter = | |
280 std::find_if(terminating_callbacks_.begin(), | |
281 terminating_callbacks_.end(), | |
282 Finder(closure)); | |
283 if (iter != terminating_callbacks_.end()) | |
284 terminating_callbacks_.erase(iter); | |
285 } | |
286 | |
287 virtual void OnTerminating() OVERRIDE { | |
288 for (std::vector<base::Closure>::iterator iter = | |
289 terminating_callbacks_.begin(); | |
290 iter != terminating_callbacks_.end(); | |
291 ++iter) { | |
292 (*iter).Run(); | |
Jun Mukai
2014/09/10 00:24:30
iter->Run();
oshima
2014/09/10 00:47:50
Done.
| |
293 } | |
294 } | |
295 | |
257 // ui::DisplayConfigurator::Observer: | 296 // ui::DisplayConfigurator::Observer: |
258 virtual void OnDisplayModeChanged(const std::vector< | 297 virtual void OnDisplayModeChanged(const std::vector< |
259 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE { | 298 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE { |
260 gfx::Size size = GetPrimaryDisplaySize(); | 299 gfx::Size size = GetPrimaryDisplaySize(); |
261 if (!size.IsEmpty()) | 300 if (!size.IsEmpty()) |
262 host_->UpdateRootWindowSize(size); | 301 host_->UpdateRootWindowSize(size); |
263 } | 302 } |
264 | 303 |
265 // aura::WindowTreeHostObserver: | 304 // aura::WindowTreeHostObserver: |
266 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE { | 305 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 | 347 |
309 // static | 348 // static |
310 | 349 |
311 // static | 350 // static |
312 void AthenaEnv::Shutdown() { | 351 void AthenaEnv::Shutdown() { |
313 DCHECK(instance); | 352 DCHECK(instance); |
314 delete instance; | 353 delete instance; |
315 } | 354 } |
316 | 355 |
317 } // namespace athena | 356 } // namespace athena |
OLD | NEW |