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..ed1436237210b67bcbecf0ad8c41ea6e2596d0e9 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 |
@@ -14,6 +14,7 @@ |
#include "chrome/browser/ui/ash/ash_util.h" |
#include "chrome/browser/ui/views/ash/tab_scrubber.h" |
#include "chrome/common/chrome_switches.h" |
+#include "components/exo/display.h" |
#include "ui/aura/env.h" |
#include "ui/gfx/screen.h" |
#include "ui/gfx/screen_type_delegate.h" |
@@ -34,6 +35,13 @@ |
#include "base/win/windows_version.h" |
#endif |
+#if defined(OS_LINUX) |
+#include "base/message_loop/message_loop.h" |
+#include "chrome/common/chrome_switches.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,36 @@ base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate; |
#endif |
+#if defined(OS_LINUX) |
+class ChromeBrowserMainExtraPartsAsh::WaylandWatcher |
+ : public base::MessagePumpLibevent::Watcher { |
+ public: |
+ explicit WaylandWatcher(exo::wayland::Server* server) : server_(server) { |
+#if defined(USE_OZONE) || (defined(USE_X11) && !defined(USE_GLIB)) |
+ base::MessageLoopForUI::current()->WatchFileDescriptor( |
+ server_->GetFileDescriptor(), |
+ true, // persistent |
+ base::MessagePumpLibevent::WATCH_READ, &controller_, this); |
+#else |
+ NOTIMPLEMENTED(); |
+#endif |
+ } |
+ |
+ // 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 +117,16 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
ash::Shell::GetInstance()->CreateShelf(); |
ash::Shell::GetInstance()->ShowShelf(); |
#endif |
+ |
+ exo_display_ = make_scoped_ptr(new exo::Display); |
+#if defined(OS_LINUX) |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableWaylandServer)) { |
+ 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 +159,9 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() { |
} |
void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { |
+#if defined(OS_LINUX) |
+ wayland_server_.reset(); |
+#endif |
+ exo_display_.reset(); |
chrome::CloseAsh(); |
} |