1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_STATUS_COLLECTOR_ENTERPRISE_ACTIVITY_STORAGE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_STATUS_COLLECTOR_ENTERPRISE_ACTIVITY_STORAGE_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/macros.h"
12 #include "base/time/time.h"
13 #include "chrome/browser/chromeos/policy/status_collector/activity_storage.h"
14 #include "chrome/browser/chromeos/policy/status_collector/interval_map.h"
15 
16 class PrefService;
17 
18 namespace policy {
19 
20 class EnterpriseActivityStorage : public ActivityStorage {
21  public:
22   // Forwards the arguments to ActivityStorage.
23   EnterpriseActivityStorage(PrefService* pref_service,
24                             const std::string& pref_name);
25   EnterpriseActivityStorage(const EnterpriseActivityStorage&) = delete;
26   EnterpriseActivityStorage& operator=(const EnterpriseActivityStorage&) =
27       delete;
28   ~EnterpriseActivityStorage() override;
29 
30   // Returns the list of stored activity periods. Aggregated data is returned
31   // without email addresses if |omit_emails| is set.
32   const std::map<std::string, Activities> GetFilteredActivityPeriods(
33       bool omit_emails) const;
34 
35   // Updates stored activity period according to users' reporting preferences.
36   // Removes user's email and aggregates the activity data if user's information
37   // should no longer be reported.
38   void FilterActivityPeriodsByUsers(
39       const std::vector<std::string>& reporting_users);
40 
41  private:
42   const std::map<std::string, ActivityStorage::Activities>
43   GetRedactedActivityPeriods(
44       const std::vector<std::string>& reporting_users) const;
45 };
46 
47 }  // namespace policy
48 
49 #endif  // CHROME_BROWSER_CHROMEOS_POLICY_STATUS_COLLECTOR_ENTERPRISE_ACTIVITY_STORAGE_H_
50