Commit bc0c4e67 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: make mash use MultiUserWindowManagerChromeOS

Ash's MultiUserWindowManagerBridge now creates ash::MultiUserWindowManager
in multi-process mode.

BUG=875111
TEST=covered by tests

Change-Id: I9702b18b453ae4cdde5aad4a8774e2c510e4e9f1
Reviewed-on: https://chromium-review.googlesource.com/c/1355484
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612472}
parent 2b64c2db
......@@ -82,6 +82,11 @@ int SessionController::NumberOfLoggedInUsers() const {
return static_cast<int>(user_sessions_.size());
}
AccountId SessionController::GetActiveAccountId() const {
return user_sessions_.empty() ? AccountId()
: user_sessions_[0]->user_info->account_id;
}
AddUserSessionPolicy SessionController::GetAddUserPolicy() const {
return add_user_session_policy_;
}
......
......@@ -54,6 +54,10 @@ class ASH_EXPORT SessionController : public mojom::SessionController {
// no session in progress or no active user.
int NumberOfLoggedInUsers() const;
// Returns the active account. If no users are logged in this returns an empty
// AccountId.
AccountId GetActiveAccountId() const;
// Gets the policy of adding a user session to ash.
AddUserSessionPolicy GetAddUserPolicy() const;
......
......@@ -5,8 +5,11 @@
#include "ash/ws/multi_user_window_manager_bridge.h"
#include "ash/multi_user/multi_user_window_manager.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "services/ws/window_tree.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
namespace ash {
......@@ -26,8 +29,19 @@ MultiUserWindowManagerBridge::~MultiUserWindowManagerBridge() {
void MultiUserWindowManagerBridge::SetClient(
mojom::MultiUserWindowManagerClientAssociatedPtrInfo client_info) {
multi_user_window_manager_.reset();
client_.Bind(std::move(client_info));
ash::MultiUserWindowManager::Get()->SetClient(client_.get());
if (features::IsMultiProcessMash()) {
// NOTE: there is nothing stopping mulitple MultiUserWindowManagerBridges
// from being created (because multiple clients ask for
// ash::mojom::MultiUserWindowManager). This code is assuming only a single
// client is used at a time.
multi_user_window_manager_ = std::make_unique<ash::MultiUserWindowManager>(
client_.get(), nullptr,
Shell::Get()->session_controller()->GetActiveAccountId());
} else {
ash::MultiUserWindowManager::Get()->SetClient(client_.get());
}
}
void MultiUserWindowManagerBridge::SetWindowOwner(ws::Id window_id,
......
......@@ -20,7 +20,11 @@ class WindowTree;
namespace ash {
// Trivially forwards calls to MultiUserWindowManager.
class MultiUserWindowManager;
// Responsible for forwarding calls to MultiUserWindowManager. In multi-process
// mash mode *this* owns the MultiUserWindowManager. In all other cases chrome
// owns the MultiUserWindowManager.
class MultiUserWindowManagerBridge : public mojom::MultiUserWindowManager,
public ws::WindowManagerInterface {
public:
......@@ -41,6 +45,8 @@ class MultiUserWindowManagerBridge : public mojom::MultiUserWindowManager,
ws::WindowTree* window_tree_;
mojo::AssociatedBinding<mojom::MultiUserWindowManager> binding_;
mojom::MultiUserWindowManagerClientAssociatedPtr client_;
// Only valid in MultiUserWindowManager.
std::unique_ptr<ash::MultiUserWindowManager> multi_user_window_manager_;
DISALLOW_COPY_AND_ASSIGN(MultiUserWindowManagerBridge);
};
......
......@@ -4,14 +4,12 @@
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#include "base/logging.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h"
#include "chrome/browser/ui/ash/session_controller_client.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user_info.h"
#include "components/user_manager/user_manager.h"
#include "ui/base/ui_base_features.h"
namespace {
MultiUserWindowManager* g_multi_user_window_manager_instance = nullptr;
......@@ -24,10 +22,7 @@ MultiUserWindowManager* MultiUserWindowManager::GetInstance() {
MultiUserWindowManager* MultiUserWindowManager::CreateInstance() {
DCHECK(!g_multi_user_window_manager_instance);
// TODO(crbug.com/875111): Enable this component in Mash. The object owns a
// UserSwitchAnimatorChromeOS with direct ash dependencies.
if (!features::IsMultiProcessMash() &&
SessionControllerClient::IsMultiProfileAvailable()) {
if (SessionControllerClient::IsMultiProfileAvailable()) {
MultiUserWindowManagerChromeOS* manager =
new MultiUserWindowManagerChromeOS(
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId());
......
......@@ -163,10 +163,8 @@ class MultiUserWindowManagerChromeOS
// The notification registrar to track the creation of browser windows.
content::NotificationRegistrar registrar_;
// TODO: this won't work in the multi-process mash case. What needs to happen
// for the multi-process case is MultiUserWindowManagerDelegate needs to be
// converted to a mojom that ash uses to call this code.
// https://crbug.com/875111.
// This is *only* created in classic and single-process mash cases. In
// multi-process mash Ash creates the MultiUserWindowManager.
std::unique_ptr<ash::MultiUserWindowManager> ash_multi_user_window_manager_;
// Only used for windows created for the window-service. For example,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment