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

ash / public / cpp / graduation / graduation_manager.h [blame]

// Copyright 2024 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_GRADUATION_GRADUATION_MANAGER_H_
#define ASH_PUBLIC_CPP_GRADUATION_GRADUATION_MANAGER_H_

#include <string>

#include "ash/public/cpp/ash_public_export.h"
#include "base/observer_list_types.h"

namespace base {
class Clock;
class TickClock;
}  // namespace base

namespace content {
class BrowserContext;
class StoragePartition;
class StoragePartitionConfig;
}  // namespace content

namespace signin {
class IdentityManager;
}  // namespace signin

namespace ash::graduation {

// A checked observer which receives notification of changes to the
// Graduation app.
class ASH_PUBLIC_EXPORT GraduationManagerObserver
    : public base::CheckedObserver {
 public:
  // Invoked when the session active state is changed.
  virtual void OnGraduationAppUpdate(bool enabled) = 0;
};

// Creates interface to access browser-side functionalities in
// GraduationManagerImpl.
class ASH_PUBLIC_EXPORT GraduationManager {
 public:
  static GraduationManager* Get();

  GraduationManager();
  GraduationManager(const GraduationManager&) = delete;
  GraduationManager& operator=(const GraduationManager&) = delete;
  virtual ~GraduationManager();

  // Returns the language code of the device's current locale.
  virtual std::string GetLanguageCode() const = 0;

  // Returns identity manager for given `context`.
  // Needed to avoid ash/chrome dependency.
  virtual signin::IdentityManager* GetIdentityManager(
      content::BrowserContext* context) = 0;

  //  Returns storage partition for a given `context` and
  //  `storage_partition_config`.
  virtual content::StoragePartition* GetStoragePartition(
      content::BrowserContext* context,
      const content::StoragePartitionConfig& storage_partition_config) = 0;

  // Adds the specified observer to be notified of updates to the Graduation
  // app.
  virtual void AddObserver(GraduationManagerObserver* observer) = 0;
  virtual void RemoveObserver(GraduationManagerObserver* observer) = 0;

  // Used by browser tests to set and fast-forward the system time.
  virtual void SetClocksForTesting(const base::Clock* clock,
                                   const base::TickClock* tick_clock) = 0;

  // Used by browser tests to resume the timer after it is paused (e.g. during
  // fast-forwarding).
  virtual void ResumeTimerForTesting() = 0;
};

}  // namespace ash::graduation

#endif  // ASH_PUBLIC_CPP_GRADUATION_GRADUATION_MANAGER_H_