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

ash / public / cpp / kiosk_app_menu.cc [blame]

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

#include "ash/public/cpp/kiosk_app_menu.h"

#include <optional>

#include "base/check.h"
#include "base/check_op.h"

namespace ash {

namespace {

KioskAppMenu* g_instance = nullptr;

}  // namespace

KioskAppMenuEntry::KioskAppMenuEntry(
    AppType type,
    const AccountId& account_id,
    const std::optional<std::string>& chrome_app_id,
    std::u16string name,
    gfx::ImageSkia icon)
    : type(type),
      account_id(account_id),
      chrome_app_id(chrome_app_id),
      name(std::move(name)),
      icon(icon) {
  bool should_have_chrome_app_id = type == AppType::kChromeApp;
  CHECK_EQ(should_have_chrome_app_id, chrome_app_id.has_value());
}
KioskAppMenuEntry::KioskAppMenuEntry(const KioskAppMenuEntry& other) = default;
KioskAppMenuEntry::KioskAppMenuEntry(KioskAppMenuEntry&& other) = default;
KioskAppMenuEntry::~KioskAppMenuEntry() = default;

KioskAppMenuEntry& KioskAppMenuEntry::operator=(KioskAppMenuEntry&& other) =
    default;
KioskAppMenuEntry& KioskAppMenuEntry::operator=(
    const KioskAppMenuEntry& other) = default;

// static
KioskAppMenu* KioskAppMenu::Get() {
  return g_instance;
}

KioskAppMenu::KioskAppMenu() {
  DCHECK_EQ(nullptr, g_instance);
  g_instance = this;
}

KioskAppMenu::~KioskAppMenu() {
  DCHECK_EQ(this, g_instance);
  g_instance = nullptr;
}

}  // namespace ash