| 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 "ash/mus/top_level_window_factory.h" | 5 #include "ash/mus/top_level_window_factory.h" |
| 6 | 6 |
| 7 #include "ash/mus/disconnected_app_handler.h" | 7 #include "ash/mus/disconnected_app_handler.h" |
| 8 #include "ash/mus/frame/detached_title_area_renderer.h" | 8 #include "ash/mus/frame/detached_title_area_renderer.h" |
| 9 #include "ash/mus/non_client_frame_controller.h" | 9 #include "ash/mus/non_client_frame_controller.h" |
| 10 #include "ash/mus/property_util.h" | 10 #include "ash/mus/property_util.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 WindowManager* window_manager, | 124 WindowManager* window_manager, |
| 125 RootWindowController* root_window_controller, | 125 RootWindowController* root_window_controller, |
| 126 ui::mojom::WindowType window_type, | 126 ui::mojom::WindowType window_type, |
| 127 std::map<std::string, std::vector<uint8_t>>* properties) { | 127 std::map<std::string, std::vector<uint8_t>>* properties) { |
| 128 // TODO(sky): constrain and validate properties. | 128 // TODO(sky): constrain and validate properties. |
| 129 | 129 |
| 130 int32_t container_id = kShellWindowId_Invalid; | 130 int32_t container_id = kShellWindowId_Invalid; |
| 131 aura::Window* context = nullptr; | 131 aura::Window* context = nullptr; |
| 132 aura::Window* container_window = nullptr; | 132 aura::Window* container_window = nullptr; |
| 133 if (GetInitialContainerId(*properties, &container_id)) { | 133 if (GetInitialContainerId(*properties, &container_id)) { |
| 134 container_window = root_window_controller->GetWindow() | 134 container_window = |
| 135 ->GetChildByShellWindowId(container_id) | 135 root_window_controller->GetRootWindow()->GetChildById(container_id); |
| 136 ->aura_window(); | |
| 137 } else { | 136 } else { |
| 138 context = root_window_controller->GetRootWindow(); | 137 context = root_window_controller->GetRootWindow(); |
| 139 } | 138 } |
| 140 | 139 |
| 141 gfx::Rect bounds = CalculateDefaultBounds( | 140 gfx::Rect bounds = CalculateDefaultBounds( |
| 142 window_manager, root_window_controller, container_window, properties); | 141 window_manager, root_window_controller, container_window, properties); |
| 143 | 142 |
| 144 const bool provide_non_client_frame = | 143 const bool provide_non_client_frame = |
| 145 window_type == ui::mojom::WindowType::WINDOW || | 144 window_type == ui::mojom::WindowType::WINDOW || |
| 146 window_type == ui::mojom::WindowType::PANEL; | 145 window_type == ui::mojom::WindowType::PANEL; |
| 147 if (provide_non_client_frame) { | 146 if (provide_non_client_frame) { |
| 148 // See NonClientFrameController for details on lifetime. | 147 // See NonClientFrameController for details on lifetime. |
| 149 NonClientFrameController* non_client_frame_controller = | 148 NonClientFrameController* non_client_frame_controller = |
| 150 new NonClientFrameController(container_window, context, bounds, | 149 new NonClientFrameController(container_window, context, bounds, |
| 151 window_type, properties, window_manager); | 150 window_type, properties, window_manager); |
| 152 return non_client_frame_controller->window(); | 151 return non_client_frame_controller->window(); |
| 153 } | 152 } |
| 154 | 153 |
| 155 aura::PropertyConverter* property_converter = | 154 aura::PropertyConverter* property_converter = |
| 156 window_manager->property_converter(); | 155 window_manager->property_converter(); |
| 157 | 156 |
| 158 if (window_type == ui::mojom::WindowType::POPUP && | 157 if (window_type == ui::mojom::WindowType::POPUP && |
| 159 ShouldRenderTitleArea(property_converter, *properties)) { | 158 ShouldRenderTitleArea(property_converter, *properties)) { |
| 160 // Pick a parent so display information is obtained. Will pick the real one | 159 // Pick a parent so display information is obtained. Will pick the real one |
| 161 // once transient parent found. | 160 // once transient parent found. |
| 162 aura::Window* unparented_control_container = | 161 aura::Window* unparented_control_container = |
| 163 root_window_controller->GetWindow() | 162 root_window_controller->GetRootWindow()->GetChildById( |
| 164 ->GetChildByShellWindowId(kShellWindowId_UnparentedControlContainer) | 163 kShellWindowId_UnparentedControlContainer); |
| 165 ->aura_window(); | |
| 166 // DetachedTitleAreaRendererForClient is owned by the client. | 164 // DetachedTitleAreaRendererForClient is owned by the client. |
| 167 DetachedTitleAreaRendererForClient* renderer = | 165 DetachedTitleAreaRendererForClient* renderer = |
| 168 new DetachedTitleAreaRendererForClient(unparented_control_container, | 166 new DetachedTitleAreaRendererForClient(unparented_control_container, |
| 169 properties, window_manager); | 167 properties, window_manager); |
| 170 return renderer->widget()->GetNativeView(); | 168 return renderer->widget()->GetNativeView(); |
| 171 } | 169 } |
| 172 | 170 |
| 173 aura::Window* window = new aura::Window(nullptr); | 171 aura::Window* window = new aura::Window(nullptr); |
| 174 aura::SetWindowType(window, window_type); | 172 aura::SetWindowType(window, window_type); |
| 175 window->SetProperty(aura::client::kEmbedType, | 173 window->SetProperty(aura::client::kEmbedType, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (non_client_frame_controller) | 226 if (non_client_frame_controller) |
| 229 non_client_frame_controller->set_can_activate(can_focus); | 227 non_client_frame_controller->set_can_activate(can_focus); |
| 230 // No need to persist this value. | 228 // No need to persist this value. |
| 231 properties->erase(focusable_iter); | 229 properties->erase(focusable_iter); |
| 232 } | 230 } |
| 233 return window; | 231 return window; |
| 234 } | 232 } |
| 235 | 233 |
| 236 } // namespace mus | 234 } // namespace mus |
| 237 } // namespace ash | 235 } // namespace ash |
| OLD | NEW |