Index: services/ui/service.cc |
diff --git a/services/ui/service.cc b/services/ui/service.cc |
index 3113ce8fec9923ca555f8943950d1cf7c5f5e364..5514f158eb0c3a4734fdbfe888469aadf0baacce 100644 |
--- a/services/ui/service.cc |
+++ b/services/ui/service.cc |
@@ -41,6 +41,7 @@ |
#include "services/ui/ws/window_tree_binding.h" |
#include "services/ui/ws/window_tree_factory.h" |
#include "services/ui/ws/window_tree_host_factory.h" |
+#include "ui/base/cursor/image_cursors.h" |
#include "ui/base/platform_window_defaults.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/base/ui_base_paths.h" |
@@ -91,7 +92,13 @@ struct Service::UserState { |
std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
}; |
-Service::Service() : test_config_(false), ime_registrar_(&ime_driver_) {} |
+Service::Service(scoped_refptr<base::SingleThreadTaskRunner> resource_runner, |
+ base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr) |
+ : in_process_(resource_runner != nullptr), |
+ resource_runner_(resource_runner), |
+ image_cursors_weak_ptr_(image_cursors_weak_ptr), |
+ test_config_(false), |
+ ime_registrar_(&ime_driver_) {} |
Service::~Service() { |
// Destroy |window_server_| first, since it depends on |event_source_|. |
@@ -110,7 +117,7 @@ Service::~Service() { |
} |
bool Service::InitializeResources(service_manager::Connector* connector) { |
- if (ui::ResourceBundle::HasSharedInstance()) |
+ if (in_process() || ui::ResourceBundle::HasSharedInstance()) |
return true; |
std::set<std::string> resource_paths; |
@@ -137,6 +144,11 @@ bool Service::InitializeResources(service_manager::Connector* connector) { |
ui::SCALE_FACTOR_100P); |
rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200), |
ui::SCALE_FACTOR_200P); |
+ |
+ // Initialize the cursors. |
sky
2017/06/27 19:58:56
This comment just documents the code and so isn't
mfomitchev
2017/07/11 21:46:59
Done.
|
+ image_cursors_ = base::MakeUnique<ui::ImageCursors>(); |
+ image_cursors_weak_ptr_ = image_cursors_->GetWeakPtr(); |
+ |
return true; |
} |
@@ -156,11 +168,17 @@ void Service::AddUserIfNecessary( |
} |
void Service::OnStart() { |
- base::PlatformThread::SetName("mus"); |
+ if (!in_process()) |
+ base::PlatformThread::SetName("mus"); |
+ |
TRACE_EVENT0("mus", "Service::Initialize started"); |
+ if (!resource_runner_) |
+ resource_runner_ = base::ThreadTaskRunnerHandle::Get(); |
+ |
test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kUseTestConfig); |
+ |
#if defined(USE_X11) |
XInitThreads(); |
ui::SetDefaultX11ErrorHandlers(); |
@@ -188,9 +206,12 @@ void Service::OnStart() { |
// Assume a client will change the layout to an appropriate configuration. |
ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() |
->SetCurrentLayoutByName("us"); |
- client_native_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone(); |
- gfx::ClientNativePixmapFactory::SetInstance( |
- client_native_pixmap_factory_.get()); |
+ |
+ if (!in_process()) { |
+ client_native_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone(); |
+ gfx::ClientNativePixmapFactory::SetInstance( |
+ client_native_pixmap_factory_.get()); |
+ } |
DCHECK(gfx::ClientNativePixmapFactory::GetInstance()); |
@@ -323,7 +344,8 @@ void Service::OnWillCreateTreeForWindowManager( |
if (window_server_->display_creation_config() == |
ws::DisplayCreationConfig::MANUAL) { |
#if defined(USE_OZONE) && defined(OS_CHROMEOS) |
- screen_manager_ = base::MakeUnique<display::ScreenManagerForwarding>(); |
+ screen_manager_ = |
+ base::MakeUnique<display::ScreenManagerForwarding>(in_process()); |
#else |
CHECK(false); |
#endif |
@@ -335,6 +357,15 @@ void Service::OnWillCreateTreeForWindowManager( |
screen_manager_->Init(window_server_->display_manager()); |
} |
+scoped_refptr<base::SingleThreadTaskRunner>& Service::GetResourceRunner() { |
+ DCHECK(resource_runner_); |
+ return resource_runner_; |
+} |
+ |
+base::WeakPtr<ui::ImageCursors> Service::GetImageCursorsWeakPtr() { |
+ return image_cursors_weak_ptr_; |
+} |
+ |
void Service::BindAccessibilityManagerRequest( |
const service_manager::BindSourceInfo& source_info, |
mojom::AccessibilityManagerRequest request) { |