Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: chrome/browser/ui/ash/ash_init.cc

Issue 2777223002: Gets chrome --mus some what working (Closed)
Patch Set: fix mac Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/ash_init.h ('k') | chrome/browser/ui/ash/ash_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/ash_init.cc
diff --git a/chrome/browser/ui/ash/ash_init.cc b/chrome/browser/ui/ash/ash_init.cc
index 388a113441e27348845896572b842567904be795..568d12127b718005de786c2e8e712556109a8c9c 100644
--- a/chrome/browser/ui/ash/ash_init.cc
+++ b/chrome/browser/ui/ash/ash_init.cc
@@ -11,9 +11,13 @@
#include "ash/high_contrast/high_contrast_controller.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/magnifier/partial_magnification_controller.h"
+#include "ash/mus/bridge/wm_shell_mus.h"
+#include "ash/mus/window_manager.h"
+#include "ash/public/cpp/config.h"
#include "ash/shell.h"
#include "ash/shell_init_params.h"
#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
#include "base/sys_info.h"
#include "base/threading/sequenced_worker_pool.h"
#include "build/build_config.h"
@@ -22,6 +26,7 @@
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
+#include "chrome/browser/chromeos/ash_config.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
#include "chrome/browser/ui/ash/chrome_shell_content_state.h"
@@ -33,18 +38,53 @@
#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/context_factory.h"
+#include "content/public/common/service_manager_connection.h"
#include "ui/aura/env.h"
+#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/window_tree_host.h"
#if defined(USE_X11)
#include "ui/base/x/x11_util.h" // nogncheck
#endif
-namespace chrome {
+namespace {
-void OpenAsh(gfx::AcceleratedWidget remote_window) {
+void CreateClassicShell() {
+ ash::ShellInitParams shell_init_params;
+ // Shell takes ownership of ChromeShellDelegate.
+ shell_init_params.delegate = new ChromeShellDelegate;
+ shell_init_params.context_factory = content::GetContextFactory();
+ shell_init_params.context_factory_private =
+ content::GetContextFactoryPrivate();
+ shell_init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
+
+ ash::Shell::CreateInstance(shell_init_params);
+}
+
+std::unique_ptr<ash::mus::WindowManager> CreateMusShell() {
+ service_manager::Connector* connector =
+ content::ServiceManagerConnection::GetForProcess()->GetConnector();
+ std::unique_ptr<ash::mus::WindowManager> window_manager =
+ base::MakeUnique<ash::mus::WindowManager>(connector, ash::Config::MUS);
+ std::unique_ptr<aura::WindowTreeClient> window_tree_client =
+ base::MakeUnique<aura::WindowTreeClient>(connector, window_manager.get(),
+ window_manager.get());
+ window_tree_client->ConnectAsWindowManager();
+ aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get());
+ window_manager->Init(std::move(window_tree_client),
+ content::BrowserThread::GetBlockingPool(),
+ base::MakeUnique<ChromeShellDelegate>());
+ CHECK(window_manager->WaitForInitialDisplays());
+ return window_manager;
+}
+
+} // namespace
+
+AshInit::AshInit() {
#if defined(USE_X11)
if (base::SysInfo::IsRunningOnChromeOS()) {
+ // Mus only runs on ozone.
+ DCHECK_NE(ash::Config::MUS, chromeos::GetConfig());
// Hides the cursor outside of the Aura root window. The cursor will be
// drawn within the Aura root window, and it'll remain hidden after the
// Aura window is closed.
@@ -59,19 +99,28 @@ void OpenAsh(gfx::AcceleratedWidget remote_window) {
// Balanced by a call to DestroyInstance() in CloseAsh() below.
ash::ShellContentState::SetInstance(new ChromeShellContentState);
- ash::ShellInitParams shell_init_params;
- // Shell takes ownership of ChromeShellDelegate.
- shell_init_params.delegate = new ChromeShellDelegate;
- shell_init_params.context_factory = content::GetContextFactory();
- shell_init_params.context_factory_private =
- content::GetContextFactoryPrivate();
- shell_init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
+ if (chromeos::GetConfig() == ash::Config::MUS)
+ window_manager_ = CreateMusShell();
+ else
+ CreateClassicShell();
+
+ ash::Shell* shell = ash::Shell::GetInstance();
- ash::Shell* shell = ash::Shell::CreateInstance(shell_init_params);
- ash::WmShellAura::Get()
- ->accelerator_controller_delegate()
- ->SetScreenshotDelegate(std::unique_ptr<ash::ScreenshotDelegate>(
- new ChromeScreenshotGrabber));
+ ash::AcceleratorControllerDelegateAura* accelerator_controller_delegate =
+ nullptr;
+ if (chromeos::GetConfig() == ash::Config::CLASSIC) {
+ accelerator_controller_delegate =
+ ash::WmShellAura::Get()->accelerator_controller_delegate();
+ } else if (chromeos::GetConfig() == ash::Config::MUS) {
+ accelerator_controller_delegate =
+ ash::mus::WmShellMus::Get()->accelerator_controller_delegate_classic();
+ }
+ if (accelerator_controller_delegate) {
+ std::unique_ptr<ChromeScreenshotGrabber> screenshot_delegate =
+ base::MakeUnique<ChromeScreenshotGrabber>();
+ accelerator_controller_delegate->SetScreenshotDelegate(
+ std::move(screenshot_delegate));
+ }
// TODO(flackr): Investigate exposing a blocking pool task runner to chromeos.
chromeos::AccelerometerReader::GetInstance()->Initialize(
content::BrowserThread::GetBlockingPool()
@@ -100,11 +149,10 @@ void OpenAsh(gfx::AcceleratedWidget remote_window) {
ash::Shell::GetPrimaryRootWindow()->GetHost()->Show();
}
-void CloseAsh() {
- if (ash::Shell::HasInstance()) {
+AshInit::~AshInit() {
+ // |window_manager_| deletes the Shell.
+ if (!window_manager_ && ash::Shell::HasInstance()) {
ash::Shell::DeleteInstance();
ash::ShellContentState::DestroyInstance();
}
}
-
-} // namespace chrome
« no previous file with comments | « chrome/browser/ui/ash/ash_init.h ('k') | chrome/browser/ui/ash/ash_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698