| 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" |
| 8 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 7 #include "ui/views/mus/mus_client.h" | 9 #include "ui/views/mus/mus_client.h" |
| 10 #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/native_widget_aura.h" |
| 8 | 13 |
| 9 namespace views { | 14 namespace views { |
| 10 namespace test { | 15 namespace test { |
| 16 namespace { |
| 17 |
| 18 NativeWidget* CreatePlatformNativeWidgetImplAuraMus( |
| 19 bool create_desktop_native_widget_aura, |
| 20 const Widget::InitParams& init_params, |
| 21 Widget* widget, |
| 22 int32_t type, |
| 23 bool* destroyed) { |
| 24 if (!create_desktop_native_widget_aura) { |
| 25 return new TestPlatformNativeWidget<NativeWidgetAura>( |
| 26 widget, type == kStubCapture, destroyed); |
| 27 } |
| 28 DesktopNativeWidgetAura* desktop_native_widget_aura = |
| 29 new TestPlatformNativeWidget<DesktopNativeWidgetAura>( |
| 30 widget, type == kStubCapture, destroyed); |
| 31 desktop_native_widget_aura->SetDesktopWindowTreeHost( |
| 32 base::MakeUnique<DesktopWindowTreeHostMus>(widget, |
| 33 desktop_native_widget_aura)); |
| 34 return desktop_native_widget_aura; |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
| 39 NativeWidget* CreatePlatformNativeWidgetImpl( |
| 40 const Widget::InitParams& init_params, |
| 41 Widget* widget, |
| 42 uint32_t type, |
| 43 bool* destroyed) { |
| 44 // Only create a NativeWidgetAura if necessary, otherwise use |
| 45 // DesktopNativeWidgetAura. |
| 46 return CreatePlatformNativeWidgetImplAuraMus( |
| 47 MusClient::ShouldCreateDesktopNativeWidgetAura(init_params), init_params, |
| 48 widget, type, destroyed); |
| 49 } |
| 11 | 50 |
| 12 NativeWidget* CreatePlatformDesktopNativeWidgetImpl( | 51 NativeWidget* CreatePlatformDesktopNativeWidgetImpl( |
| 13 const Widget::InitParams& init_params, | 52 const Widget::InitParams& init_params, |
| 14 Widget* widget, | 53 Widget* widget, |
| 15 bool* destroyed) { | 54 bool* destroyed) { |
| 16 return MusClient::Get()->CreateNativeWidget(init_params, widget); | 55 return CreatePlatformNativeWidgetImplAuraMus(true, init_params, widget, |
| 56 kDefault, destroyed); |
| 17 } | 57 } |
| 18 | 58 |
| 19 } // namespace test | 59 } // namespace test |
| 20 } // namespace views | 60 } // namespace views |
| OLD | NEW |