blob: 4272c8e7eb10a5dcd30bc960d655e995063ced89 (
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
|
// Copyright 2020 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/address_profile_save_manager.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/common/autofill_features.h"
namespace autofill {
AddressProfileSaveManager::AddressProfileSaveManager(
AutofillClient* client,
PersonalDataManager* personal_data_manager)
: client_(client), personal_data_manager_(personal_data_manager) {}
AddressProfileSaveManager::~AddressProfileSaveManager() = default;
void AddressProfileSaveManager::SaveProfile(const AutofillProfile& profile) {
if (!personal_data_manager_)
return;
if (base::FeatureList::IsEnabled(
features::kAutofillAddressProfileSavePrompt)) {
client_->ConfirmSaveAddressProfile(
profile,
base::BindOnce(&AddressProfileSaveManager::SaveProfilePromptCallback,
weak_ptr_factory_.GetWeakPtr()));
return;
}
SaveProfileInternal(profile);
}
void AddressProfileSaveManager::SaveProfileInternal(
const AutofillProfile& profile) {
personal_data_manager_->SaveImportedProfile(profile);
}
void AddressProfileSaveManager::SaveProfilePromptCallback(
AutofillClient::SaveAddressProfileOfferUserDecision user_decision,
AutofillProfile profile) {
switch (user_decision) {
case AutofillClient::SaveAddressProfileOfferUserDecision::kAccepted:
case AutofillClient::SaveAddressProfileOfferUserDecision::kEdited:
personal_data_manager_->SaveImportedProfile(profile);
break;
case AutofillClient::SaveAddressProfileOfferUserDecision::kDeclined:
case AutofillClient::SaveAddressProfileOfferUserDecision::kIgnored:
break;
}
}
} // namespace autofill
|