| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/mus/native_widget_factory_mus.h" |
| 6 |
| 7 #include "ash/common/wm_shell.h" |
| 8 #include "ash/mus/bridge/wm_window_mus.h" |
| 9 #include "ash/mus/window_manager.h" |
| 10 #include "services/ui/public/cpp/property_type_converters.h" |
| 11 #include "ui/views/mus/native_widget_mus.h" |
| 12 #include "ui/views/views_delegate.h" |
| 13 #include "ui/views/widget/widget.h" |
| 14 |
| 15 namespace ash { |
| 16 namespace mus { |
| 17 |
| 18 namespace { |
| 19 |
| 20 views::NativeWidget* CreateNativeWidgetMus( |
| 21 WindowManager* window_manager, |
| 22 const views::Widget::InitParams& init_params, |
| 23 views::internal::NativeWidgetDelegate* delegate) { |
| 24 // TYPE_CONTROL widgets require a NativeWidgetAura. So we let this fall |
| 25 // through, so that the default NativeWidgetPrivate::CreateNativeWidget() is |
| 26 // used instead. |
| 27 if (init_params.type == views::Widget::InitParams::TYPE_CONTROL) |
| 28 return nullptr; |
| 29 std::map<std::string, std::vector<uint8_t>> props; |
| 30 views::NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &props); |
| 31 return new views::NativeWidgetMus(delegate, |
| 32 window_manager->NewTopLevelWindow(&props), |
| 33 ui::mojom::SurfaceType::DEFAULT); |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
| 38 NativeWidgetFactoryMus::NativeWidgetFactoryMus(WindowManager* window_manager) { |
| 39 views::ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 40 base::Bind(&CreateNativeWidgetMus, window_manager)); |
| 41 } |
| 42 |
| 43 NativeWidgetFactoryMus::~NativeWidgetFactoryMus() { |
| 44 if (views::ViewsDelegate::GetInstance()) { |
| 45 views::ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 46 views::ViewsDelegate::NativeWidgetFactory()); |
| 47 } |
| 48 } |
| 49 |
| 50 } // namespace mus |
| 51 } // namespace ash |
| OLD | NEW |