diff options
author | jdonnelly <jdonnelly@chromium.org> | 2016-01-15 14:05:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-15 22:06:28 +0000 |
commit | b4ddb6b439ded116b61d77dc6ed0f0e8a3bad4b9 (patch) | |
tree | 08f692d8270dac664bfaefb40aaf86bddba91591 | |
parent | 73f33b9bb4e534d75915757b7bf746349f817663 (diff) | |
download | chromium_src-b4ddb6b439ded116b61d77dc6ed0f0e8a3bad4b9.zip chromium_src-b4ddb6b439ded116b61d77dc6ed0f0e8a3bad4b9.tar.gz chromium_src-b4ddb6b439ded116b61d77dc6ed0f0e8a3bad4b9.tar.bz2 |
Move Autofill Payments integration checkbox to the sync settings page.
Based on results of discussions between privacy, pm, and UI review. Mock available at: https://screenshot.googleplex.com/59eiPNOvZAS.png
Notes on the implementation:
The mechanism for handling the availability of the payments integration setting has changed. Previously it was changed by events from the personal data manager and the sync service. This was because it depended on the state of those services and because the setting was on a different page than the sync settings.
With the new upload feature, the availability of the integration setting depends *only* on whether Autofill sync is enabled. (It no longer depends on the rollout flag governed by the sync service nor on whether the user currently has server cards in the personal data manager.)
Because of this and since the setting is on the same page/dialog as the Autofill sync setting, the availability of the integration setting can simply be changed in a click handler on the Autofill sync setting.
"Availability" is also now implemented via disabling (greying out) rather than visibility to avoid a dialog size change and relayout whenever the user clicks the Autofill sync setting.
One final detail: on the Autofill settings dialog, the magic "pref=" mechanism was used to read/write the integration setting. Because the sync settings dialog uses an ok/cancel design, we can't immediately write the value of the checkbox to the setting. Instead, it's manually set along with the rest of the sync settings after the user clicks ok.
BUG=535784
Review URL: https://codereview.chromium.org/1578173005
Cr-Commit-Position: refs/heads/master@{#369857}
10 files changed, 147 insertions, 164 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 952ab19..352225f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -9521,8 +9521,8 @@ I don't think this site should be blocked! <message name="IDS_AUTOFILL_ADD_CREDITCARD_CAPTION" desc="The caption on the edit Autofill credit card dialog the new entry."> Add a credit card </message> - <message name="IDS_AUTOFILL_USE_WALLET_DATA" desc="The text for the checkbox that controls the Autofill/Wallet integration feature."> - Sync credit cards and addresses using Google Payments + <message name="IDS_AUTOFILL_USE_PAYMENTS_DATA" desc="The text for the checkbox that controls the Autofill/Payments integration feature."> + Credit cards and addresses using Google Payments </message> <message name="IDS_AUTOFILL_FIELD_LABEL_EMAIL" desc="The label of the Email entry."> diff --git a/chrome/browser/resources/options/autofill_options.html b/chrome/browser/resources/options/autofill_options.html index e018c50..cf33636 100644 --- a/chrome/browser/resources/options/autofill_options.html +++ b/chrome/browser/resources/options/autofill_options.html @@ -2,14 +2,6 @@ <div class="close-button"></div> <h1 i18n-content="autofillOptionsPage"></h1> <div class="content-area"> - <!-- TODO(estade): This checkbox shouldn't show if you're not signed into - sync. Or perhaps it should show with a link to go sign in with sync? - --> - <div id="autofill-wallet-setting-area" class="checkbox"> - <label> - <input pref="autofill.wallet_import_enabled" type="checkbox"> - <span i18n-content="autofillWalletOption"></span> - </div> <h3 i18n-content="autofillAddresses"></h3> <div class="settings-list"> <list id="address-list"></list> diff --git a/chrome/browser/resources/options/autofill_options.js b/chrome/browser/resources/options/autofill_options.js index bea6a1a..7f30000 100644 --- a/chrome/browser/resources/options/autofill_options.js +++ b/chrome/browser/resources/options/autofill_options.js @@ -76,9 +76,6 @@ cr.define('options', function() { return true; // Always follow the href }; - this.walletIntegrationAvailableStateChanged_( - loadTimeData.getBoolean('autofillWalletIntegrationAvailable')); - // TODO(jhawkins): What happens when Autofill is disabled whilst on the // Autofill options page? }, @@ -187,16 +184,6 @@ cr.define('options', function() { AutofillEditCreditCardOverlay.loadCreditCard(creditCard); PageManager.showPageByName('autofillEditCreditCard'); }, - - /** - * Toggles the visibility of the Wallet integration checkbox. - * @param {boolean} available Whether the user has the option of using - * Wallet data. - * @private - */ - walletIntegrationAvailableStateChanged_: function(available) { - $('autofill-wallet-setting-area').hidden = !available; - }, }; AutofillOptions.setAddressList = function(entries) { @@ -215,11 +202,6 @@ cr.define('options', function() { AutofillOptions.getInstance().showEditAddressOverlay_(address); }; - AutofillOptions.walletIntegrationAvailableStateChanged = function(available) { - AutofillOptions.getInstance(). - walletIntegrationAvailableStateChanged_(available); - }; - /** * @param {CreditCardData} creditCard */ diff --git a/chrome/browser/resources/options/sync_setup_overlay.css b/chrome/browser/resources/options/sync_setup_overlay.css index c04dc00..0b79504 100644 --- a/chrome/browser/resources/options/sync_setup_overlay.css +++ b/chrome/browser/resources/options/sync_setup_overlay.css @@ -42,10 +42,6 @@ padding: 10px; } -#sync-select-container { - margin-bottom: 10px; -} - #sync-instructions-container { line-height: 1.8em; margin-bottom: 30px; @@ -53,7 +49,7 @@ #choose-data-types-body { -webkit-column-count: 3; - margin: 10px 0; + margin: 10px 0 0 0; } #choose-data-types-body > .checkbox:first-child { diff --git a/chrome/browser/resources/options/sync_setup_overlay.html b/chrome/browser/resources/options/sync_setup_overlay.html index eee3199..8924552 100644 --- a/chrome/browser/resources/options/sync_setup_overlay.html +++ b/chrome/browser/resources/options/sync_setup_overlay.html @@ -106,6 +106,14 @@ </div> </div> </div> + <div id="payments-integration-setting-area" class="checkbox"> + <label> + <input id="payments-integration-checkbox" type="checkbox"> + <span i18n-content="enablePaymentsIntegration"></span> + </label> + <a i18n-values="href:autofillHelpURL" target="_blank" + i18n-content="learnMore"></a> + </div> <div id="customize-sync-encryption-new"> <hr> <h4 i18n-content="encryptionSectionTitle"></h4> diff --git a/chrome/browser/resources/options/sync_setup_overlay.js b/chrome/browser/resources/options/sync_setup_overlay.js index d05b778..50a297a 100644 --- a/chrome/browser/resources/options/sync_setup_overlay.js +++ b/chrome/browser/resources/options/sync_setup_overlay.js @@ -25,6 +25,7 @@ cr.exportPath('options'); * passwordsEnforced: boolean, * passwordsRegistered: boolean, * passwordsSynced: boolean, + * paymentsIntegrationEnabled: boolean, * preferencesEnforced: boolean, * preferencesRegistered: boolean, * preferencesSynced: boolean, @@ -159,6 +160,11 @@ cr.define('options', function() { $('use-default-link').onclick = function() { self.showSyncEverythingPage_(); }; + $('autofill-checkbox').onclick = function() { + var autofillSyncEnabled = $('autofill-checkbox').checked; + $('payments-integration-checkbox').checked = autofillSyncEnabled; + $('payments-integration-checkbox').disabled = !autofillSyncEnabled; + }; }, /** @private */ @@ -210,6 +216,7 @@ cr.define('options', function() { for (var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = value; } + $('payments-integration-checkbox').checked = value; }, /** @@ -330,6 +337,7 @@ cr.define('options', function() { options.DataTypeSelection.SYNC_EVERYTHING; var syncNothing = $('sync-select-datatypes').selectedIndex == options.DataTypeSelection.SYNC_NOTHING; + var autofillSynced = syncAll || $('autofill-checkbox').checked; var result = JSON.stringify({ 'syncAllDataTypes': syncAll, 'syncNothing': syncNothing, @@ -337,13 +345,15 @@ cr.define('options', function() { 'preferencesSynced': syncAll || $('preferences-checkbox').checked, 'themesSynced': syncAll || $('themes-checkbox').checked, 'passwordsSynced': syncAll || $('passwords-checkbox').checked, - 'autofillSynced': syncAll || $('autofill-checkbox').checked, + 'autofillSynced': autofillSynced, 'extensionsSynced': syncAll || $('extensions-checkbox').checked, 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, 'appsSynced': syncAll || $('apps-checkbox').checked, 'tabsSynced': syncAll || $('tabs-checkbox').checked, - 'wifiCredentialsSynced': syncAll || - $('wifi-credentials-checkbox').checked, + 'wifiCredentialsSynced': + syncAll || $('wifi-credentials-checkbox').checked, + 'paymentsIntegrationEnabled': syncAll || + (autofillSynced && $('payments-integration-checkbox').checked), 'encryptAllData': encryptAllData, 'usePassphrase': usePassphrase, 'isGooglePassphrase': googlePassphrase, @@ -367,6 +377,7 @@ cr.define('options', function() { for (var i = 0; i < configureElements.length; i++) configureElements[i].disabled = disabled; $('sync-select-datatypes').disabled = disabled; + $('payments-integration-checkbox').disabled = disabled; $('customize-link').hidden = disabled; $('customize-link').disabled = disabled; @@ -420,9 +431,15 @@ cr.define('options', function() { this.dataTypeBoxesChecked_['autofill-checkbox'] = args.autofillSynced; this.dataTypeBoxesDisabled_['autofill-checkbox'] = args.autofillEnforced; + this.dataTypeBoxesChecked_['payments-integration-checkbox'] = + args.autofillSynced && args.paymentsIntegrationEnabled; + this.dataTypeBoxesDisabled_['payments-integration-checkbox'] = + !args.autofillSynced; $('autofill-item').hidden = false; + $('payments-integration-setting-area').hidden = false; } else { $('autofill-item').hidden = true; + $('payments-integration-setting-area').hidden = true; } if (args.extensionsRegistered) { $('extensions-checkbox').checked = args.extensionsSynced; diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index 28fb030..388ad27 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc @@ -23,7 +23,6 @@ #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/autofill/country_combobox_model.h" #include "chrome/common/url_constants.h" #include "chrome/grit/chromium_strings.h" @@ -210,9 +209,7 @@ void SetCountryData(const PersonalDataManager& manager, namespace options { -AutofillOptionsHandler::AutofillOptionsHandler() - : personal_data_(NULL), observer_(this) { -} +AutofillOptionsHandler::AutofillOptionsHandler() : personal_data_(NULL) {} AutofillOptionsHandler::~AutofillOptionsHandler() { if (personal_data_) @@ -239,7 +236,6 @@ void AutofillOptionsHandler::GetLocalizedValues( { "editAddressTitle", IDS_AUTOFILL_EDIT_ADDRESS_CAPTION }, { "addCreditCardTitle", IDS_AUTOFILL_ADD_CREDITCARD_CAPTION }, { "editCreditCardTitle", IDS_AUTOFILL_EDIT_CREDITCARD_CAPTION }, - { "autofillWalletOption", IDS_AUTOFILL_USE_WALLET_DATA }, }; RegisterStrings(localized_strings, resources, arraysize(resources)); @@ -260,18 +256,6 @@ void AutofillOptionsHandler::GetLocalizedValues( localized_strings->SetString( "manageWalletPaymentMethodsUrl", autofill::wallet::GetManageInstrumentsUrl(0).spec()); - - // This is set in loadTimeData to minimize the chance of a load-time flash of - // content. - ProfileSyncService* service = - ProfileSyncServiceFactory::GetInstance()->GetForProfile( - Profile::FromWebUI(web_ui())); - if (service) - observer_.Add(service); - - localized_strings->SetBoolean("autofillWalletIntegrationAvailable", - autofill::WalletIntegrationAvailableForProfile( - Profile::FromWebUI(web_ui()))); } void AutofillOptionsHandler::InitializeHandler() { @@ -283,10 +267,6 @@ void AutofillOptionsHandler::InitializeHandler() { void AutofillOptionsHandler::InitializePage() { if (personal_data_) LoadAutofillData(); - - // Also update the visibility of the Wallet checkbox (which may have - // changed since the localized string dictionary was built). - OnStateChanged(); } void AutofillOptionsHandler::RegisterMessages() { @@ -323,14 +303,6 @@ void AutofillOptionsHandler::RegisterMessages() { // PersonalDataManagerObserver implementation: void AutofillOptionsHandler::OnPersonalDataChanged() { LoadAutofillData(); - OnStateChanged(); -} - -void AutofillOptionsHandler::OnStateChanged() { - web_ui()->CallJavascriptFunction( - "AutofillOptions.walletIntegrationAvailableStateChanged", - base::FundamentalValue(autofill::WalletIntegrationAvailableForProfile( - Profile::FromWebUI(web_ui())))); } void AutofillOptionsHandler::SetAddressOverlayStrings( diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.h b/chrome/browser/ui/webui/options/autofill_options_handler.h index 58d51e9..ef00b3e 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.h +++ b/chrome/browser/ui/webui/options/autofill_options_handler.h @@ -13,8 +13,6 @@ #include "base/scoped_observer.h" #include "chrome/browser/ui/webui/options/options_ui.h" #include "components/autofill/core/browser/personal_data_manager_observer.h" -#include "components/browser_sync/browser/profile_sync_service.h" -#include "components/sync_driver/sync_service_observer.h" namespace autofill { class AutofillProfile; @@ -29,8 +27,7 @@ class ListValue; namespace options { class AutofillOptionsHandler : public OptionsPageUIHandler, - public autofill::PersonalDataManagerObserver, - public sync_driver::SyncServiceObserver { + public autofill::PersonalDataManagerObserver { public: AutofillOptionsHandler(); ~AutofillOptionsHandler() override; @@ -44,9 +41,6 @@ class AutofillOptionsHandler : public OptionsPageUIHandler, // PersonalDataManagerObserver implementation. void OnPersonalDataChanged() override; - // sync_driver::SyncServiceObserver implementation. - void OnStateChanged() override; - private: FRIEND_TEST_ALL_PREFIXES(AutofillOptionsHandlerTest, AddressToDictionary); @@ -112,9 +106,6 @@ class AutofillOptionsHandler : public OptionsPageUIHandler, // Unowned pointer, may not be NULL. autofill::PersonalDataManager* personal_data_; - ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver> - observer_; - DISALLOW_COPY_AND_ASSIGN(AutofillOptionsHandler); }; diff --git a/chrome/browser/ui/webui/options/sync_setup_handler.cc b/chrome/browser/ui/webui/options/sync_setup_handler.cc index 6c7dac3..639f068 100644 --- a/chrome/browser/ui/webui/options/sync_setup_handler.cc +++ b/chrome/browser/ui/webui/options/sync_setup_handler.cc @@ -39,6 +39,8 @@ #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "chrome/grit/locale_settings.h" +#include "components/autofill/core/common/autofill_constants.h" +#include "components/autofill/core/common/autofill_pref_names.h" #include "components/browser_sync/browser/profile_sync_service.h" #include "components/google/core/browser/google_util.h" #include "components/signin/core/browser/signin_error_controller.h" @@ -76,6 +78,7 @@ struct SyncConfigInfo { bool sync_everything; bool sync_nothing; syncer::ModelTypeSet data_types; + bool payments_integration_enabled; std::string passphrase; bool passphrase_is_gaia; }; @@ -84,8 +87,8 @@ SyncConfigInfo::SyncConfigInfo() : encrypt_all(false), sync_everything(false), sync_nothing(false), - passphrase_is_gaia(false) { -} + payments_integration_enabled(false), + passphrase_is_gaia(false) {} SyncConfigInfo::~SyncConfigInfo() {} @@ -110,6 +113,13 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { DCHECK(!(config->sync_everything && config->sync_nothing)) << "syncAllDataTypes and syncNothing cannot both be true"; + if (!result->GetBoolean("paymentsIntegrationEnabled", + &config->payments_integration_enabled)) { + DLOG(ERROR) << "GetConfiguration() not passed a paymentsIntegrationEnabled " + << "value"; + return false; + } + syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap(); for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin(); @@ -180,6 +190,7 @@ void SyncSetupHandler::GetStaticLocalizedValues( localized_strings->SetString( "chooseDataTypesInstructions", GetStringFUTF16(IDS_SYNC_CHOOSE_DATATYPES_INSTRUCTIONS, product_name)); + localized_strings->SetString("autofillHelpURL", autofill::kHelpURL); localized_strings->SetString( "encryptionInstructions", GetStringFUTF16(IDS_SYNC_ENCRYPTION_INSTRUCTIONS, product_name)); @@ -218,56 +229,57 @@ void SyncSetupHandler::GetStaticLocalizedValues( "syncErrorHelpURL", chrome::kSyncErrorsHelpURL); static OptionsStringResource resources[] = { - { "syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE }, - { "syncSetupSpinnerTitle", IDS_SYNC_SETUP_SPINNER_TITLE }, - { "syncSetupTimeoutTitle", IDS_SYNC_SETUP_TIME_OUT_TITLE }, - { "syncSetupTimeoutContent", IDS_SYNC_SETUP_TIME_OUT_CONTENT }, - { "errorLearnMore", IDS_LEARN_MORE }, - { "cancel", IDS_CANCEL }, - { "loginSuccess", IDS_SYNC_SUCCESS }, - { "settingUp", IDS_SYNC_LOGIN_SETTING_UP }, - { "syncAllDataTypes", IDS_SYNC_EVERYTHING }, - { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, - { "syncNothing", IDS_SYNC_NOTHING }, - { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, - { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, - { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, - { "themes", IDS_SYNC_DATATYPE_THEMES }, - { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, - { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, - { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, - { "apps", IDS_SYNC_DATATYPE_APPS }, - { "wifiCredentials", IDS_SYNC_DATATYPE_WIFI_CREDENTIALS }, - { "openTabs", IDS_SYNC_DATATYPE_TABS }, - { "serviceUnavailableError", IDS_SYNC_SETUP_ABORTED_BY_PENDING_CLEAR }, - { "confirmLabel", IDS_SYNC_CONFIRM_PASSPHRASE_LABEL }, - { "emptyErrorMessage", IDS_SYNC_EMPTY_PASSPHRASE_ERROR }, - { "mismatchErrorMessage", IDS_SYNC_PASSPHRASE_MISMATCH_ERROR }, - { "customizeLinkLabel", IDS_SYNC_CUSTOMIZE_LINK_LABEL }, - { "confirmSyncPreferences", IDS_SYNC_CONFIRM_SYNC_PREFERENCES }, - { "syncEverything", IDS_SYNC_SYNC_EVERYTHING }, - { "useDefaultSettings", IDS_SYNC_USE_DEFAULT_SETTINGS }, - { "enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY }, - { "enterGooglePassphraseBody", IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY }, - { "passphraseLabel", IDS_SYNC_PASSPHRASE_LABEL }, - { "incorrectPassphrase", IDS_SYNC_INCORRECT_PASSPHRASE }, - { "passphraseWarning", IDS_SYNC_PASSPHRASE_WARNING }, - { "yes", IDS_SYNC_PASSPHRASE_CANCEL_YES }, - { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO }, - { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX }, - { "sectionExplicitMessagePostfix", - IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, - // TODO(rogerta): browser/resource/sync_promo/sync_promo.html and related - // file may not be needed any more. If not, then the following promo - // strings can also be removed. - { "promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE }, - { "promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON }, - { "promoAdvanced", IDS_SYNC_PROMO_ADVANCED }, - { "promoLearnMore", IDS_LEARN_MORE }, - { "promoTitleShort", IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT }, - { "encryptionSectionTitle", IDS_SYNC_ENCRYPTION_SECTION_TITLE }, - { "basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA }, - { "fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA }, + {"syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE}, + {"syncSetupSpinnerTitle", IDS_SYNC_SETUP_SPINNER_TITLE}, + {"syncSetupTimeoutTitle", IDS_SYNC_SETUP_TIME_OUT_TITLE}, + {"syncSetupTimeoutContent", IDS_SYNC_SETUP_TIME_OUT_CONTENT}, + {"errorLearnMore", IDS_LEARN_MORE}, + {"cancel", IDS_CANCEL}, + {"loginSuccess", IDS_SYNC_SUCCESS}, + {"settingUp", IDS_SYNC_LOGIN_SETTING_UP}, + {"syncAllDataTypes", IDS_SYNC_EVERYTHING}, + {"chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES}, + {"syncNothing", IDS_SYNC_NOTHING}, + {"bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS}, + {"preferences", IDS_SYNC_DATATYPE_PREFERENCES}, + {"autofill", IDS_SYNC_DATATYPE_AUTOFILL}, + {"themes", IDS_SYNC_DATATYPE_THEMES}, + {"passwords", IDS_SYNC_DATATYPE_PASSWORDS}, + {"extensions", IDS_SYNC_DATATYPE_EXTENSIONS}, + {"typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS}, + {"apps", IDS_SYNC_DATATYPE_APPS}, + {"wifiCredentials", IDS_SYNC_DATATYPE_WIFI_CREDENTIALS}, + {"openTabs", IDS_SYNC_DATATYPE_TABS}, + {"enablePaymentsIntegration", IDS_AUTOFILL_USE_PAYMENTS_DATA}, + {"serviceUnavailableError", IDS_SYNC_SETUP_ABORTED_BY_PENDING_CLEAR}, + {"confirmLabel", IDS_SYNC_CONFIRM_PASSPHRASE_LABEL}, + {"emptyErrorMessage", IDS_SYNC_EMPTY_PASSPHRASE_ERROR}, + {"mismatchErrorMessage", IDS_SYNC_PASSPHRASE_MISMATCH_ERROR}, + {"customizeLinkLabel", IDS_SYNC_CUSTOMIZE_LINK_LABEL}, + {"confirmSyncPreferences", IDS_SYNC_CONFIRM_SYNC_PREFERENCES}, + {"syncEverything", IDS_SYNC_SYNC_EVERYTHING}, + {"useDefaultSettings", IDS_SYNC_USE_DEFAULT_SETTINGS}, + {"enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY}, + {"enterGooglePassphraseBody", IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY}, + {"passphraseLabel", IDS_SYNC_PASSPHRASE_LABEL}, + {"incorrectPassphrase", IDS_SYNC_INCORRECT_PASSPHRASE}, + {"passphraseWarning", IDS_SYNC_PASSPHRASE_WARNING}, + {"yes", IDS_SYNC_PASSPHRASE_CANCEL_YES}, + {"no", IDS_SYNC_PASSPHRASE_CANCEL_NO}, + {"sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX}, + {"sectionExplicitMessagePostfix", + IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX}, + // TODO(rogerta): browser/resource/sync_promo/sync_promo.html and related + // file may not be needed any more. If not, then the following promo + // strings can also be removed. + {"promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE}, + {"promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON}, + {"promoAdvanced", IDS_SYNC_PROMO_ADVANCED}, + {"promoLearnMore", IDS_LEARN_MORE}, + {"promoTitleShort", IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT}, + {"encryptionSectionTitle", IDS_SYNC_ENCRYPTION_SECTION_TITLE}, + {"basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA}, + {"fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA}, }; RegisterStrings(localized_strings, resources, arraysize(resources)); @@ -568,6 +580,10 @@ void SyncSetupHandler::HandleConfigure(const base::ListValue* args) { service->OnUserChoseDatatypes(configuration.sync_everything, configuration.data_types); + PrefService* pref_service = GetProfile()->GetPrefs(); + pref_service->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, + configuration.payments_integration_enabled); + // Need to call IsPassphraseRequiredForDecryption() *after* calling // OnUserChoseDatatypes() because the user may have just disabled the // encrypted datatypes (in which case we just want to exit, not prompt the @@ -845,6 +861,7 @@ void SyncSetupHandler::DisplayConfigureSync(bool passphrase_failed) { // syncNothing: true if the user wants to sync nothing // <data_type>Registered: true if the associated data type is supported // <data_type>Synced: true if the user wants to sync that specific data type + // paymentsIntegrationEnabled: true if the user wants Payments integration // encryptionEnabled: true if sync supports encryption // encryptAllData: true if user wants to encrypt all data (not just // passwords) @@ -868,10 +885,14 @@ void SyncSetupHandler::DisplayConfigureSync(bool passphrase_failed) { // TODO(treib): How do we want to handle pref groups, i.e. when only some of // the sync types behind a checkbox are force-enabled? crbug.com/403326 } - sync_driver::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); + PrefService* pref_service = GetProfile()->GetPrefs(); + sync_driver::SyncPrefs sync_prefs(pref_service); args.SetBoolean("passphraseFailed", passphrase_failed); args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); args.SetBoolean("syncNothing", false); // Always false during initial setup. + args.SetBoolean( + "paymentsIntegrationEnabled", + pref_service->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled)); args.SetBoolean("encryptAllData", service->IsEncryptEverythingEnabled()); args.SetBoolean("encryptAllDataAllowed", service->IsEncryptEverythingAllowed()); diff --git a/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc index 7aeb5f1..7fcc635 100644 --- a/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc +++ b/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc @@ -67,6 +67,11 @@ enum EncryptAllConfig { ENCRYPT_PASSWORDS }; +enum PaymentsIntegrationConfig { + PAYMENTS_INTEGRATION_ENABLED, + PAYMENTS_INTEGRATION_DISABLED +}; + // Create a json-format string with the key/value pairs appropriate for a call // to HandleConfigure(). If |extra_values| is non-null, then the values from // the passed dictionary are added to the json. @@ -74,7 +79,8 @@ std::string GetConfiguration(const base::DictionaryValue* extra_values, SyncAllDataConfig sync_all, syncer::ModelTypeSet types, const std::string& passphrase, - EncryptAllConfig encrypt_all) { + EncryptAllConfig encrypt_all, + PaymentsIntegrationConfig payments_integration) { base::DictionaryValue result; if (extra_values) result.MergeDictionary(extra_values); @@ -96,6 +102,8 @@ std::string GetConfiguration(const base::DictionaryValue* extra_values, result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); result.SetBoolean("wifiCredentialsSynced", types.Has(syncer::WIFI_CREDENTIALS)); + result.SetBoolean("paymentsIntegrationEnabled", + payments_integration == PAYMENTS_INTEGRATION_ENABLED); std::string args; base::JSONWriter::Write(result, &args); return args; @@ -518,8 +526,9 @@ TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { #endif // #if !defined(OS_CHROMEOS) TEST_F(SyncSetupHandlerTest, TestSyncEverything) { - std::string args = GetConfiguration( - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -536,8 +545,9 @@ TEST_F(SyncSetupHandlerTest, TestSyncEverything) { } TEST_F(SyncSetupHandlerTest, TestSyncNothing) { - std::string args = GetConfiguration( - NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(NULL, SYNC_NOTHING, GetAllTypes(), std::string(), + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); @@ -551,8 +561,9 @@ TEST_F(SyncSetupHandlerTest, TestSyncNothing) { } TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { - std::string args = GetConfiguration( - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); + std::string args = + GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), + ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -572,8 +583,9 @@ TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { } TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { - std::string args = GetConfiguration( - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -595,11 +607,9 @@ TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { base::DictionaryValue dict; dict.SetBoolean("isGooglePassphrase", true); - std::string args = GetConfiguration(&dict, - SYNC_ALL_DATA, - GetAllTypes(), - "gaiaPassphrase", - ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "gaiaPassphrase", + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); // Act as if an encryption passphrase is required the first time, then never @@ -622,11 +632,9 @@ TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { base::DictionaryValue dict; dict.SetBoolean("isGooglePassphrase", false); - std::string args = GetConfiguration(&dict, - SYNC_ALL_DATA, - GetAllTypes(), - "custom_passphrase", - ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "custom_passphrase", + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -649,11 +657,9 @@ TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { base::DictionaryValue dict; dict.SetBoolean("isGooglePassphrase", true); - std::string args = GetConfiguration(&dict, - SYNC_ALL_DATA, - GetAllTypes(), - "invalid_passphrase", - ENCRYPT_PASSWORDS); + std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), + "invalid_passphrase", ENCRYPT_PASSWORDS, + PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -689,11 +695,9 @@ TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { for (it = user_selectable_types.First(); it.Good(); it.Inc()) { syncer::ModelTypeSet type_to_set; type_to_set.Put(it.Get()); - std::string args = GetConfiguration(NULL, - CHOOSE_WHAT_TO_SYNC, - type_to_set, - std::string(), - ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, std::string(), + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -712,11 +716,9 @@ TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { } TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { - std::string args = GetConfiguration(NULL, - CHOOSE_WHAT_TO_SYNC, - GetAllTypes(), - std::string(), - ENCRYPT_PASSWORDS); + std::string args = + GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), std::string(), + ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) @@ -810,6 +812,7 @@ TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { CheckBool(dictionary, "tabsRegistered", true); CheckBool(dictionary, "themesRegistered", true); CheckBool(dictionary, "typedUrlsRegistered", true); + CheckBool(dictionary, "paymentsIntegrationEnabled", true); CheckBool(dictionary, "showPassphrase", false); CheckBool(dictionary, "usePassphrase", false); CheckBool(dictionary, "passphraseFailed", false); @@ -954,8 +957,9 @@ TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { } TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { - std::string args = GetConfiguration( - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); + std::string args = + GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), + ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED); base::ListValue list_args; list_args.Append(new base::StringValue(args)); EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |