OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ash/display/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 CHECK_NE(display::Display::kInvalidDisplayID, primary_display_id); | 325 CHECK_NE(display::Display::kInvalidDisplayID, primary_display_id); |
326 return primary_display_id; | 326 return primary_display_id; |
327 } | 327 } |
328 | 328 |
329 aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { | 329 aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { |
330 return GetRootWindowForDisplayId(primary_display_id); | 330 return GetRootWindowForDisplayId(primary_display_id); |
331 } | 331 } |
332 | 332 |
333 aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64_t id) { | 333 aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64_t id) { |
334 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); | 334 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); |
335 CHECK(host); | 335 return host ? GetWindow(host) : nullptr; |
336 return GetWindow(host); | |
337 } | 336 } |
338 | 337 |
339 AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( | 338 AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( |
340 int64_t display_id) { | 339 int64_t display_id) { |
341 CHECK_EQ(1u, window_tree_hosts_.count(display_id)) << "display id = " | 340 if (window_tree_hosts_.count(display_id) == 0) |
sky
2016/10/11 02:40:37
use find and a conditional to avoid the double loo
msw
2016/10/11 15:38:00
Done.
| |
342 << display_id; | 341 return nullptr; |
343 return window_tree_hosts_[display_id]; | 342 return window_tree_hosts_[display_id]; |
344 } | 343 } |
345 | 344 |
346 void WindowTreeHostManager::CloseChildWindows() { | 345 void WindowTreeHostManager::CloseChildWindows() { |
347 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); | 346 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); |
348 it != window_tree_hosts_.end(); ++it) { | 347 it != window_tree_hosts_.end(); ++it) { |
349 aura::Window* root_window = GetWindow(it->second); | 348 aura::Window* root_window = GetWindow(it->second); |
350 RootWindowController* controller = GetRootWindowController(root_window); | 349 RootWindowController* controller = GetRootWindowController(root_window); |
351 if (controller) { | 350 if (controller) { |
352 controller->CloseChildWindows(); | 351 controller->CloseChildWindows(); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 SetDisplayPropertiesOnHost(ash_host, display); | 861 SetDisplayPropertiesOnHost(ash_host, display); |
863 | 862 |
864 #if defined(OS_CHROMEOS) | 863 #if defined(OS_CHROMEOS) |
865 if (switches::ConstrainPointerToRoot()) | 864 if (switches::ConstrainPointerToRoot()) |
866 ash_host->ConfineCursorToRootWindow(); | 865 ash_host->ConfineCursorToRootWindow(); |
867 #endif | 866 #endif |
868 return ash_host; | 867 return ash_host; |
869 } | 868 } |
870 | 869 |
871 } // namespace ash | 870 } // namespace ash |
OLD | NEW |