blob: 9bc27f627ddd7b317b44a7b70df0d02448b0feff (
plain)
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
|
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_ACCOUNT_CAPABILITIES_H_
#define COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_ACCOUNT_CAPABILITIES_H_
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "build/build_config.h"
#include "components/signin/public/identity_manager/tribool.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/scoped_java_ref.h"
#endif
namespace base {
class Value;
}
// Stores the information about account capabilities. Capabilities provide
// information about state and features of Gaia accounts.
class AccountCapabilities {
public:
AccountCapabilities();
~AccountCapabilities();
AccountCapabilities(const AccountCapabilities& other);
AccountCapabilities(AccountCapabilities&& other) noexcept;
AccountCapabilities& operator=(const AccountCapabilities& other);
AccountCapabilities& operator=(AccountCapabilities&& other) noexcept;
#if BUILDFLAG(IS_ANDROID)
static AccountCapabilities ConvertFromJavaAccountCapabilities(
JNIEnv* env,
const base::android::JavaRef<jobject>& accountCapabilities);
base::android::ScopedJavaLocalRef<jobject> ConvertToJavaAccountCapabilities(
JNIEnv* env) const;
#endif
// Chrome can offer extended promos for turning on Sync to accounts with this
// capability.
signin::Tribool can_offer_extended_chrome_sync_promos() const;
// Chrome can run privacy sandbox trials for accounts with this capability.
signin::Tribool can_run_chrome_privacy_sandbox_trials() const;
// Chrome can stop parental supervision if the user chooses to do so with
// this capability.
signin::Tribool can_stop_parental_supervision() const;
// Chrome applies parental controls to accounts with this capability.
signin::Tribool is_subject_to_parental_controls() const;
// Whether none of the capabilities has `signin::Tribool::kUnknown`.
bool AreAllCapabilitiesKnown() const;
// Updates the capability state value for keys in `other`. If a value is
// `signin::Tribool::kUnknown` in `other` the corresponding key will not
// be updated in order to avoid overriding known values.
bool UpdateWith(const AccountCapabilities& other);
bool operator==(const AccountCapabilities& other) const;
bool operator!=(const AccountCapabilities& other) const;
private:
friend absl::optional<AccountCapabilities> AccountCapabilitiesFromValue(
const base::Value& account_capabilities);
friend class AccountCapabilitiesFetcherGaia;
friend class AccountCapabilitiesTestMutator;
friend class AccountTrackerService;
// Returns the capability state using the service name.
signin::Tribool GetCapabilityByName(const std::string& name) const;
// Returns the list of account capability service names supported in Chrome.
static const std::vector<std::string>& GetSupportedAccountCapabilityNames();
base::flat_map<std::string, bool> capabilities_map_;
};
#endif // COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_ACCOUNT_CAPABILITIES_H_
|