Chromium Code Reviews| 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" |
| 11 #include "services/ui/public/cpp/gpu/gpu_service.h" | 11 #include "services/ui/public/cpp/gpu/gpu_service.h" |
| 12 #include "services/ui/public/cpp/property_type_converters.h" | |
| 12 #include "services/ui/public/interfaces/event_matcher.mojom.h" | 13 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
| 14 #include "services/ui/public/interfaces/window_manager.mojom.h" | |
| 13 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 14 #include "ui/aura/mus/mus_context_factory.h" | 16 #include "ui/aura/mus/mus_context_factory.h" |
| 15 #include "ui/aura/mus/os_exchange_data_provider_mus.h" | 17 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
| 16 #include "ui/aura/mus/property_converter.h" | 18 #include "ui/aura/mus/property_converter.h" |
| 17 #include "ui/aura/mus/window_tree_client.h" | 19 #include "ui/aura/mus/window_tree_client.h" |
| 18 #include "ui/aura/mus/window_tree_host_mus.h" | 20 #include "ui/aura/mus/window_tree_host_mus.h" |
| 19 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_tree_host.h" | 22 #include "ui/aura/window_tree_host.h" |
| 21 #include "ui/views/mus/aura_init.h" | 23 #include "ui/views/mus/aura_init.h" |
| 22 #include "ui/views/mus/clipboard_mus.h" | 24 #include "ui/views/mus/clipboard_mus.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 50 } | 52 } |
| 51 | 53 |
| 52 // static | 54 // static |
| 53 bool MusClient::ShouldCreateDesktopNativeWidgetAura( | 55 bool MusClient::ShouldCreateDesktopNativeWidgetAura( |
| 54 const Widget::InitParams& init_params) { | 56 const Widget::InitParams& init_params) { |
| 55 // TYPE_CONTROL and child widgets require a NativeWidgetAura. | 57 // TYPE_CONTROL and child widgets require a NativeWidgetAura. |
| 56 return init_params.type != Widget::InitParams::TYPE_CONTROL && | 58 return init_params.type != Widget::InitParams::TYPE_CONTROL && |
| 57 !init_params.child; | 59 !init_params.child; |
| 58 } | 60 } |
| 59 | 61 |
| 62 // static | |
| 63 std::map<std::string, std::vector<uint8_t>> | |
| 64 MusClient::ConfigurePropertiesFromParams( | |
| 65 const Widget::InitParams& init_params) { | |
| 66 std::map<std::string, std::vector<uint8_t>> mus_properties = | |
| 67 init_params.mus_properties; | |
| 68 mus_properties[ui::mojom::WindowManager::kWindowType_Property] = | |
| 69 mojo::ConvertTo<std::vector<uint8_t>>( | |
| 70 static_cast<int32_t>(init_params.type)); | |
|
msw
2016/11/21 19:26:47
Hmm, this sets kWindowType_Property to a Widget::I
sky
2016/11/21 22:13:56
Done.
| |
| 71 return mus_properties; | |
| 72 } | |
| 73 | |
| 60 NativeWidget* MusClient::CreateNativeWidget( | 74 NativeWidget* MusClient::CreateNativeWidget( |
| 61 const Widget::InitParams& init_params, | 75 const Widget::InitParams& init_params, |
| 62 internal::NativeWidgetDelegate* delegate) { | 76 internal::NativeWidgetDelegate* delegate) { |
| 63 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { | 77 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { |
| 64 // A null return value results in creating NativeWidgetAura. | 78 // A null return value results in creating NativeWidgetAura. |
| 65 return nullptr; | 79 return nullptr; |
| 66 } | 80 } |
| 67 | 81 |
| 68 DesktopNativeWidgetAura* native_widget = | 82 DesktopNativeWidgetAura* native_widget = |
| 69 new DesktopNativeWidgetAura(delegate); | 83 new DesktopNativeWidgetAura(delegate); |
| 70 if (init_params.desktop_window_tree_host) { | 84 if (init_params.desktop_window_tree_host) { |
| 71 native_widget->SetDesktopWindowTreeHost( | 85 native_widget->SetDesktopWindowTreeHost( |
| 72 base::WrapUnique(init_params.desktop_window_tree_host)); | 86 base::WrapUnique(init_params.desktop_window_tree_host)); |
| 73 } else { | 87 } else { |
| 88 std::map<std::string, std::vector<uint8_t>> mus_properties = | |
|
msw
2016/11/21 19:26:47
Should this use the helper above?
sky
2016/11/21 22:13:56
Done.
| |
| 89 init_params.mus_properties; | |
| 90 mus_properties[ui::mojom::WindowManager::kWindowType_Property] = | |
| 91 mojo::ConvertTo<std::vector<uint8_t>>( | |
| 92 static_cast<int32_t>(init_params.type)); | |
| 74 native_widget->SetDesktopWindowTreeHost( | 93 native_widget->SetDesktopWindowTreeHost( |
| 75 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget, | 94 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget, |
| 76 init_params)); | 95 &mus_properties)); |
| 77 } | 96 } |
| 78 return native_widget; | 97 return native_widget; |
| 79 } | 98 } |
| 80 | 99 |
| 81 MusClient::MusClient(service_manager::Connector* connector, | 100 MusClient::MusClient(service_manager::Connector* connector, |
| 82 const service_manager::Identity& identity, | 101 const service_manager::Identity& identity, |
| 83 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) | 102 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) |
| 84 : connector_(connector), identity_(identity) { | 103 : connector_(connector), identity_(identity) { |
| 85 DCHECK(!instance_); | 104 DCHECK(!instance_); |
| 86 instance_ = this; | 105 instance_ = this; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 return root->GetTopWindowContainingPoint(relative_point); | 181 return root->GetTopWindowContainingPoint(relative_point); |
| 163 } | 182 } |
| 164 return nullptr; | 183 return nullptr; |
| 165 } | 184 } |
| 166 | 185 |
| 167 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { | 186 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { |
| 168 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 187 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 169 } | 188 } |
| 170 | 189 |
| 171 } // namespace views | 190 } // namespace views |
| OLD | NEW |