summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/autofill_address_policy_handler.cc
blob: 5afc719388c17e152bdc2537683e1b67bcaea2c8 (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
// Copyright 2018 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.

#include "components/autofill/core/browser/autofill_address_policy_handler.h"

#include "base/values.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_value_map.h"

namespace autofill {

AutofillAddressPolicyHandler::AutofillAddressPolicyHandler()
    : TypeCheckingPolicyHandler(policy::key::kAutofillAddressEnabled,
                                base::Value::Type::BOOLEAN) {}

AutofillAddressPolicyHandler::~AutofillAddressPolicyHandler() {}

void AutofillAddressPolicyHandler::ApplyPolicySettings(
    const policy::PolicyMap& policies,
    PrefValueMap* prefs) {
  const base::Value* value = policies.GetValue(policy_name());
  bool autofill_profile_enabled;
  if (value && value->GetAsBoolean(&autofill_profile_enabled) &&
      !autofill_profile_enabled) {
    prefs->SetBoolean(autofill::prefs::kAutofillProfileEnabled, false);
  }
}

}  // namespace autofill