| 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/mus/mus_client.h" | 5 #include "ui/views/mus/mus_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "services/service_manager/public/cpp/connection.h" | 9 #include "services/service_manager/public/cpp/connection.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 if (ViewsDelegate::GetInstance()) { | 73 if (ViewsDelegate::GetInstance()) { |
| 74 ViewsDelegate::GetInstance()->set_native_widget_factory( | 74 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 75 ViewsDelegate::NativeWidgetFactory()); | 75 ViewsDelegate::NativeWidgetFactory()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 DCHECK_EQ(instance_, this); | 78 DCHECK_EQ(instance_, this); |
| 79 instance_ = nullptr; | 79 instance_ = nullptr; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static |
| 83 bool MusClient::ShouldCreateDesktopNativeWidgetAura( |
| 84 const Widget::InitParams& init_params) { |
| 85 // TYPE_CONTROL and child widgets require a NativeWidgetAura. |
| 86 return init_params.type != Widget::InitParams::TYPE_CONTROL && |
| 87 !init_params.child; |
| 88 } |
| 89 |
| 82 NativeWidget* MusClient::CreateNativeWidget( | 90 NativeWidget* MusClient::CreateNativeWidget( |
| 83 const Widget::InitParams& init_params, | 91 const Widget::InitParams& init_params, |
| 84 internal::NativeWidgetDelegate* delegate) { | 92 internal::NativeWidgetDelegate* delegate) { |
| 85 // TYPE_CONTROL widgets require a NativeWidgetAura. So we let this fall | 93 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { |
| 86 // through, so that the default NativeWidgetPrivate::CreateNativeWidget() is | 94 // A null return value results in creating NativeWidgetAura. |
| 87 // used instead. | |
| 88 if (init_params.type == Widget::InitParams::TYPE_CONTROL) | |
| 89 return nullptr; | 95 return nullptr; |
| 96 } |
| 90 | 97 |
| 91 DesktopNativeWidgetAura* native_widget = | 98 DesktopNativeWidgetAura* native_widget = |
| 92 new DesktopNativeWidgetAura(delegate); | 99 new DesktopNativeWidgetAura(delegate); |
| 93 if (init_params.desktop_window_tree_host) { | 100 if (init_params.desktop_window_tree_host) { |
| 94 native_widget->SetDesktopWindowTreeHost( | 101 native_widget->SetDesktopWindowTreeHost( |
| 95 base::WrapUnique(init_params.desktop_window_tree_host)); | 102 base::WrapUnique(init_params.desktop_window_tree_host)); |
| 96 } else { | 103 } else { |
| 97 native_widget->SetDesktopWindowTreeHost( | 104 native_widget->SetDesktopWindowTreeHost( |
| 98 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget)); | 105 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget)); |
| 99 } | 106 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 return root->GetTopWindowContainingPoint(relative_point); | 189 return root->GetTopWindowContainingPoint(relative_point); |
| 183 } | 190 } |
| 184 return nullptr; | 191 return nullptr; |
| 185 } | 192 } |
| 186 | 193 |
| 187 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { | 194 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { |
| 188 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 195 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 189 } | 196 } |
| 190 | 197 |
| 191 } // namespace views | 198 } // namespace views |
| OLD | NEW |