| 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" | 10 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 screen_ = base::MakeUnique<ScreenMus>(this); | 107 screen_ = base::MakeUnique<ScreenMus>(this); |
| 108 screen_->Init(connector); | 108 screen_->Init(connector); |
| 109 | 109 |
| 110 std::unique_ptr<ClipboardMus> clipboard = base::MakeUnique<ClipboardMus>(); | 110 std::unique_ptr<ClipboardMus> clipboard = base::MakeUnique<ClipboardMus>(); |
| 111 clipboard->Init(connector); | 111 clipboard->Init(connector); |
| 112 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); | 112 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); |
| 113 | 113 |
| 114 ViewsDelegate::GetInstance()->set_native_widget_factory( | 114 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 115 base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this))); | 115 base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this))); |
| 116 ViewsDelegate::GetInstance()->set_desktop_window_tree_host_factory(base::Bind( |
| 117 &MusClient::CreateDesktopWindowTreeHost, base::Unretained(this))); |
| 116 } | 118 } |
| 117 | 119 |
| 118 MusClient::~MusClient() { | 120 MusClient::~MusClient() { |
| 119 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while | 121 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while |
| 120 // we are still valid. | 122 // we are still valid. |
| 121 window_tree_client_.reset(); | 123 window_tree_client_.reset(); |
| 122 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); | 124 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); |
| 123 ui::Clipboard::DestroyClipboardForCurrentThread(); | 125 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 124 | 126 |
| 125 if (ViewsDelegate::GetInstance()) { | 127 if (ViewsDelegate::GetInstance()) { |
| 126 ViewsDelegate::GetInstance()->set_native_widget_factory( | 128 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 127 ViewsDelegate::NativeWidgetFactory()); | 129 ViewsDelegate::NativeWidgetFactory()); |
| 130 ViewsDelegate::GetInstance()->set_desktop_window_tree_host_factory( |
| 131 ViewsDelegate::DesktopWindowTreeHostFactory()); |
| 128 } | 132 } |
| 129 | 133 |
| 130 base::DiscardableMemoryAllocator::SetInstance(nullptr); | 134 base::DiscardableMemoryAllocator::SetInstance(nullptr); |
| 131 DCHECK_EQ(instance_, this); | 135 DCHECK_EQ(instance_, this); |
| 132 instance_ = nullptr; | 136 instance_ = nullptr; |
| 133 DCHECK(aura::Env::GetInstance()); | 137 DCHECK(aura::Env::GetInstance()); |
| 134 } | 138 } |
| 135 | 139 |
| 136 // static | 140 // static |
| 137 bool MusClient::ShouldCreateDesktopNativeWidgetAura( | 141 bool MusClient::ShouldCreateDesktopNativeWidgetAura( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // A null return value results in creating NativeWidgetAura. | 215 // A null return value results in creating NativeWidgetAura. |
| 212 return nullptr; | 216 return nullptr; |
| 213 } | 217 } |
| 214 | 218 |
| 215 DesktopNativeWidgetAura* native_widget = | 219 DesktopNativeWidgetAura* native_widget = |
| 216 new DesktopNativeWidgetAura(delegate); | 220 new DesktopNativeWidgetAura(delegate); |
| 217 if (init_params.desktop_window_tree_host) { | 221 if (init_params.desktop_window_tree_host) { |
| 218 native_widget->SetDesktopWindowTreeHost( | 222 native_widget->SetDesktopWindowTreeHost( |
| 219 base::WrapUnique(init_params.desktop_window_tree_host)); | 223 base::WrapUnique(init_params.desktop_window_tree_host)); |
| 220 } else { | 224 } else { |
| 221 std::map<std::string, std::vector<uint8_t>> mus_properties = | |
| 222 ConfigurePropertiesFromParams(init_params); | |
| 223 native_widget->SetDesktopWindowTreeHost( | 225 native_widget->SetDesktopWindowTreeHost( |
| 224 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget, | 226 CreateDesktopWindowTreeHost(init_params, delegate, native_widget)); |
| 225 &mus_properties)); | |
| 226 } | 227 } |
| 227 return native_widget; | 228 return native_widget; |
| 228 } | 229 } |
| 229 | 230 |
| 230 void MusClient::OnCaptureClientSet( | 231 void MusClient::OnCaptureClientSet( |
| 231 aura::client::CaptureClient* capture_client) { | 232 aura::client::CaptureClient* capture_client) { |
| 232 pointer_watcher_event_router_->AttachToCaptureClient(capture_client); | 233 pointer_watcher_event_router_->AttachToCaptureClient(capture_client); |
| 233 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( | 234 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( |
| 234 capture_client); | 235 capture_client); |
| 235 } | 236 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 246 } | 247 } |
| 247 | 248 |
| 248 void MusClient::RemoveObserver(MusClientObserver* observer) { | 249 void MusClient::RemoveObserver(MusClientObserver* observer) { |
| 249 observer_list_.RemoveObserver(observer); | 250 observer_list_.RemoveObserver(observer); |
| 250 } | 251 } |
| 251 void MusClient::SetMusPropertyMirror( | 252 void MusClient::SetMusPropertyMirror( |
| 252 std::unique_ptr<MusPropertyMirror> mirror) { | 253 std::unique_ptr<MusPropertyMirror> mirror) { |
| 253 mus_property_mirror_ = std::move(mirror); | 254 mus_property_mirror_ = std::move(mirror); |
| 254 } | 255 } |
| 255 | 256 |
| 257 std::unique_ptr<DesktopWindowTreeHost> MusClient::CreateDesktopWindowTreeHost( |
| 258 const Widget::InitParams& init_params, |
| 259 internal::NativeWidgetDelegate* delegate, |
| 260 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 261 std::map<std::string, std::vector<uint8_t>> mus_properties = |
| 262 ConfigurePropertiesFromParams(init_params); |
| 263 return base::MakeUnique<DesktopWindowTreeHostMus>( |
| 264 delegate, desktop_native_widget_aura, &mus_properties); |
| 265 } |
| 266 |
| 256 void MusClient::OnEmbed( | 267 void MusClient::OnEmbed( |
| 257 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 268 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 258 NOTREACHED(); | 269 NOTREACHED(); |
| 259 } | 270 } |
| 260 | 271 |
| 261 void MusClient::OnLostConnection(aura::WindowTreeClient* client) {} | 272 void MusClient::OnLostConnection(aura::WindowTreeClient* client) {} |
| 262 | 273 |
| 263 void MusClient::OnEmbedRootDestroyed( | 274 void MusClient::OnEmbedRootDestroyed( |
| 264 aura::WindowTreeHostMus* window_tree_host) { | 275 aura::WindowTreeHostMus* window_tree_host) { |
| 265 static_cast<DesktopWindowTreeHostMus*>(window_tree_host) | 276 static_cast<DesktopWindowTreeHostMus*>(window_tree_host) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 288 // TODO: this likely gets z-order wrong. http://crbug.com/663606. | 299 // TODO: this likely gets z-order wrong. http://crbug.com/663606. |
| 289 gfx::Point relative_point(point); | 300 gfx::Point relative_point(point); |
| 290 window_tree_host->ConvertScreenInPixelsToDIP(&relative_point); | 301 window_tree_host->ConvertScreenInPixelsToDIP(&relative_point); |
| 291 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) | 302 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) |
| 292 return root->GetTopWindowContainingPoint(relative_point); | 303 return root->GetTopWindowContainingPoint(relative_point); |
| 293 } | 304 } |
| 294 return nullptr; | 305 return nullptr; |
| 295 } | 306 } |
| 296 | 307 |
| 297 } // namespace views | 308 } // namespace views |
| OLD | NEW |