File: policy_utils.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (147 lines) | stat: -rw-r--r-- 5,212 bytes parent folder | download | duplicates (5)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// 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 CHROME_BROWSER_ASH_POLICY_SKYVAULT_POLICY_UTILS_H_
#define CHROME_BROWSER_ASH_POLICY_SKYVAULT_POLICY_UTILS_H_

#include <optional>

#include "base/files/file_path.h"
#include "base/time/time.h"

class Profile;

namespace policy::local_user_files {

extern const char kGoogleDrivePolicyVariableName[],
    kOneDrivePolicyVariableName[];

// Enum describing where the admin configured the files to be saved.
enum class FileSaveDestination {
  kNotSpecified = 0,
  kDownloads = 1,
  kGoogleDrive = 2,
  kOneDrive = 3,
  kMaxValue = kOneDrive,
};

// Supported migration destination options.
enum class MigrationDestination {
  kNotSpecified,
  kGoogleDrive,
  kOneDrive,
  kDelete,
  kMaxValue = kDelete,
};

// Categories of errors that can occur during the file upload process.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(MigrationUploadError)
enum class MigrationUploadError {
  kUnexpectedError = 0,     // An unexpected error occurred, e.g. no profile.
  kServiceUnavailable = 1,  // The cloud provider is not accessible.
  kCreateFolderFailed = 2,  // Creating a folder in Google Drive failed.
  kSyncFailed = 3,          // Syncing the file to Google Drive failed.
  kCloudQuotaFull = 4,      // No space on the cloud provider.
  kFileNotFound = 5,        // File deleted before finishing the upload.
  kInvalidURL = 6,          // OneDrive rejected the request.
  kCopyFailed = 7,          // Generic catch-all copy error.
  kDeleteFailed = 8,        // Deleting the file after upload failed.
  kAuthRequired = 9,        // OneDrive reauthentication required.
  kMoveFailed = 10,         // Generic catch-all move error.
  kCancelled = 11,          // Upload explicitly cancelled.
  kNetworkError = 12,       // Interruption due to disconnected network.
  kReconnectTimeout = 13,   // Upload failed after a reconnection timeout.
  kMaxValue = kReconnectTimeout,
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/enterprise/enums.xml:EnterpriseSkyVaultMigrationUploadError)

// The event or action that triggers an upload to the cloud.
enum class UploadTrigger {
  kDownload = 0,
  kScreenCapture = 1,
  kMigration = 2,
  kMaxValue = kMigration,
};

// Possible states of the migration. Persisted to a pref.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(State)
enum class State {
  kUninitialized = 0,
  kPending = 1,
  kInProgress = 2,
  kCleanup = 3,
  kCompleted = 4,
  kFailure = 5,
  kMaxValue = kFailure,
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/enterprise/enums.xml:EnterpriseSkyVaultMigrationState)

// The context, or the part of the migration process in which an unexpected
// state transition happens.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(StateErrorContext)
enum class StateErrorContext {
  kShowDialog = 0,  //
  kDialogClick = 1,
  kSkipTimeout = 2,
  kTimeout = 3,
  kListFiles = 4,
  kMigrationStart = 5,
  kMigrationDone = 6,
  kCleanupStart = 7,
  kCleanupDone = 8,
  kMaxValue = kCleanupDone,
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/enterprise/enums.xml:EnterpriseSkyVaultMigrationStateErrorContext)

// Possible actions a user can take in the migration dialog.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(DialogAction)
enum class DialogAction {
  kUploadNow = 0,    // `Upload now` button clicked
  kUploadLater = 1,  // No action or `Upload in <delay>` button clicked
  kMaxValue = kUploadLater,
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/enterprise/enums.xml:EnterpriseSkyVaultMigrationDialogAction)

// Returns whether local user files are enabled on the device by the flag and
// policy.
bool LocalUserFilesAllowed();

// Returns the `MigrationDestination` indicating where local files should be
// moved, or that they should be deleted. Returns `kNotSpecified` if the
// migration policy is unset or explicitly set to "read-only".
MigrationDestination GetMigrationDestination();

// Returns true if `destination` is set to a cloud location.
bool IsCloudDestination(MigrationDestination destination);

// Get the destination where downloads are saved.
FileSaveDestination GetDownloadsDestination(Profile* profile);

// Get the destination where screen captures are saved.
FileSaveDestination GetScreenCaptureDestination(Profile* profile);

// Returns whether `download` should be saved to tmp/ directory.
bool DownloadToTemp(Profile* profile);

// Returns the path of MyFiles folder for `profile`.
base::FilePath GetMyFilesPath(Profile* profile);

// Returns the scheduled start time for local file migration or deletion.
std::optional<base::Time> GetMigrationStartTime(Profile* profile);

}  // namespace policy::local_user_files

#endif  // CHROME_BROWSER_ASH_POLICY_SKYVAULT_POLICY_UTILS_H_