Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: components/autofill/core/browser/options_util.cc

Issue 1137513002: Autofill: Add WalletIntegrationAvailable() to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/options_util.cc
diff --git a/components/autofill/core/browser/options_util.cc b/components/autofill/core/browser/options_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..62028b9ca59db8b0b33ddf0f9d086b6915185650
--- /dev/null
+++ b/components/autofill/core/browser/options_util.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 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/options_util.h"
+
+#include "base/prefs/pref_service.h"
+#include "components/autofill/core/browser/personal_data_manager.h"
+#include "components/autofill/core/common/autofill_pref_names.h"
+#include "components/sync_driver/sync_service.h"
+
+namespace autofill {
+
+bool WalletIntegrationAvailable(sync_driver::SyncService* sync_service,
+ PrefService* pref_service,
Evan Stade 2015/05/07 19:59:46 this should be const ref
bondd 2015/05/07 21:19:24 Done.
+ PersonalDataManager* personal_data_manager) {
Evan Stade 2015/05/07 19:59:46 this should be const ref
bondd 2015/05/07 21:19:24 Done.
+ if (!(sync_service && sync_service->IsSyncEnabledAndLoggedIn() &&
+ sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE))) {
+ return false;
+ }
+
+ DCHECK(personal_data_manager);
+ if (!personal_data_manager->IsExperimentalWalletIntegrationEnabled())
+ return false;
+
+ // If the user is signed in and the feature is enabled, but no data is being
+ // synced, hide the option. The user doesn't have a Wallet account. If the
+ // feature is disabled, we can't know, so show the checkbox.
+ DCHECK(pref_service);
+ if (!pref_service->GetBoolean(prefs::kAutofillWalletImportEnabled))
+ return true;
+
+ // If wallet is preferred but we haven't gotten the sync data yet, we don't
+ // know, so show the checkbox.
+ if (!sync_service->GetActiveDataTypes().Has(syncer::AUTOFILL_WALLET_DATA))
+ return true;
+
+ return personal_data_manager->HasServerData();
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698