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 "services/service_manager/public/cpp/connection.h" | 10 #include "services/service_manager/public/cpp/connection.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Widget::InitParams::Type. | 54 // Widget::InitParams::Type. |
55 | 55 |
56 namespace views { | 56 namespace views { |
57 | 57 |
58 // static | 58 // static |
59 MusClient* MusClient::instance_ = nullptr; | 59 MusClient* MusClient::instance_ = nullptr; |
60 | 60 |
61 MusClient::MusClient(service_manager::Connector* connector, | 61 MusClient::MusClient(service_manager::Connector* connector, |
62 const service_manager::Identity& identity, | 62 const service_manager::Identity& identity, |
63 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 63 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
64 bool create_wm_state) | 64 bool create_wm_state, |
| 65 MusClientTestingState testing_state) |
65 : identity_(identity) { | 66 : identity_(identity) { |
66 DCHECK(!instance_); | 67 DCHECK(!instance_); |
67 DCHECK(aura::Env::GetInstance()); | 68 DCHECK(aura::Env::GetInstance()); |
68 instance_ = this; | 69 instance_ = this; |
69 | 70 |
70 if (!io_task_runner) { | 71 if (!io_task_runner) { |
71 io_thread_ = base::MakeUnique<base::Thread>("IOThread"); | 72 io_thread_ = base::MakeUnique<base::Thread>("IOThread"); |
72 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); | 73 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
73 thread_options.priority = base::ThreadPriority::NORMAL; | 74 thread_options.priority = base::ThreadPriority::NORMAL; |
74 CHECK(io_thread_->StartWithOptions(thread_options)); | 75 CHECK(io_thread_->StartWithOptions(thread_options)); |
75 io_task_runner = io_thread_->task_runner(); | 76 io_task_runner = io_thread_->task_runner(); |
76 } | 77 } |
77 | 78 |
78 // TODO(msw): Avoid this... use some default value? Allow clients to extend? | 79 // TODO(msw): Avoid this... use some default value? Allow clients to extend? |
79 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); | 80 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); |
80 property_converter_->RegisterProperty( | 81 property_converter_->RegisterProperty( |
81 wm::kShadowElevationKey, | 82 wm::kShadowElevationKey, |
82 ui::mojom::WindowManager::kShadowElevation_Property, | 83 ui::mojom::WindowManager::kShadowElevation_Property, |
83 base::Bind(&wm::IsValidShadowElevation)); | 84 base::Bind(&wm::IsValidShadowElevation)); |
84 | 85 |
85 if (create_wm_state) | 86 if (create_wm_state) |
86 wm_state_ = base::MakeUnique<wm::WMState>(); | 87 wm_state_ = base::MakeUnique<wm::WMState>(); |
87 | 88 |
| 89 if (testing_state == MusClientTestingState::CREATE_TESTING_STATE) { |
| 90 connector->BindInterface(ui::mojom::kServiceName, &server_test_ptr_); |
| 91 server_test_ptr_.EnableNestedDispatch(true); |
| 92 } |
| 93 |
88 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( | 94 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( |
89 connector, this, nullptr /* window_manager_delegate */, | 95 connector, this, nullptr /* window_manager_delegate */, |
90 nullptr /* window_tree_client_request */, std::move(io_task_runner)); | 96 nullptr /* window_tree_client_request */, std::move(io_task_runner)); |
91 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); | 97 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); |
92 window_tree_client_->ConnectViaWindowTreeFactory(); | 98 window_tree_client_->ConnectViaWindowTreeFactory(); |
93 | 99 |
94 pointer_watcher_event_router_ = | 100 pointer_watcher_event_router_ = |
95 base::MakeUnique<PointerWatcherEventRouter>(window_tree_client_.get()); | 101 base::MakeUnique<PointerWatcherEventRouter>(window_tree_client_.get()); |
96 | 102 |
97 screen_ = base::MakeUnique<ScreenMus>(this); | 103 screen_ = base::MakeUnique<ScreenMus>(this); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 242 } |
237 | 243 |
238 void MusClient::RemoveObserver(MusClientObserver* observer) { | 244 void MusClient::RemoveObserver(MusClientObserver* observer) { |
239 observer_list_.RemoveObserver(observer); | 245 observer_list_.RemoveObserver(observer); |
240 } | 246 } |
241 void MusClient::SetMusPropertyMirror( | 247 void MusClient::SetMusPropertyMirror( |
242 std::unique_ptr<MusPropertyMirror> mirror) { | 248 std::unique_ptr<MusPropertyMirror> mirror) { |
243 mus_property_mirror_ = std::move(mirror); | 249 mus_property_mirror_ = std::move(mirror); |
244 } | 250 } |
245 | 251 |
| 252 ui::mojom::WindowServerTest* MusClient::GetTestingInterface() const { |
| 253 // This will only be set in tests. CHECK to ensure it doesn't get used |
| 254 // elsewhere. |
| 255 CHECK(server_test_ptr_); |
| 256 return server_test_ptr_.get(); |
| 257 } |
| 258 |
246 std::unique_ptr<DesktopWindowTreeHost> MusClient::CreateDesktopWindowTreeHost( | 259 std::unique_ptr<DesktopWindowTreeHost> MusClient::CreateDesktopWindowTreeHost( |
247 const Widget::InitParams& init_params, | 260 const Widget::InitParams& init_params, |
248 internal::NativeWidgetDelegate* delegate, | 261 internal::NativeWidgetDelegate* delegate, |
249 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 262 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
250 std::map<std::string, std::vector<uint8_t>> mus_properties = | 263 std::map<std::string, std::vector<uint8_t>> mus_properties = |
251 ConfigurePropertiesFromParams(init_params); | 264 ConfigurePropertiesFromParams(init_params); |
252 return base::MakeUnique<DesktopWindowTreeHostMus>( | 265 return base::MakeUnique<DesktopWindowTreeHostMus>( |
253 delegate, desktop_native_widget_aura, &mus_properties); | 266 delegate, desktop_native_widget_aura, &mus_properties); |
254 } | 267 } |
255 | 268 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // TODO: this likely gets z-order wrong. http://crbug.com/663606. | 301 // TODO: this likely gets z-order wrong. http://crbug.com/663606. |
289 gfx::Point relative_point(point); | 302 gfx::Point relative_point(point); |
290 window_tree_host->ConvertScreenInPixelsToDIP(&relative_point); | 303 window_tree_host->ConvertScreenInPixelsToDIP(&relative_point); |
291 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) | 304 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) |
292 return root->GetTopWindowContainingPoint(relative_point); | 305 return root->GetTopWindowContainingPoint(relative_point); |
293 } | 306 } |
294 return nullptr; | 307 return nullptr; |
295 } | 308 } |
296 | 309 |
297 } // namespace views | 310 } // namespace views |
OLD | NEW |