Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / browser / options_util.cc
blobb162d7767394ebb10874c228efd1a969aab0049e
1 // Copyright 2015 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.
5 #include "components/autofill/core/browser/options_util.h"
7 #include "base/prefs/pref_service.h"
8 #include "components/autofill/core/browser/personal_data_manager.h"
9 #include "components/autofill/core/common/autofill_pref_names.h"
10 #include "components/sync_driver/sync_service.h"
12 namespace autofill {
14 bool WalletIntegrationAvailable(
15 sync_driver::SyncService* sync_service,
16 const PrefService& pref_service,
17 const PersonalDataManager& personal_data_manager) {
18 if (!(sync_service && sync_service->CanSyncStart() &&
19 sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE))) {
20 return false;
23 if (!personal_data_manager.IsExperimentalWalletIntegrationEnabled())
24 return false;
26 // If the user is signed in and the feature is enabled, but no data is being
27 // synced, hide the option. The user doesn't have a Wallet account. If the
28 // feature is disabled, we can't know, so show the checkbox.
29 if (!pref_service.GetBoolean(prefs::kAutofillWalletImportEnabled))
30 return true;
32 // If wallet is preferred but we haven't gotten the sync data yet, we don't
33 // know, so show the checkbox.
34 if (!sync_service->GetActiveDataTypes().Has(syncer::AUTOFILL_WALLET_DATA))
35 return true;
37 return personal_data_manager.HasServerData();
40 } // namespace autofill