| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/service.h" | 5 #include "services/ui/service.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 std::unique_ptr<mojom::WindowTreeFactoryRequest> wtf_request; | 85 std::unique_ptr<mojom::WindowTreeFactoryRequest> wtf_request; |
| 86 std::unique_ptr<mojom::DisplayManagerRequest> dm_request; | 86 std::unique_ptr<mojom::DisplayManagerRequest> dm_request; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 struct Service::UserState { | 89 struct Service::UserState { |
| 90 std::unique_ptr<clipboard::ClipboardImpl> clipboard; | 90 std::unique_ptr<clipboard::ClipboardImpl> clipboard; |
| 91 std::unique_ptr<ws::AccessibilityManager> accessibility; | 91 std::unique_ptr<ws::AccessibilityManager> accessibility; |
| 92 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 92 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 Service::Service(scoped_refptr<base::SingleThreadTaskRunner> resource_runner, | 95 Service::Service( |
| 96 base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr) | 96 scoped_refptr<base::SingleThreadTaskRunner> resource_runner, |
| 97 base::WeakPtr<ui::ImageCursorsHolder> image_cursors_holder_weak_ptr) |
| 97 : in_process_(resource_runner != nullptr), | 98 : in_process_(resource_runner != nullptr), |
| 98 resource_runner_(resource_runner), | 99 resource_runner_(resource_runner), |
| 99 image_cursors_weak_ptr_(image_cursors_weak_ptr), | 100 image_cursors_holder_weak_ptr_(image_cursors_holder_weak_ptr), |
| 100 test_config_(false), | 101 test_config_(false), |
| 101 ime_registrar_(&ime_driver_) {} | 102 ime_registrar_(&ime_driver_) {} |
| 102 | 103 |
| 103 Service::~Service() { | 104 Service::~Service() { |
| 104 // Destroy |window_server_| first, since it depends on |event_source_|. | 105 // Destroy |window_server_| first, since it depends on |event_source_|. |
| 105 // WindowServer (or more correctly its Displays) may have state that needs to | 106 // WindowServer (or more correctly its Displays) may have state that needs to |
| 106 // be destroyed before GpuState as well. | 107 // be destroyed before GpuState as well. |
| 107 window_server_.reset(); | 108 window_server_.reset(); |
| 108 | 109 |
| 109 #if defined(USE_OZONE) | 110 #if defined(USE_OZONE) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 139 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( | 140 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( |
| 140 loader.TakeFile(kResourceFileStrings), | 141 loader.TakeFile(kResourceFileStrings), |
| 141 base::MemoryMappedFile::Region::kWholeFile); | 142 base::MemoryMappedFile::Region::kWholeFile); |
| 142 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 143 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 143 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile100), | 144 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile100), |
| 144 ui::SCALE_FACTOR_100P); | 145 ui::SCALE_FACTOR_100P); |
| 145 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200), | 146 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200), |
| 146 ui::SCALE_FACTOR_200P); | 147 ui::SCALE_FACTOR_200P); |
| 147 | 148 |
| 148 // Initialize the cursors. | 149 // Initialize the cursors. |
| 149 image_cursors_ = base::MakeUnique<ui::ImageCursors>(); | 150 image_cursors_holder_ = base::MakeUnique<ui::ImageCursorsHolder>(); |
| 150 image_cursors_weak_ptr_ = image_cursors_->GetWeakPtr(); | 151 image_cursors_holder_->SetImageCursors(base::MakeUnique<ui::ImageCursors>()); |
| 152 image_cursors_holder_weak_ptr_ = image_cursors_holder_->GetWeakPtr(); |
| 151 | 153 |
| 152 return true; | 154 return true; |
| 153 } | 155 } |
| 154 | 156 |
| 155 Service::UserState* Service::GetUserState( | 157 Service::UserState* Service::GetUserState( |
| 156 const service_manager::Identity& remote_identity) { | 158 const service_manager::Identity& remote_identity) { |
| 157 const ws::UserId& user_id = remote_identity.user_id(); | 159 const ws::UserId& user_id = remote_identity.user_id(); |
| 158 auto it = user_id_to_user_state_.find(user_id); | 160 auto it = user_id_to_user_state_.find(user_id); |
| 159 if (it != user_id_to_user_state_.end()) | 161 if (it != user_id_to_user_state_.end()) |
| 160 return it->second.get(); | 162 return it->second.get(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 screen_manager_->AddInterfaces(®istry_); | 357 screen_manager_->AddInterfaces(®istry_); |
| 356 if (is_gpu_ready_) | 358 if (is_gpu_ready_) |
| 357 screen_manager_->Init(window_server_->display_manager()); | 359 screen_manager_->Init(window_server_->display_manager()); |
| 358 } | 360 } |
| 359 | 361 |
| 360 scoped_refptr<base::SingleThreadTaskRunner>& Service::GetResourceRunner() { | 362 scoped_refptr<base::SingleThreadTaskRunner>& Service::GetResourceRunner() { |
| 361 DCHECK(resource_runner_); | 363 DCHECK(resource_runner_); |
| 362 return resource_runner_; | 364 return resource_runner_; |
| 363 } | 365 } |
| 364 | 366 |
| 365 base::WeakPtr<ui::ImageCursors> Service::GetImageCursorsWeakPtr() { | 367 base::WeakPtr<ui::ImageCursorsHolder> Service::GetImageCursorsHolderWeakPtr() { |
| 366 return image_cursors_weak_ptr_; | 368 return image_cursors_holder_weak_ptr_; |
| 367 } | 369 } |
| 368 | 370 |
| 369 void Service::BindAccessibilityManagerRequest( | 371 void Service::BindAccessibilityManagerRequest( |
| 370 const service_manager::BindSourceInfo& source_info, | 372 const service_manager::BindSourceInfo& source_info, |
| 371 mojom::AccessibilityManagerRequest request) { | 373 mojom::AccessibilityManagerRequest request) { |
| 372 UserState* user_state = GetUserState(source_info.identity); | 374 UserState* user_state = GetUserState(source_info.identity); |
| 373 if (!user_state->accessibility) { | 375 if (!user_state->accessibility) { |
| 374 const ws::UserId& user_id = source_info.identity.user_id(); | 376 const ws::UserId& user_id = source_info.identity.user_id(); |
| 375 user_state->accessibility.reset( | 377 user_state->accessibility.reset( |
| 376 new ws::AccessibilityManager(window_server_.get(), user_id)); | 378 new ws::AccessibilityManager(window_server_.get(), user_id)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 mojom::WindowServerTestRequest request) { | 489 mojom::WindowServerTestRequest request) { |
| 488 if (!test_config_) | 490 if (!test_config_) |
| 489 return; | 491 return; |
| 490 mojo::MakeStrongBinding( | 492 mojo::MakeStrongBinding( |
| 491 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), | 493 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), |
| 492 std::move(request)); | 494 std::move(request)); |
| 493 } | 495 } |
| 494 | 496 |
| 495 | 497 |
| 496 } // namespace ui | 498 } // namespace ui |
| OLD | NEW |