| 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 "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" | |
| 11 #include "services/service_manager/public/cpp/connection.h" | 10 #include "services/service_manager/public/cpp/connection.h" |
| 12 #include "services/service_manager/public/cpp/connector.h" | 11 #include "services/service_manager/public/cpp/connector.h" |
| 13 #include "services/ui/public/cpp/gpu/gpu.h" | 12 #include "services/ui/public/cpp/gpu/gpu.h" |
| 14 #include "services/ui/public/cpp/property_type_converters.h" | 13 #include "services/ui/public/cpp/property_type_converters.h" |
| 15 #include "services/ui/public/interfaces/constants.mojom.h" | 14 #include "services/ui/public/interfaces/constants.mojom.h" |
| 16 #include "services/ui/public/interfaces/event_matcher.mojom.h" | 15 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
| 17 #include "services/ui/public/interfaces/window_manager.mojom.h" | 16 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 18 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
| 19 #include "ui/aura/mus/capture_synchronizer.h" | 18 #include "ui/aura/mus/capture_synchronizer.h" |
| 20 #include "ui/aura/mus/mus_context_factory.h" | 19 #include "ui/aura/mus/mus_context_factory.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // TODO(msw): Avoid this... use some default value? Allow clients to extend? | 78 // TODO(msw): Avoid this... use some default value? Allow clients to extend? |
| 80 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); | 79 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); |
| 81 property_converter_->RegisterProperty( | 80 property_converter_->RegisterProperty( |
| 82 wm::kShadowElevationKey, | 81 wm::kShadowElevationKey, |
| 83 ui::mojom::WindowManager::kShadowElevation_Property, | 82 ui::mojom::WindowManager::kShadowElevation_Property, |
| 84 base::Bind(&wm::IsValidShadowElevation)); | 83 base::Bind(&wm::IsValidShadowElevation)); |
| 85 | 84 |
| 86 if (create_wm_state) | 85 if (create_wm_state) |
| 87 wm_state_ = base::MakeUnique<wm::WMState>(); | 86 wm_state_ = base::MakeUnique<wm::WMState>(); |
| 88 | 87 |
| 89 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; | |
| 90 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); | |
| 91 | |
| 92 discardable_shared_memory_manager_ = base::MakeUnique< | |
| 93 discardable_memory::ClientDiscardableSharedMemoryManager>( | |
| 94 std::move(manager_ptr), io_task_runner); | |
| 95 base::DiscardableMemoryAllocator::SetInstance( | |
| 96 discardable_shared_memory_manager_.get()); | |
| 97 | |
| 98 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( | 88 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( |
| 99 connector, this, nullptr /* window_manager_delegate */, | 89 connector, this, nullptr /* window_manager_delegate */, |
| 100 nullptr /* window_tree_client_request */, std::move(io_task_runner)); | 90 nullptr /* window_tree_client_request */, std::move(io_task_runner)); |
| 101 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); | 91 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); |
| 102 window_tree_client_->ConnectViaWindowTreeFactory(); | 92 window_tree_client_->ConnectViaWindowTreeFactory(); |
| 103 | 93 |
| 104 pointer_watcher_event_router_ = | 94 pointer_watcher_event_router_ = |
| 105 base::MakeUnique<PointerWatcherEventRouter>(window_tree_client_.get()); | 95 base::MakeUnique<PointerWatcherEventRouter>(window_tree_client_.get()); |
| 106 | 96 |
| 107 screen_ = base::MakeUnique<ScreenMus>(this); | 97 screen_ = base::MakeUnique<ScreenMus>(this); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 124 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); | 114 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); |
| 125 ui::Clipboard::DestroyClipboardForCurrentThread(); | 115 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 126 | 116 |
| 127 if (ViewsDelegate::GetInstance()) { | 117 if (ViewsDelegate::GetInstance()) { |
| 128 ViewsDelegate::GetInstance()->set_native_widget_factory( | 118 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 129 ViewsDelegate::NativeWidgetFactory()); | 119 ViewsDelegate::NativeWidgetFactory()); |
| 130 ViewsDelegate::GetInstance()->set_desktop_window_tree_host_factory( | 120 ViewsDelegate::GetInstance()->set_desktop_window_tree_host_factory( |
| 131 ViewsDelegate::DesktopWindowTreeHostFactory()); | 121 ViewsDelegate::DesktopWindowTreeHostFactory()); |
| 132 } | 122 } |
| 133 | 123 |
| 134 base::DiscardableMemoryAllocator::SetInstance(nullptr); | |
| 135 DCHECK_EQ(instance_, this); | 124 DCHECK_EQ(instance_, this); |
| 136 instance_ = nullptr; | 125 instance_ = nullptr; |
| 137 DCHECK(aura::Env::GetInstance()); | 126 DCHECK(aura::Env::GetInstance()); |
| 138 } | 127 } |
| 139 | 128 |
| 140 // static | 129 // static |
| 141 bool MusClient::ShouldCreateDesktopNativeWidgetAura( | 130 bool MusClient::ShouldCreateDesktopNativeWidgetAura( |
| 142 const Widget::InitParams& init_params) { | 131 const Widget::InitParams& init_params) { |
| 143 // TYPE_CONTROL and child widgets require a NativeWidgetAura. | 132 // TYPE_CONTROL and child widgets require a NativeWidgetAura. |
| 144 return init_params.type != Widget::InitParams::TYPE_CONTROL && | 133 return init_params.type != Widget::InitParams::TYPE_CONTROL && |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // TODO: this likely gets z-order wrong. http://crbug.com/663606. | 288 // TODO: this likely gets z-order wrong. http://crbug.com/663606. |
| 300 gfx::Point relative_point(point); | 289 gfx::Point relative_point(point); |
| 301 window_tree_host->ConvertScreenInPixelsToDIP(&relative_point); | 290 window_tree_host->ConvertScreenInPixelsToDIP(&relative_point); |
| 302 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) | 291 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) |
| 303 return root->GetTopWindowContainingPoint(relative_point); | 292 return root->GetTopWindowContainingPoint(relative_point); |
| 304 } | 293 } |
| 305 return nullptr; | 294 return nullptr; |
| 306 } | 295 } |
| 307 | 296 |
| 308 } // namespace views | 297 } // namespace views |
| OLD | NEW |