| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/ui/demo/mus_demo_external.h" | 5 #include "services/ui/demo/mus_demo_external.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "services/service_manager/public/cpp/service_context.h" | 9 #include "services/service_manager/public/cpp/service_context.h" |
| 10 #include "services/ui/demo/window_tree_data.h" | 10 #include "services/ui/demo/window_tree_data.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 window_tree_client()->ConnectViaWindowTreeHostFactory(); | 62 window_tree_client()->ConnectViaWindowTreeHostFactory(); |
| 63 | 63 |
| 64 // TODO(tonikitoo,fwang): Implement management of displays in external mode. | 64 // TODO(tonikitoo,fwang): Implement management of displays in external mode. |
| 65 // For now, a fake display is created in order to work around an assertion in | 65 // For now, a fake display is created in order to work around an assertion in |
| 66 // aura::GetDeviceScaleFactorFromDisplay(). | 66 // aura::GetDeviceScaleFactorFromDisplay(). |
| 67 AddPrimaryDisplay(display::Display(0)); | 67 AddPrimaryDisplay(display::Display(0)); |
| 68 | 68 |
| 69 // TODO(tonikitoo,fwang): New windows can be launched without need to wait | 69 for (size_t i = 0; i < number_of_windows_; ++i) |
| 70 // the respective ::OnEmbed call of the previous instance. | 70 OpenNewWindow(i); |
| 71 OpenNewWindow(); | |
| 72 } | 71 } |
| 73 | 72 |
| 74 void MusDemoExternal::OpenNewWindow() { | 73 void MusDemoExternal::OpenNewWindow(size_t window_index) { |
| 75 AppendWindowTreeData(base::MakeUnique<WindowTreeDataExternal>( | 74 AppendWindowTreeData(base::MakeUnique<WindowTreeDataExternal>( |
| 76 window_tree_client(), | 75 window_tree_client(), GetSquareSizeForWindow(window_index))); |
| 77 GetSquareSizeForWindow(initialized_windows_count_))); | |
| 78 } | 76 } |
| 79 | 77 |
| 80 void MusDemoExternal::OnEmbed( | 78 void MusDemoExternal::OnEmbedRootReady( |
| 81 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 79 aura::WindowTreeHostMus* window_tree_host) { |
| 82 DCHECK(!window_tree_host); | 80 DCHECK(window_tree_host); |
| 83 | 81 auto window_tree_data = FindWindowTreeData(window_tree_host); |
| 84 // TODO: Clean up WindowTreeClientDelegate::OnEmbed API so that it passes | 82 (*window_tree_data)->Init(); |
| 85 // no ownership of WindowTreeHostMus instance. | |
| 86 InitWindowTreeData(nullptr); | |
| 87 initialized_windows_count_++; | |
| 88 | |
| 89 // Open the next window until the requested number of windows is reached. | |
| 90 if (initialized_windows_count_ < number_of_windows_) | |
| 91 OpenNewWindow(); | |
| 92 } | 83 } |
| 93 | 84 |
| 94 void MusDemoExternal::OnEmbedRootDestroyed( | 85 void MusDemoExternal::OnEmbedRootDestroyed( |
| 95 aura::WindowTreeHostMus* window_tree_host) { | 86 aura::WindowTreeHostMus* window_tree_host) { |
| 96 RemoveWindowTreeData(window_tree_host); | 87 RemoveWindowTreeData(window_tree_host); |
| 97 } | 88 } |
| 98 | 89 |
| 99 } // namespace demo | 90 } // namespace demo |
| 100 } // namespace ui | 91 } // namespace ui |
| OLD | NEW |