Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/chrome_browser_main_extra_parts_exo.h" | 5 #include "chrome/browser/chrome_browser_main_extra_parts_exo.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 | 8 |
| 9 #if defined(USE_GLIB) | 9 #if defined(USE_GLIB) |
| 10 #include <glib.h> | 10 #include <glib.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "ash/public/cpp/window_properties.h" | |
| 14 #include "ash/public/interfaces/window_pin_type.mojom.h" | |
| 13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 16 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 16 #include "chrome/browser/ui/ash/ash_util.h" | 18 #include "chrome/browser/ui/ash/ash_util.h" |
| 17 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 18 #include "components/exo/display.h" | 20 #include "components/exo/display.h" |
| 19 #include "components/exo/wayland/server.h" | 21 #include "components/exo/wayland/server.h" |
| 20 #include "components/exo/wm_helper_ash.h" | 22 #include "components/exo/wm_helper_ash.h" |
| 21 #include "components/exo/wm_helper_mus.h" | 23 #include "components/exo/wm_helper_mus.h" |
| 22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 23 #include "ui/arc/notification/arc_notification_surface_manager.h" | 25 #include "ui/arc/notification/arc_notification_surface_manager.h" |
| 26 #include "ui/aura/mus/property_converter.h" | |
| 27 #include "ui/views/mus/mus_client.h" | |
| 24 | 28 |
| 25 #if defined(USE_GLIB) | 29 #if defined(USE_GLIB) |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 struct GLibWaylandSource : public GSource { | 32 struct GLibWaylandSource : public GSource { |
| 29 // Note: The GLibWaylandSource is created and destroyed by GLib. So its | 33 // Note: The GLibWaylandSource is created and destroyed by GLib. So its |
| 30 // constructor/destructor may or may not get called. | 34 // constructor/destructor may or may not get called. |
| 31 exo::wayland::Server* server; | 35 exo::wayland::Server* server; |
| 32 GPollFD* poll_fd; | 36 GPollFD* poll_fd; |
| 33 }; | 37 }; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 exo::wayland::Server* const server_; | 114 exo::wayland::Server* const server_; |
| 111 | 115 |
| 112 DISALLOW_COPY_AND_ASSIGN(WaylandWatcher); | 116 DISALLOW_COPY_AND_ASSIGN(WaylandWatcher); |
| 113 }; | 117 }; |
| 114 #endif | 118 #endif |
| 115 | 119 |
| 116 ChromeBrowserMainExtraPartsExo::ChromeBrowserMainExtraPartsExo() {} | 120 ChromeBrowserMainExtraPartsExo::ChromeBrowserMainExtraPartsExo() {} |
| 117 | 121 |
| 118 ChromeBrowserMainExtraPartsExo::~ChromeBrowserMainExtraPartsExo() {} | 122 ChromeBrowserMainExtraPartsExo::~ChromeBrowserMainExtraPartsExo() {} |
| 119 | 123 |
| 124 void ChromeBrowserMainExtraPartsExo::ServiceManagerConnectionStarted( | |
|
sky
2017/04/03 16:38:56
This property is really ash specific. I think you
Peng
2017/04/03 18:03:48
Done.
| |
| 125 content::ServiceManagerConnection* connection) { | |
| 126 if (ash_util::IsRunningInMash()) { | |
| 127 // Register exo-specific window properties with Chrome's property converter. | |
| 128 // This propagates ash properties set on exo windows to ash, via mojo. | |
| 129 DCHECK(views::MusClient::Exists()); | |
| 130 views::MusClient* mus_client = views::MusClient::Get(); | |
| 131 aura::WindowTreeClientDelegate* delegate = mus_client; | |
| 132 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); | |
| 133 | |
| 134 converter->RegisterProperty(ash::kWindowPinTypeKey, | |
| 135 ash::mojom::kWindowPinType_Property, | |
| 136 base::Bind(&ash::IsValidWindowPinType)); | |
| 137 } | |
| 138 } | |
| 139 | |
| 120 void ChromeBrowserMainExtraPartsExo::PreProfileInit() { | 140 void ChromeBrowserMainExtraPartsExo::PreProfileInit() { |
| 121 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 141 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 122 switches::kEnableWaylandServer)) | 142 switches::kEnableWaylandServer)) |
| 123 return; | 143 return; |
| 124 | 144 |
| 125 arc_notification_surface_manager_ = | 145 arc_notification_surface_manager_ = |
| 126 base::MakeUnique<arc::ArcNotificationSurfaceManager>(); | 146 base::MakeUnique<arc::ArcNotificationSurfaceManager>(); |
| 127 if (ash_util::IsRunningInMash()) | 147 if (ash_util::IsRunningInMash()) |
| 128 wm_helper_ = base::MakeUnique<exo::WMHelperMus>(); | 148 wm_helper_ = base::MakeUnique<exo::WMHelperMus>(); |
| 129 else | 149 else |
| 130 wm_helper_ = base::MakeUnique<exo::WMHelperAsh>(); | 150 wm_helper_ = base::MakeUnique<exo::WMHelperAsh>(); |
| 131 exo::WMHelper::SetInstance(wm_helper_.get()); | 151 exo::WMHelper::SetInstance(wm_helper_.get()); |
| 132 display_ = | 152 display_ = |
| 133 base::MakeUnique<exo::Display>(arc_notification_surface_manager_.get()); | 153 base::MakeUnique<exo::Display>(arc_notification_surface_manager_.get()); |
| 134 wayland_server_ = exo::wayland::Server::Create(display_.get()); | 154 wayland_server_ = exo::wayland::Server::Create(display_.get()); |
| 135 // Wayland server creation can fail if XDG_RUNTIME_DIR is not set correctly. | 155 // Wayland server creation can fail if XDG_RUNTIME_DIR is not set correctly. |
| 136 if (wayland_server_) | 156 if (wayland_server_) |
| 137 wayland_watcher_ = base::MakeUnique<WaylandWatcher>(wayland_server_.get()); | 157 wayland_watcher_ = base::MakeUnique<WaylandWatcher>(wayland_server_.get()); |
| 138 } | 158 } |
| 139 | 159 |
| 140 void ChromeBrowserMainExtraPartsExo::PostMainMessageLoopRun() { | 160 void ChromeBrowserMainExtraPartsExo::PostMainMessageLoopRun() { |
| 141 wayland_watcher_.reset(); | 161 wayland_watcher_.reset(); |
| 142 wayland_server_.reset(); | 162 wayland_server_.reset(); |
| 143 if (wm_helper_) { | 163 if (wm_helper_) { |
| 144 exo::WMHelper::SetInstance(nullptr); | 164 exo::WMHelper::SetInstance(nullptr); |
| 145 wm_helper_.reset(); | 165 wm_helper_.reset(); |
| 146 } | 166 } |
| 147 } | 167 } |
| OLD | NEW |