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
|
// 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 CHROME_BROWSER_ASH_ACCOUNT_MANAGER_ACCOUNT_MANAGER_EDU_COEXISTENCE_CONTROLLER_H_
#define CHROME_BROWSER_ASH_ACCOUNT_MANAGER_ACCOUNT_MANAGER_EDU_COEXISTENCE_CONTROLLER_H_
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "components/account_id/account_id.h"
#include "components/account_manager_core/account.h"
#include "components/prefs/pref_change_registrar.h"
#include "google_apis/gaia/gaia_id.h"
class PrefRegistrySimple;
class Profile;
namespace account_manager {
class AccountManagerFacade;
class AccountManager;
}
namespace ash {
// Listens to changes to prefs::kEduCoexistenceToSVersion policy
// preference and invalidates secondary edu accounts with outdated terms of
// service version.
class EduCoexistenceConsentInvalidationController {
public:
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
EduCoexistenceConsentInvalidationController(
Profile* profile,
account_manager::AccountManager* account_manager,
account_manager::AccountManagerFacade* account_manager_facade,
const AccountId& device_account_id);
EduCoexistenceConsentInvalidationController(
const EduCoexistenceConsentInvalidationController&) = delete;
EduCoexistenceConsentInvalidationController& operator=(
const EduCoexistenceConsentInvalidationController&) = delete;
~EduCoexistenceConsentInvalidationController();
// Accesses the list from AccountManager to update the list of accounts stored
// in prefs::kEduCoexistenceToSAcceptedVersion.
void Init();
private:
// Removes accounts which may have been stored in pref but which have since
// been removed as a secondary account.
// Secondary edu accounts may have already been added to device prior to M88.
// Therefore, it updates the
// prefs::kEduCoexistenceToSAcceptedVersion pref to include those
// accounts.
void UpdateEduAccountsInTermsOfServicePref(
const std::vector<::account_manager::Account>& accounts);
void TermsOfServicePrefChanged();
void InvalidateEduAccounts(
const std::vector<GaiaId>& account_emails_to_invalidate,
const std::vector<::account_manager::Account>& accounts);
const raw_ptr<Profile> profile_;
const raw_ptr<account_manager::AccountManager> account_manager_;
const raw_ptr<account_manager::AccountManagerFacade> account_manager_facade_;
const AccountId device_account_id_;
PrefChangeRegistrar pref_change_registrar_;
base::WeakPtrFactory<EduCoexistenceConsentInvalidationController>
weak_factory_{this};
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_ACCOUNT_MANAGER_ACCOUNT_MANAGER_EDU_COEXISTENCE_CONTROLLER_H_
|