Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / autofill / options_util.cc
blob389d40e44beeee39ddb5f535469fe67f4b4c8a45
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 "chrome/browser/autofill/options_util.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/autofill/personal_data_manager_factory.h"
9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/sync/profile_sync_service_factory.h"
11 #include "components/autofill/core/browser/personal_data_manager.h"
12 #include "components/autofill/core/common/autofill_pref_names.h"
14 namespace autofill {
16 bool WalletIntegrationAvailableForProfile(Profile* profile) {
17 ProfileSyncService* service =
18 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
19 if (!(service && service->IsSyncEnabledAndLoggedIn() &&
20 service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE))) {
21 return false;
24 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile(profile);
25 if (!pdm->IsExperimentalWalletIntegrationEnabled())
26 return false;
28 // If the user is signed in and the feature is enabled, but no data is being
29 // synced, hide the option. The user doesn't have a Wallet account. If the
30 // feature is disabled, we can't know, so show the checkbox.
31 if (!profile->GetPrefs()->GetBoolean(prefs::kAutofillWalletImportEnabled))
32 return true;
34 // If wallet is preferred but we haven't gotten the sync data yet, we don't
35 // know, so show the checkbox.
36 if (!service->GetActiveDataTypes().Has(syncer::AUTOFILL_WALLET_DATA))
37 return true;
39 return pdm->HasServerData();
42 } // namespace autofill