Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / ash / multi_user / multi_user_window_manager_test.cc
blob4b39f9385a9357e7363d4b178e5bcc84c61c3b69
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_test.h"
7 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
8 #include "chrome/browser/ui/browser_window.h"
9 #include "ui/aura/window.h"
11 TestMultiUserWindowManager::TestMultiUserWindowManager(
12 Browser* visiting_browser,
13 const std::string& desktop_owner)
14 : browser_window_(visiting_browser->window()->GetNativeWindow()),
15 browser_owner_(
16 multi_user_util::GetUserIDFromProfile(visiting_browser->profile())),
17 desktop_owner_(desktop_owner),
18 created_window_(NULL),
19 created_window_shown_for_(browser_owner_),
20 current_user_id_(desktop_owner) {
21 // Register this object with the system (which will take ownership). It will
22 // be deleted by ChromeLauncherController::~ChromeLauncherController().
23 chrome::MultiUserWindowManager::SetInstanceForTest(
24 this, chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED);
27 TestMultiUserWindowManager::~TestMultiUserWindowManager() {
28 // This object is owned by the MultiUserWindowManager since the
29 // SetInstanceForTest call. As such no uninstall is required.
32 void TestMultiUserWindowManager::SetWindowOwner(aura::Window* window,
33 const std::string& user_id) {
34 NOTREACHED();
37 const std::string& TestMultiUserWindowManager::GetWindowOwner(
38 aura::Window* window) const {
39 // No matter which window will get queried - all browsers belong to the
40 // original browser's user.
41 return browser_owner_;
44 void TestMultiUserWindowManager::ShowWindowForUser(aura::Window* window,
45 const std::string& user_id) {
46 // This class is only able to handle one additional window <-> user
47 // association beside the creation parameters.
48 // If no association has yet been requested remember it now.
49 DCHECK(!created_window_);
50 created_window_ = window;
51 created_window_shown_for_ = user_id;
53 if (browser_window_ == window)
54 desktop_owner_ = user_id;
56 if (user_id == current_user_id_)
57 return;
59 // Change the visibility of the window to update the view recursively.
60 window->Hide();
61 window->Show();
62 current_user_id_ = user_id;
65 bool TestMultiUserWindowManager::AreWindowsSharedAmongUsers() const {
66 return browser_owner_ != desktop_owner_;
69 void TestMultiUserWindowManager::GetOwnersOfVisibleWindows(
70 std::set<std::string>* user_ids) const {
73 bool TestMultiUserWindowManager::IsWindowOnDesktopOfUser(
74 aura::Window* window,
75 const std::string& user_id) const {
76 return GetUserPresentingWindow(window) == user_id;
79 const std::string& TestMultiUserWindowManager::GetUserPresentingWindow(
80 aura::Window* window) const {
81 if (window == browser_window_)
82 return desktop_owner_;
83 if (created_window_ && window == created_window_)
84 return created_window_shown_for_;
85 // We can come here before the window gets registered.
86 return browser_owner_;
89 void TestMultiUserWindowManager::AddUser(content::BrowserContext* profile) {
92 void TestMultiUserWindowManager::AddObserver(Observer* observer) {
95 void TestMultiUserWindowManager::RemoveObserver(Observer* observer) {