summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2015-01-07 21:22:05 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-08 05:22:55 +0000
commit09af4d6443f86f03e07ddb1bed3cd473baa7e0d6 (patch)
treec24e494e716db5fe08b2fe90b31d64fc01b706d5
parent9b9e33a32ebf68a70b305a26a3564ad71f87070a (diff)
downloadchromium_src-09af4d6443f86f03e07ddb1bed3cd473baa7e0d6.zip
chromium_src-09af4d6443f86f03e07ddb1bed3cd473baa7e0d6.tar.gz
chromium_src-09af4d6443f86f03e07ddb1bed3cd473baa7e0d6.tar.bz2
Create initial settings UI for wallet integration.
Due to lack of mocks, this is the simplest and ugliest UI imaginable. BUG=446698 Review URL: https://codereview.chromium.org/839683002 Cr-Commit-Position: refs/heads/master@{#310455}
-rw-r--r--chrome/browser/resources/options/autofill_options.html22
-rw-r--r--chrome/browser/resources/options/autofill_options.js7
-rw-r--r--chrome/browser/ui/webui/options/autofill_options_handler.cc30
-rw-r--r--chrome/browser/ui/webui/options/autofill_options_handler.h3
4 files changed, 62 insertions, 0 deletions
diff --git a/chrome/browser/resources/options/autofill_options.html b/chrome/browser/resources/options/autofill_options.html
index 28374bc..91529fb 100644
--- a/chrome/browser/resources/options/autofill_options.html
+++ b/chrome/browser/resources/options/autofill_options.html
@@ -28,6 +28,28 @@
i18n-content="autofillAddCreditCard"></button>
</div>
</div>
+ <!-- TODO(estade): This section shouldn't show if you're not signed into
+ sync. -->
+ <div id="autofill-wallet-card-area" class="settings-row" hidden>
+ <!-- A reminder not to launch this UI. -->
+ <span>Warning, these strings are not translated!</span>
+ <div>
+ Chrome will also suggest
+ <a target="_blank" i18n-values="href:manageWalletAddressesUrl">
+ addresses</a>
+ and
+ <a target="_blank" i18n-values="href:manageWalletPaymentMethodsUrl">
+ cards</a>
+ stored in your Wallet.
+ </div>
+ <div>
+ <span>Credit cards from Wallet require authentication once and
+ then remain unlocked.
+ </span>
+ <a id="remask-server-cards-link"
+ is="action-link">Reset authenticated cards</a>
+ </div>
+ </div>
</div>
<div class="action-area">
<a id="autofill-help" target="_blank" i18n-values="href:helpUrl"
diff --git a/chrome/browser/resources/options/autofill_options.js b/chrome/browser/resources/options/autofill_options.js
index 22498d2..49ce81f 100644
--- a/chrome/browser/resources/options/autofill_options.js
+++ b/chrome/browser/resources/options/autofill_options.js
@@ -89,6 +89,13 @@ cr.define('options', function() {
return true; // Always follow the href
};
+ $('autofill-wallet-card-area').hidden =
+ !loadTimeData.getBoolean('enableAutofillWalletIntegration');
+ // TODO(estade): there should probably be some indication of success.
+ $('remask-server-cards-link').onclick = function(event) {
+ chrome.send('remaskServerCards');
+ };
+
// TODO(jhawkins): What happens when Autofill is disabled whilst on the
// Autofill options page?
},
diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc
index 6968c6c..8b0c04c 100644
--- a/chrome/browser/ui/webui/options/autofill_options_handler.cc
+++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/command_line.h"
#include "base/guid.h"
#include "base/logging.h"
#include "base/strings/string16.h"
@@ -20,12 +21,14 @@
#include "chrome/browser/ui/autofill/country_combobox_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "components/autofill/content/browser/wallet/wallet_service_url.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/phone_number_i18n.h"
#include "components/autofill/core/common/autofill_constants.h"
+#include "components/autofill/core/common/autofill_switches.h"
#include "content/public/browser/web_ui.h"
#include "third_party/libaddressinput/messages.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
@@ -331,6 +334,17 @@ void AutofillOptionsHandler::GetLocalizedValues(
localized_strings->SetString("helpUrl", autofill::kHelpURL);
SetAddressOverlayStrings(localized_strings);
SetCreditCardOverlayStrings(localized_strings);
+
+ localized_strings->SetBoolean(
+ "enableAutofillWalletIntegration",
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ autofill::switches::kEnableWalletCardImport));
+ localized_strings->SetString(
+ "manageWalletAddressesUrl",
+ autofill::wallet::GetManageAddressesUrl(0).spec());
+ localized_strings->SetString(
+ "manageWalletPaymentMethodsUrl",
+ autofill::wallet::GetManageInstrumentsUrl(0).spec());
}
void AutofillOptionsHandler::InitializeHandler() {
@@ -381,6 +395,10 @@ void AutofillOptionsHandler::RegisterMessages() {
"validatePhoneNumbers",
base::Bind(&AutofillOptionsHandler::ValidatePhoneNumbers,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "remaskServerCards",
+ base::Bind(&AutofillOptionsHandler::RemaskServerCards,
+ base::Unretained(this)));
}
/////////////////////////////////////////////////////////////////////////////
@@ -675,6 +693,18 @@ void AutofillOptionsHandler::ValidatePhoneNumbers(const base::ListValue* args) {
"AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value);
}
+void AutofillOptionsHandler::RemaskServerCards(const base::ListValue* args) {
+ const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards();
+ for (const auto card : cards) {
+ CreditCard card_copy = *card;
+ if (card_copy.record_type() == CreditCard::FULL_SERVER_CARD) {
+ card_copy.set_record_type(CreditCard::MASKED_SERVER_CARD);
+ card_copy.SetNumber(card->LastFourDigits());
+ personal_data_->UpdateServerCreditCard(card_copy);
+ }
+ }
+}
+
bool AutofillOptionsHandler::IsPersonalDataLoaded() const {
return personal_data_ && personal_data_->IsDataLoaded();
}
diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.h b/chrome/browser/ui/webui/options/autofill_options_handler.h
index ca26e0e..3f80e55 100644
--- a/chrome/browser/ui/webui/options/autofill_options_handler.h
+++ b/chrome/browser/ui/webui/options/autofill_options_handler.h
@@ -94,6 +94,9 @@ class AutofillOptionsHandler : public OptionsPageUIHandler,
// array of numbers, and the country code string set on the profile.
void ValidatePhoneNumbers(const base::ListValue* args);
+ // Resets the masked state on all unmasked Wallet cards.
+ void RemaskServerCards(const base::ListValue* args);
+
// Returns true if |personal_data_| is non-null and loaded.
bool IsPersonalDataLoaded() const;