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
|
// 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_CHROMEOS_POLICY_DLP_DLP_RULES_MANAGER_IMPL_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_RULES_MANAGER_IMPL_H_
#include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager.h"
#include <map>
#include <memory>
#include <set>
#include "base/scoped_observation.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/dbus/dlp/dlp_client.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/url_matcher/url_matcher.h"
class GURL;
class PrefRegistrySimple;
namespace data_controls {
class DlpReportingManager;
} // namespace data_controls
namespace policy {
class DlpFilesController;
class DlpRulesManagerImpl : public DlpRulesManager,
public chromeos::DlpClient::Observer {
public:
using RuleId = int;
using UrlConditionId = base::MatcherStringPattern::ID;
explicit DlpRulesManagerImpl(PrefService* local_state, Profile* profile);
~DlpRulesManagerImpl() override;
// Registers the policy pref.
static void RegisterPrefs(PrefRegistrySimple* registry);
// DlpRulesManager:
Level IsRestrictedComponent(const GURL& source,
const data_controls::Component& destination,
Restriction restriction,
std::string* out_source_pattern,
RuleMetadata* out_rule_metadata) const override;
AggregatedComponents GetAggregatedComponents(
const GURL& source,
Restriction restriction) const override;
bool IsReportingEnabled() const override;
data_controls::DlpReportingManager* GetReportingManager() const override;
DlpFilesController* GetDlpFilesController() const override;
size_t GetClipboardCheckSizeLimitInBytes() const override;
bool IsFilesPolicyEnabled() const override;
// chromeos::DlpClient::Observer overrides:
void DlpDaemonRestarted() override;
// KeyedService overrides:
void Shutdown() override;
protected:
friend class DlpRulesManagerFactory;
private:
void OnDataLeakPreventionRulesUpdate() override;
// Used to track kDlpRulesList local state pref.
PrefChangeRegistrar pref_change_registrar_;
// Map from the components to their configured rules IDs.
std::map<data_controls::Component, std::set<RuleId>> components_rules_;
// Vector of source urls conditions.
url_matcher::URLMatcherConditionSet::Vector src_conditions_;
// Vector of destination urls conditions.
url_matcher::URLMatcherConditionSet::Vector dst_conditions_;
// System-wide singleton instantiated when required by rules configuration.
std::unique_ptr<data_controls::DlpReportingManager> reporting_manager_;
// System-wide singleton instantiated when there are rules involving files.
std::unique_ptr<DlpFilesController> files_controller_;
// Observe to re-notify DLP daemon in case of restart.
base::ScopedObservation<chromeos::DlpClient, chromeos::DlpClient::Observer>
dlp_client_observation_{this};
};
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_DLP_DLP_RULES_MANAGER_IMPL_H_
|