summaryrefslogtreecommitdiff
path: root/chromium/components/exo/server
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/exo/server
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/exo/server')
-rw-r--r--chromium/components/exo/server/BUILD.gn21
-rw-r--r--chromium/components/exo/server/OWNERS1
-rw-r--r--chromium/components/exo/server/wayland_server_controller.cc62
-rw-r--r--chromium/components/exo/server/wayland_server_controller.h61
4 files changed, 145 insertions, 0 deletions
diff --git a/chromium/components/exo/server/BUILD.gn b/chromium/components/exo/server/BUILD.gn
new file mode 100644
index 00000000000..0dc6caef345
--- /dev/null
+++ b/chromium/components/exo/server/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+assert(is_chromeos)
+
+source_set("server") {
+ sources = [
+ "wayland_server_controller.cc",
+ "wayland_server_controller.h",
+ ]
+
+ deps = [
+ "//ash/public/cpp",
+ "//ash/public/cpp/external_arc",
+ "//base",
+ "//components/exo",
+ "//components/exo/wayland",
+ "//skia",
+ ]
+}
diff --git a/chromium/components/exo/server/OWNERS b/chromium/components/exo/server/OWNERS
new file mode 100644
index 00000000000..2285adf99b1
--- /dev/null
+++ b/chromium/components/exo/server/OWNERS
@@ -0,0 +1 @@
+penghuang@chromium.org
diff --git a/chromium/components/exo/server/wayland_server_controller.cc b/chromium/components/exo/server/wayland_server_controller.cc
new file mode 100644
index 00000000000..8f2823796be
--- /dev/null
+++ b/chromium/components/exo/server/wayland_server_controller.cc
@@ -0,0 +1,62 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/exo/server/wayland_server_controller.h"
+
+#include <memory>
+
+#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
+#include "base/message_loop/message_loop_current.h"
+#include "components/exo/display.h"
+#include "components/exo/file_helper.h"
+#include "components/exo/input_method_surface_manager.h"
+#include "components/exo/notification_surface_manager.h"
+#include "components/exo/wayland/server.h"
+#include "components/exo/wayland/wayland_watcher.h"
+#include "components/exo/wm_helper.h"
+#include "components/exo/wm_helper_chromeos.h"
+
+namespace exo {
+
+// static
+std::unique_ptr<WaylandServerController>
+WaylandServerController::CreateIfNecessary(
+ std::unique_ptr<FileHelper> file_helper,
+ std::unique_ptr<NotificationSurfaceManager> notification_surface_manager,
+ std::unique_ptr<InputMethodSurfaceManager> input_method_surface_manager) {
+ return std::make_unique<WaylandServerController>(
+ std::move(file_helper), std::move(notification_surface_manager),
+ std::move(input_method_surface_manager));
+}
+
+WaylandServerController::~WaylandServerController() {
+ // Delete the instance in the reversed order they are created.
+ wayland_watcher_.reset();
+ wayland_server_.reset();
+ display_.reset();
+ WMHelper::SetInstance(nullptr);
+ wm_helper_.reset();
+}
+
+WaylandServerController::WaylandServerController(
+ std::unique_ptr<FileHelper> file_helper,
+ std::unique_ptr<NotificationSurfaceManager> notification_surface_manager,
+ std::unique_ptr<InputMethodSurfaceManager> input_method_surface_manager)
+ : wm_helper_(std::make_unique<WMHelperChromeOS>()),
+ notification_surface_manager_(std::move(notification_surface_manager)),
+ input_method_surface_manager_(std::move(input_method_surface_manager)) {
+ WMHelper::SetInstance(wm_helper_.get());
+ display_ = std::make_unique<Display>(notification_surface_manager_.get(),
+ input_method_surface_manager_.get(),
+ std::move(file_helper));
+ wayland_server_ = wayland::Server::Create(display_.get());
+ // Wayland server creation can fail if XDG_RUNTIME_DIR is not set correctly.
+ if (wayland_server_) {
+ wayland_watcher_ =
+ std::make_unique<wayland::WaylandWatcher>(wayland_server_.get());
+ }
+}
+
+} // namespace exo
diff --git a/chromium/components/exo/server/wayland_server_controller.h b/chromium/components/exo/server/wayland_server_controller.h
new file mode 100644
index 00000000000..9f448c6e9fd
--- /dev/null
+++ b/chromium/components/exo/server/wayland_server_controller.h
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_EXO_SERVER_WAYLAND_SERVER_CONTROLLER_H_
+#define COMPONENTS_EXO_SERVER_WAYLAND_SERVER_CONTROLLER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+
+namespace exo {
+
+namespace wayland {
+class Server;
+class WaylandWatcher;
+} // namespace wayland
+
+class Display;
+class FileHelper;
+class WMHelper;
+class NotificationSurfaceManager;
+class InputMethodSurfaceManager;
+
+class WaylandServerController {
+ public:
+ static std::unique_ptr<WaylandServerController> CreateForArcIfNecessary(
+ std::unique_ptr<FileHelper> file_helper);
+
+ // Creates WaylandServerController. Returns null if controller should not be
+ // created.
+ static std::unique_ptr<WaylandServerController> CreateIfNecessary(
+ std::unique_ptr<FileHelper> file_helper,
+ std::unique_ptr<NotificationSurfaceManager> notification_surface_manager,
+ std::unique_ptr<InputMethodSurfaceManager> input_method_surface_manager);
+
+ ~WaylandServerController();
+
+ InputMethodSurfaceManager* input_method_surface_manager() {
+ return input_method_surface_manager_.get();
+ }
+
+ WaylandServerController(
+ std::unique_ptr<FileHelper> file_helper,
+ std::unique_ptr<NotificationSurfaceManager> notification_surface_manager,
+ std::unique_ptr<InputMethodSurfaceManager> input_method_surface_manager);
+
+ private:
+ std::unique_ptr<WMHelper> wm_helper_;
+ std::unique_ptr<Display> display_;
+ std::unique_ptr<wayland::Server> wayland_server_;
+ std::unique_ptr<wayland::WaylandWatcher> wayland_watcher_;
+ std::unique_ptr<NotificationSurfaceManager> notification_surface_manager_;
+ std::unique_ptr<InputMethodSurfaceManager> input_method_surface_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(WaylandServerController);
+};
+
+} // namespace exo
+
+#endif // COMPONENTS_EXO_SERVER_WAYLAND_SERVER_CONTROLLER_H_