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
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112

ash / public / cpp / holding_space / holding_space_prefs.h [blame]

// Copyright 2020 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_HOLDING_SPACE_HOLDING_SPACE_PREFS_H_
#define ASH_PUBLIC_CPP_HOLDING_SPACE_HOLDING_SPACE_PREFS_H_

#include <optional>

#include "ash/public/cpp/ash_public_export.h"
#include "base/functional/callback_forward.h"

class PrefChangeRegistrar;
class PrefRegistrySimple;
class PrefService;

namespace base {
class Time;
}  // namespace base

namespace ash::holding_space_prefs {

// Registers holding space profile preferences to `registry`.
ASH_PUBLIC_EXPORT void RegisterProfilePrefs(PrefRegistrySimple* registry);

// Resets all preferences to their default values.
ASH_PUBLIC_EXPORT void ResetProfilePrefsForTesting(PrefService* prefs);

// Adds `callback` to `registrar` to be invoked on changes to previews enabled.
ASH_PUBLIC_EXPORT void AddPreviewsEnabledChangedCallback(
    PrefChangeRegistrar* registrar,
    base::RepeatingClosure callback);

// Adds `callback` to `registrar` to be invoked on changes to whether the
// suggestions section should be expanded.
ASH_PUBLIC_EXPORT void AddSuggestionsExpandedChangedCallback(
    PrefChangeRegistrar* registrar,
    base::RepeatingClosure callback);

// Adds `callback` to `registrar` to be invoked on changes to time of first add.
ASH_PUBLIC_EXPORT void AddTimeOfFirstAddChangedCallback(
    PrefChangeRegistrar* registrar,
    base::RepeatingClosure callback);

// Adds `callback` to `registrar` to be invoked on changes to time of first pin.
ASH_PUBLIC_EXPORT void AddTimeOfFirstPinChangedCallback(
    PrefChangeRegistrar* registrar,
    base::RepeatingClosure callback);

// Returns whether previews are enabled.
ASH_PUBLIC_EXPORT bool IsPreviewsEnabled(PrefService* prefs);

// Sets whether previews are `enabled`.
ASH_PUBLIC_EXPORT void SetPreviewsEnabled(PrefService* prefs, bool enabled);

// Returns whether suggestions are expanded.
ASH_PUBLIC_EXPORT bool IsSuggestionsExpanded(PrefService* prefs);

// Sets whether suggestions are `expanded`.
ASH_PUBLIC_EXPORT void SetSuggestionsExpanded(PrefService* prefs,
                                              bool expanded);

// Returns the time when a holding space item was first added. Note that if the
// time of first add is unmarked, `std::nullopt` is returned.
ASH_PUBLIC_EXPORT std::optional<base::Time> GetTimeOfFirstAdd(
    PrefService* prefs);

// Marks the time when the first holding space item was added. If the time of
// first add was previously marked, this no-ops and returns false.
ASH_PUBLIC_EXPORT bool MarkTimeOfFirstAdd(PrefService* prefs);

// Returns the time when holding space first became available. Note that if the
// time of first availability is unmarked, `std::nullopt` is returned.
ASH_PUBLIC_EXPORT std::optional<base::Time> GetTimeOfFirstAvailability(
    PrefService* prefs);

// Marks time when holding space first became available. If the time of first
// availability was previously marked, this no-ops and returns false.
ASH_PUBLIC_EXPORT bool MarkTimeOfFirstAvailability(PrefService* prefs);

// Returns the time when holding space was first entered. Note that if the time
// of first entry is unmarked, `std::nullopt` is returned.
ASH_PUBLIC_EXPORT std::optional<base::Time> GetTimeOfFirstEntry(
    PrefService* prefs);

// Marks time when holding space was first entered. If the time of first entry
// was previously marked, this no-ops and returns false.
ASH_PUBLIC_EXPORT bool MarkTimeOfFirstEntry(PrefService* prefs);

// Returns the time when the first pin to holding space occurred. Note that if
// the time of first pin is unmarked, `std::nullopt` is returned.
ASH_PUBLIC_EXPORT std::optional<base::Time> GetTimeOfFirstPin(
    PrefService* prefs);

// Marks time of when the first pin to holding space occurred. If time of first
// pin was previously marked, this no-ops and returns false.
ASH_PUBLIC_EXPORT bool MarkTimeOfFirstPin(PrefService* prefs);

// Returns the time when the Files app chip in the holding space pinned files
// section placeholder was first pressed. Note that if the time of first press
// is unmarked, `std::nullopt` is returned.
ASH_PUBLIC_EXPORT std::optional<base::Time> GetTimeOfFirstFilesAppChipPress(
    PrefService* prefs);

// Marks the time when the Files app chip in the holding space pinned files
// section placeholder was first pressed. If the time of first press was
// previously marked, this no-ops and returns false.
ASH_PUBLIC_EXPORT bool MarkTimeOfFirstFilesAppChipPress(PrefService* prefs);

}  // namespace ash::holding_space_prefs

#endif  // ASH_PUBLIC_CPP_HOLDING_SPACE_HOLDING_SPACE_PREFS_H_