| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/test/native_widget_factory.h" | 5 #include "ui/views/test/native_widget_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/mus/window_tree_host_mus_init_params.h" |
| 8 #include "ui/views/mus/desktop_window_tree_host_mus.h" | 9 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 9 #include "ui/views/mus/mus_client.h" | 10 #include "ui/views/mus/mus_client.h" |
| 10 #include "ui/views/test/test_platform_native_widget.h" | 11 #include "ui/views/test/test_platform_native_widget.h" |
| 11 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 12 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 12 #include "ui/views/widget/native_widget_aura.h" | 13 #include "ui/views/widget/native_widget_aura.h" |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 namespace test { | 16 namespace test { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 NativeWidget* CreatePlatformNativeWidgetImplAuraMus( | 19 NativeWidget* CreatePlatformNativeWidgetImplAuraMus( |
| 19 bool create_desktop_native_widget_aura, | 20 bool create_desktop_native_widget_aura, |
| 20 const Widget::InitParams& init_params, | 21 const Widget::InitParams& init_params, |
| 21 Widget* widget, | 22 Widget* widget, |
| 22 int32_t type, | 23 int32_t type, |
| 23 bool* destroyed) { | 24 bool* destroyed) { |
| 24 if (!create_desktop_native_widget_aura) { | 25 if (!create_desktop_native_widget_aura) { |
| 25 return new TestPlatformNativeWidget<NativeWidgetAura>( | 26 return new TestPlatformNativeWidget<NativeWidgetAura>( |
| 26 widget, type == kStubCapture, destroyed); | 27 widget, type == kStubCapture, destroyed); |
| 27 } | 28 } |
| 28 DesktopNativeWidgetAura* desktop_native_widget_aura = | 29 DesktopNativeWidgetAura* desktop_native_widget_aura = |
| 29 new TestPlatformNativeWidget<DesktopNativeWidgetAura>( | 30 new TestPlatformNativeWidget<DesktopNativeWidgetAura>( |
| 30 widget, type == kStubCapture, destroyed); | 31 widget, type == kStubCapture, destroyed); |
| 31 std::map<std::string, std::vector<uint8_t>> mus_properties = | 32 std::map<std::string, std::vector<uint8_t>> mus_properties = |
| 32 MusClient::Get()->ConfigurePropertiesFromParams(init_params); | 33 MusClient::Get()->ConfigurePropertiesFromParams(init_params); |
| 34 std::unique_ptr<aura::WindowTreeHostMusInitParams> |
| 35 window_tree_host_init_params = aura::CreateInitParamsForTopLevel( |
| 36 MusClient::Get()->window_tree_client(), std::move(mus_properties)); |
| 33 desktop_native_widget_aura->SetDesktopWindowTreeHost( | 37 desktop_native_widget_aura->SetDesktopWindowTreeHost( |
| 34 base::MakeUnique<DesktopWindowTreeHostMus>( | 38 base::MakeUnique<DesktopWindowTreeHostMus>( |
| 35 widget, desktop_native_widget_aura, cc::FrameSinkId(), | 39 std::move(window_tree_host_init_params), widget, |
| 36 &mus_properties)); | 40 desktop_native_widget_aura)); |
| 37 return desktop_native_widget_aura; | 41 return desktop_native_widget_aura; |
| 38 } | 42 } |
| 39 | 43 |
| 40 } // namespace | 44 } // namespace |
| 41 | 45 |
| 42 NativeWidget* CreatePlatformNativeWidgetImpl( | 46 NativeWidget* CreatePlatformNativeWidgetImpl( |
| 43 const Widget::InitParams& init_params, | 47 const Widget::InitParams& init_params, |
| 44 Widget* widget, | 48 Widget* widget, |
| 45 uint32_t type, | 49 uint32_t type, |
| 46 bool* destroyed) { | 50 bool* destroyed) { |
| 47 // Only create a NativeWidgetAura if necessary, otherwise use | 51 // Only create a NativeWidgetAura if necessary, otherwise use |
| 48 // DesktopNativeWidgetAura. | 52 // DesktopNativeWidgetAura. |
| 49 return CreatePlatformNativeWidgetImplAuraMus( | 53 return CreatePlatformNativeWidgetImplAuraMus( |
| 50 MusClient::ShouldCreateDesktopNativeWidgetAura(init_params), init_params, | 54 MusClient::ShouldCreateDesktopNativeWidgetAura(init_params), init_params, |
| 51 widget, type, destroyed); | 55 widget, type, destroyed); |
| 52 } | 56 } |
| 53 | 57 |
| 54 NativeWidget* CreatePlatformDesktopNativeWidgetImpl( | 58 NativeWidget* CreatePlatformDesktopNativeWidgetImpl( |
| 55 const Widget::InitParams& init_params, | 59 const Widget::InitParams& init_params, |
| 56 Widget* widget, | 60 Widget* widget, |
| 57 bool* destroyed) { | 61 bool* destroyed) { |
| 58 return CreatePlatformNativeWidgetImplAuraMus(true, init_params, widget, | 62 return CreatePlatformNativeWidgetImplAuraMus(true, init_params, widget, |
| 59 kDefault, destroyed); | 63 kDefault, destroyed); |
| 60 } | 64 } |
| 61 | 65 |
| 62 } // namespace test | 66 } // namespace test |
| 63 } // namespace views | 67 } // namespace views |
| OLD | NEW |