File: crostini_pref_names.cc

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 (137 lines) | stat: -rw-r--r-- 6,806 bytes parent folder | download | duplicates (6)
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
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ash/crostini/crostini_pref_names.h"

#include <memory>
#include <utility>

#include "base/files/file_path.h"
#include "base/values.h"
#include "components/guest_os/guest_os_prefs.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"

namespace crostini {
namespace prefs {

// A boolean preference representing whether a user has opted in to use
// Crostini (Called "Linux Apps" in UI).
const char kCrostiniEnabled[] = "crostini.enabled";
// A list representing the intent to create containers with
// certain specifications. This will also store whether or not it's been
// successfully run. If so, it will only remain as a historical record.

// Keys for the kCrostiniCreateOptions Dictionary stored for each container
// CreateOptions.
const char kCrostiniCreateOptionsSharePathsKey[] = "share_paths";
const char kCrostiniCreateOptionsContainerUsernameKey[] = "container_username";
const char kCrostiniCreateOptionsDiskSizeBytesKey[] = "disk_size_bytes";
const char kCrostiniCreateOptionsImageServerUrlKey[] = "image_server_url";
const char kCrostiniCreateOptionsImageAliasKey[] = "image_alias";
const char kCrostiniCreateOptionsAnsiblePlaybookKey[] = "ansible_playbook";
const char kCrostiniCreateOptionsUsedKey[] = "used";

// List of USB devices with their system guid, a name/description and their
// enabled state for use with Crostini.
const char kCrostiniSharedUsbDevices[] = "crostini.shared_usb_devices";
// Boolean preferences indicating whether Crostini is allowed to use mic.
const char kCrostiniMicAllowed[] = "crostini.mic_allowed";

// A boolean preference representing a user level enterprise policy to enable
// Crostini use.
const char kUserCrostiniAllowedByPolicy[] = "crostini.user_allowed_by_policy";
// A boolean preference representing a user level enterprise policy to enable
// the crostini export / import UI.
const char kUserCrostiniExportImportUIAllowedByPolicy[] =
    "crostini.user_export_import_ui_allowed_by_policy";
// A boolean preference representing a user level enterprise policy to enable
// VM management CLI.
const char kVmManagementCliAllowedByPolicy[] =
    "crostini.vm_management_cli_allowed_by_policy";
// A boolean preference representing a user level enterprise policy to allow
// Crostini root access in the default Crostini VM.
// TODO(crbug.com/41470758): The features that have to be implemented.
const char kUserCrostiniRootAccessAllowedByPolicy[] =
    "crostini.user_root_access_allowed_by_policy";
// A file path preference representing a user level enterprise policy that
// specifies Ansible playbook to be applied to the default Crostini container.
// Value is empty when there is no playbook to be applied specified though
// policy.
const char kCrostiniAnsiblePlaybookFilePath[] =
    "crostini.ansible_playbook_file_path";
// A boolean preference representing whether default Crostini container is
// successfully configured by kCrostiniAnsiblePlaybook user policy.
const char kCrostiniDefaultContainerConfigured[] =
    "crostini.default_container_configured";
// A boolean preference representing a user level enterprise policy to allow
// port forwarding into Crostini.
const char kCrostiniPortForwardingAllowedByPolicy[] =
    "crostini.port_forwarding_allowed_by_policy";
// A boolean preference representing a user level enterprise policy to allow
// SSH in Terminal System App.
const char kTerminalSshAllowedByPolicy[] =
    "crostini.terminal_ssh_allowed_by_policy";

// A boolean preference controlling Crostini usage reporting.
const char kReportCrostiniUsageEnabled[] = "crostini.usage_reporting_enabled";
// Preferences used to store last launch information for reporting:
// Last launch Termina component version.
const char kCrostiniLastLaunchTerminaComponentVersion[] =
    "crostini.last_launch.version";
// Last launch Termina kernel version.
const char kCrostiniLastLaunchTerminaKernelVersion[] =
    "crostini.last_launch.vm_kernel_version";
// The start of a three day window of the last app launch
// stored as Java time (ms since epoch).
const char kCrostiniLastLaunchTimeWindowStart[] =
    "crostini.last_launch.time_window_start";
// The value of the last sample of the disk space used by Crostini.
const char kCrostiniLastDiskSize[] = "crostini.last_disk_size";
// A dictionary preference representing a user's settings of forwarded ports
// to Crostini.
const char kCrostiniPortForwarding[] = "crostini.port_forwarding.ports";

// An integer preference indicating the allowance policy for ADB sideloading,
// with 0 meaning disallowed and 1 meaning allowed
const char kCrostiniArcAdbSideloadingUserPref[] =
    "crostini.arc_adb_sideloading.user_pref";

// Prefix for storing engagement time data, per GuestOSEngagementMetrics.
const char kEngagementPrefsPrefix[] = "crostini.metrics";

void RegisterProfilePrefs(PrefRegistrySimple* registry) {
  registry->RegisterBooleanPref(kCrostiniEnabled, false);
  registry->RegisterListPref(kCrostiniPortForwarding);
  registry->RegisterListPref(kCrostiniSharedUsbDevices);
  registry->RegisterBooleanPref(kCrostiniMicAllowed, false);
  registry->RegisterBooleanPref(kTerminalSshAllowedByPolicy, true);
  registry->RegisterBooleanPref(crostini::prefs::kReportCrostiniUsageEnabled,
                                false);
  registry->RegisterStringPref(kCrostiniLastLaunchTerminaComponentVersion,
                               std::string());
  registry->RegisterStringPref(kCrostiniLastLaunchTerminaKernelVersion,
                               std::string());
  registry->RegisterInt64Pref(kCrostiniLastLaunchTimeWindowStart, 0u);
  registry->RegisterInt64Pref(kCrostiniLastDiskSize, 0u);
  registry->RegisterBooleanPref(kUserCrostiniAllowedByPolicy, true);
  registry->RegisterBooleanPref(kUserCrostiniExportImportUIAllowedByPolicy,
                                true);
  registry->RegisterBooleanPref(kVmManagementCliAllowedByPolicy, true);
  registry->RegisterBooleanPref(kUserCrostiniRootAccessAllowedByPolicy, true);
  registry->RegisterBooleanPref(kCrostiniPortForwardingAllowedByPolicy, true);
  registry->RegisterFilePathPref(kCrostiniAnsiblePlaybookFilePath,
                                 base::FilePath());
  registry->RegisterBooleanPref(kCrostiniDefaultContainerConfigured, false);

  registry->RegisterIntegerPref(
      kCrostiniArcAdbSideloadingUserPref,
      static_cast<int>(CrostiniArcAdbSideloadingUserAllowanceMode::kDisallow));

  guest_os::prefs::RegisterEngagementProfilePrefs(registry,
                                                  kEngagementPrefsPrefix);
}

}  // namespace prefs
}  // namespace crostini