Commit 5e26b8a5 authored by estade's avatar estade Committed by Commit bot

Hide Autofill Wallet checkbox when not syncing autofill data.

If you are not signed into sync or have unchecked "Autofill" then the option should be hidden.

BUG=468987

Review URL: https://codereview.chromium.org/1020303007

Cr-Commit-Position: refs/heads/master@{#322243}
parent e778ea03
...@@ -11,12 +11,11 @@ ...@@ -11,12 +11,11 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autofill/options_util.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/autofill/core/browser/autofill_country.h" #include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/autofill_type.h"
...@@ -339,13 +338,7 @@ static jboolean IsAutofillManaged(JNIEnv* env, jclass clazz) { ...@@ -339,13 +338,7 @@ static jboolean IsAutofillManaged(JNIEnv* env, jclass clazz) {
// Returns whether the Wallet import feature is available. // Returns whether the Wallet import feature is available.
static jboolean IsWalletImportFeatureAvailable(JNIEnv* env, jclass clazz) { static jboolean IsWalletImportFeatureAvailable(JNIEnv* env, jclass clazz) {
// TODO(estade): what to do in the IsManaged case? return WalletIntegrationAvailableForProfile(GetProfile());
ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile());
PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile(
GetProfile());
return service && service->IsSyncEnabledAndLoggedIn() &&
pdm->IsExperimentalWalletIntegrationEnabled();
} }
// Returns whether the Wallet import feature is enabled. // Returns whether the Wallet import feature is enabled.
......
// 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 "chrome/browser/autofill/options_util.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
namespace autofill {
bool WalletIntegrationAvailableForProfile(Profile* profile) {
// TODO(estade): what to do in the IsManaged case?
ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
return service && service->IsSyncEnabledAndLoggedIn() &&
service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE) &&
service->GetRegisteredDataTypes().Has(syncer::AUTOFILL_WALLET_DATA);
}
} // namespace autofill
// 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.
#ifndef CHROME_BROWSER_AUTOFILL_OPTIONS_UTIL_H_
#define CHROME_BROWSER_AUTOFILL_OPTIONS_UTIL_H_
class Profile;
namespace autofill {
// Decides whether the Autofill Wallet integration is available (i.e. can be
// enabled or disabled by the user).
bool WalletIntegrationAvailableForProfile(Profile* profile);
} // namespace autofill
#endif // CHROME_BROWSER_AUTOFILL_OPTIONS_UTIL_H_
...@@ -384,7 +384,7 @@ class ProfileSyncService : public ProfileSyncServiceBase, ...@@ -384,7 +384,7 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// Fills state_map with a map of current data types that are possible to // Fills state_map with a map of current data types that are possible to
// sync, as well as their states. // sync, as well as their states.
void GetDataTypeControllerStates( void GetDataTypeControllerStates(
sync_driver::DataTypeController::StateMap* state_map) const; sync_driver::DataTypeController::StateMap* state_map) const;
// Disables sync for user. Use ShowLoginDialog to enable. // Disables sync for user. Use ShowLoginDialog to enable.
virtual void DisableForUser(); virtual void DisableForUser();
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/autofill/options_util.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -375,10 +376,10 @@ void AutofillOptionsHandler::GetLocalizedValues( ...@@ -375,10 +376,10 @@ void AutofillOptionsHandler::GetLocalizedValues(
Profile::FromWebUI(web_ui())); Profile::FromWebUI(web_ui()));
if (service) if (service)
observer_.Add(service); observer_.Add(service);
localized_strings->SetBoolean(
"autofillWalletIntegrationAvailable", localized_strings->SetBoolean("autofillWalletIntegrationAvailable",
service && service->IsSyncEnabledAndLoggedIn() && autofill::WalletIntegrationAvailableForProfile(
personal_data_->IsExperimentalWalletIntegrationEnabled()); Profile::FromWebUI(web_ui())));
} }
void AutofillOptionsHandler::InitializeHandler() { void AutofillOptionsHandler::InitializeHandler() {
...@@ -443,12 +444,10 @@ void AutofillOptionsHandler::OnPersonalDataChanged() { ...@@ -443,12 +444,10 @@ void AutofillOptionsHandler::OnPersonalDataChanged() {
} }
void AutofillOptionsHandler::OnStateChanged() { void AutofillOptionsHandler::OnStateChanged() {
ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(
Profile::FromWebUI(web_ui()));
web_ui()->CallJavascriptFunction( web_ui()->CallJavascriptFunction(
"AutofillOptions.walletIntegrationAvailableStateChanged", "AutofillOptions.walletIntegrationAvailableStateChanged",
base::FundamentalValue(service && service->IsSyncEnabledAndLoggedIn())); base::FundamentalValue(autofill::WalletIntegrationAvailableForProfile(
Profile::FromWebUI(web_ui()))));
} }
void AutofillOptionsHandler::SetAddressOverlayStrings( void AutofillOptionsHandler::SetAddressOverlayStrings(
......
...@@ -192,6 +192,8 @@ ...@@ -192,6 +192,8 @@
'browser/app_mode/app_mode_utils.h', 'browser/app_mode/app_mode_utils.h',
'browser/autofill/android/personal_data_manager_android.cc', 'browser/autofill/android/personal_data_manager_android.cc',
'browser/autofill/android/personal_data_manager_android.h', 'browser/autofill/android/personal_data_manager_android.h',
'browser/autofill/options_util.cc',
'browser/autofill/options_util.h',
'browser/autofill/personal_data_manager_factory.cc', 'browser/autofill/personal_data_manager_factory.cc',
'browser/autofill/personal_data_manager_factory.h', 'browser/autofill/personal_data_manager_factory.h',
'browser/autofill/risk_util.cc', 'browser/autofill/risk_util.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment