1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96

ash / public / cpp / session / session_types.h [blame]

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_PUBLIC_CPP_SESSION_SESSION_TYPES_H_
#define ASH_PUBLIC_CPP_SESSION_SESSION_TYPES_H_

#include <stdint.h>

#include <string>

#include "ash/public/cpp/ash_public_export.h"
#include "ash/public/cpp/session/user_info.h"
#include "components/session_manager/session_manager_types.h"

namespace ash {

// The index of the user profile to use. The list is always LRU sorted so that
// index 0 is the currently active user.
using UserIndex = int;

// Represents possible user adding scenarios.
enum class AddUserSessionPolicy {
  // Adding a user is allowed.
  ALLOWED,
  // Disallowed due to primary user's policy.
  ERROR_NOT_ALLOWED_PRIMARY_USER,
  // Disallowed due to no eligible users.
  ERROR_NO_ELIGIBLE_USERS,
  // Disallowed due to reaching maximum supported user.
  ERROR_MAXIMUM_USERS_REACHED,
  // Disallowed multi-profile because device is locked to single user.
  ERROR_LOCKED_TO_SINGLE_USER,
};

// Defines the cycle direction for |CycleActiveUser|.
enum class CycleUserDirection {
  NEXT = 0,  // Cycle to the next user.
  PREVIOUS,  // Cycle to the previous user.
};

// Info about an ash session.
struct ASH_PUBLIC_EXPORT SessionInfo {
  // Whether the screen can be locked.
  bool can_lock_screen = false;

  // Whether the screen should be locked automatically before suspending.
  bool should_lock_screen_automatically = false;

  // Whether the session is in app mode, which includes a kiosk-like mode for
  // fullscreen web content or running a single [forced] Chrome or ARC app.
  bool is_running_in_app_mode = false;

  // Whether the session is a demo session, which is an ephemeral session for
  // Demo Mode.
  bool is_demo_session = false;

  // Sets whether adding a user session to ash is allowed.
  AddUserSessionPolicy add_user_session_policy = AddUserSessionPolicy::ALLOWED;

  // Current state of the ash session.
  session_manager::SessionState state = session_manager::SessionState::UNKNOWN;
};

ASH_PUBLIC_EXPORT bool operator==(const SessionInfo& a, const SessionInfo& b);

// Info about a user session in ash.
struct ASH_PUBLIC_EXPORT UserSession {
  UserSession();
  UserSession(const UserSession& other);
  ~UserSession();

  // A user session id for the user session. It is generated by session manager
  // (chrome) when a user session starts and never changes during the lifetime
  // of the session manager. The number starts at 1 for the first user session
  // and incremented by one for each subsequent user session.
  uint32_t session_id = 0;

  // Contains general user information state, like the account id, display name,
  // and avatar.
  UserInfo user_info;

  // For supervised users only, the email address of the custodian account.
  // Empty for non-supervised users. Available after profile is loaded.
  std::string custodian_email;

  // For supervised users only, the email address of the second custodian
  // account, if any. Available after profile is loaded.
  std::string second_custodian_email;
};

ASH_PUBLIC_EXPORT bool operator==(const UserSession& a, const UserSession& b);

}  // namespace ash

#endif  // ASH_PUBLIC_CPP_SESSION_SESSION_TYPES_H_