multi_user_window_manager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2019 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.
  4. #ifndef ASH_PUBLIC_CPP_MULTI_USER_WINDOW_MANAGER_H_
  5. #define ASH_PUBLIC_CPP_MULTI_USER_WINDOW_MANAGER_H_
  6. #include <memory>
  7. #include <set>
  8. #include "ash/ash_export.h"
  9. class AccountId;
  10. namespace aura {
  11. class Window;
  12. }
  13. namespace ash {
  14. class MultiUserWindowManagerDelegate;
  15. // Used to assign windows to user accounts so that ash shows the appropriate set
  16. // of windows based on the active user.
  17. class ASH_EXPORT MultiUserWindowManager {
  18. public:
  19. static std::unique_ptr<MultiUserWindowManager> Create(
  20. MultiUserWindowManagerDelegate* delegate,
  21. const AccountId& account_id);
  22. virtual ~MultiUserWindowManager() {}
  23. // Associates a window with a particular account. This may result in hiding
  24. // |window|. This should *not* be called more than once with a different
  25. // account. If |window| was created by a user gesture
  26. // (aura::client::kCreatedByUserGesture), then the 'shown' account is set to
  27. // the current account.
  28. virtual void SetWindowOwner(aura::Window* window,
  29. const AccountId& account_id) = 0;
  30. // Shows a previously registered window for the specified account.
  31. virtual void ShowWindowForUser(aura::Window* window,
  32. const AccountId& account_id) = 0;
  33. virtual const AccountId& GetWindowOwner(const aura::Window* window) const = 0;
  34. // Returns true if at least one window's 'owner' account differs from its
  35. // 'shown' account. In other words, a window from one account is shown with
  36. // windows from another account.
  37. virtual bool AreWindowsSharedAmongUsers() const = 0;
  38. // Returns the set owners for the visible windows.
  39. virtual std::set<AccountId> GetOwnersOfVisibleWindows() const = 0;
  40. // Returns the user for which the window is currently shown. An empty
  41. // AccountId() is returned if the window is presented for every user.
  42. virtual const AccountId& GetUserPresentingWindow(
  43. const aura::Window* window) const = 0;
  44. // Returns the id of the currently active user.
  45. virtual const AccountId& CurrentAccountId() const = 0;
  46. protected:
  47. MultiUserWindowManager() {}
  48. };
  49. } // namespace ash
  50. #endif // ASH_PUBLIC_CPP_MULTI_USER_WINDOW_MANAGER_H_