Index: chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
index 37851a85b9087e1d659feca22cd7e7bced540721..9c3f23985ce6161cc5e3f89215647634632f2e9d 100644 |
--- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
+++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
@@ -34,6 +34,14 @@ |
#include "base/win/windows_version.h" |
#endif |
+#if defined(ENABLE_WAYLAND_SERVER) |
+#include "base/message_loop/message_loop.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "components/exo/display.h" |
+#include "components/exo/wayland/server.h" |
+#include "content/public/browser/browser_thread.h" |
+#endif |
+ |
#if !defined(OS_CHROMEOS) |
class ScreenTypeDelegateWin : public gfx::ScreenTypeDelegate { |
public: |
@@ -65,6 +73,32 @@ base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate; |
#endif |
+#if defined(ENABLE_WAYLAND_SERVER) |
+class ChromeBrowserMainExtraPartsAsh::WaylandWatcher |
+ : public base::MessagePumpLibevent::Watcher { |
+ public: |
+ explicit WaylandWatcher(exo::wayland::Server* server) : server_(server) { |
+ base::MessageLoopForUI::current()->WatchFileDescriptor( |
+ server_->GetFileDescriptor(), |
+ true, // persistent |
+ base::MessagePumpLibevent::WATCH_READ, &controller_, this); |
+ } |
+ |
+ // base::MessagePumpLibevent::Watcher: |
+ void OnFileCanReadWithoutBlocking(int fd) override { |
+ server_->Dispatch(base::TimeDelta()); |
+ server_->Flush(); |
+ } |
+ void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); } |
+ |
+ private: |
+ base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
+ exo::wayland::Server* const server_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WaylandWatcher); |
+}; |
+#endif |
+ |
ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { |
} |
@@ -79,6 +113,16 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
ash::Shell::GetInstance()->CreateShelf(); |
ash::Shell::GetInstance()->ShowShelf(); |
#endif |
+ |
+#if defined(ENABLE_WAYLAND_SERVER) |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableWaylandServer)) { |
+ exo_display_ = make_scoped_ptr(new exo::Display); |
+ wayland_server_ = exo::wayland::Server::Create(exo_display_.get()); |
+ wayland_watcher_ = |
+ make_scoped_ptr(new WaylandWatcher(wayland_server_.get())); |
+ } |
+#endif |
} else { |
#if !defined(OS_CHROMEOS) |
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin); |
@@ -111,5 +155,9 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() { |
} |
void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { |
+#if defined(ENABLE_WAYLAND_SERVER) |
+ wayland_server_.reset(); |
+ exo_display_.reset(); |
+#endif |
chrome::CloseAsh(); |
} |