Commit a85ac36b authored by sebsg's avatar sebsg Committed by Commit Bot

[Autofill] Remove split settings page part1.

This removes code from the html and js files.

Bug: 930204
Change-Id: Ia3ff2e6f0c85ee2d820edaba8ce63127a3eca984
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1500055
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637818}
parent 833b27d3
......@@ -59,72 +59,31 @@
<span>$i18nRaw{manageCreditCardsLabel}</span>
</div>
<!--The version of settings that contains all the credit cards.-->
<template is="dom-if" if="[[!splitCreditCardList_]]">
<div class="settings-box continuation">
<h2 class="start">$i18n{creditCards}</h2>
<paper-button id="addCreditCard"
class="secondary-button header-aligned-button"
on-click="onAddCreditCardTap_"
hidden$="[[!prefs.autofill.credit_card_enabled.value]]">
$i18n{add}
</paper-button>
</div>
<div class="settings-box two-line" id="migrateCreditCards"
hidden$="[[!checkIfMigratable_(syncStatus, creditCards,
prefs.autofill.credit_card_enabled.value)]]"
on-click="onMigrateCreditCardsClick_" actionable>
<div class="start">
$i18n{migrateCreditCardsLabel}
<div class="secondary">[[migratableCreditCardsInfo_]]</div>
</div>
<paper-icon-button-light id="migrateCreditCardsButton"
class="subpage-arrow">
<button aria-label="[[migrateCreditCardsLabel_]]"></button>
</paper-icon-button-light>
</div>
<settings-credit-card-list id="creditCardList" class="list-frame"
credit-cards="[[creditCards]]">
</settings-credit-card-list>
</template>
<!--The version of settings that have split credit card sections.-->
<template is="dom-if" if="[[splitCreditCardList_]]">
<!--The section that contains the local credit cards.-->
<div class="settings-box continuation">
<h2 class="start">$i18n{localCreditCardsSectionTitle}</h2>
<paper-button id="addCreditCard"
class="secondary-button header-aligned-button"
on-click="onAddCreditCardTap_"
hidden$="[[!prefs.autofill.credit_card_enabled.value]]">
$i18n{add}
</paper-button>
</div>
<div class="settings-box two-line" id="migrateCreditCards"
hidden$="[[!checkIfMigratable_(syncStatus, localCreditCards,
prefs.autofill.credit_card_enabled.value)]]"
on-click="onMigrateCreditCardsClick_" actionable>
<div class="start">
$i18n{migrateCreditCardsLabel}
<div class="secondary">[[migratableCreditCardsInfo_]]</div>
</div>
<paper-icon-button-light id="migrateCreditCardsButton"
class="subpage-arrow">
<button aria-label="[[migrateCreditCardsLabel_]]"></button>
</paper-icon-button-light>
</div>
<settings-credit-card-list id="localCreditCardList" class="list-frame"
credit-cards="[[localCreditCards]]">
</settings-credit-card-list>
<!--The section that contains the server credit cards.-->
<div class="settings-box continuation">
<h2 class="start">$i18n{serverCreditCardsSectionTitle}</h2>
<div class="settings-box continuation">
<h2 class="start">$i18n{creditCards}</h2>
<paper-button id="addCreditCard"
class="secondary-button header-aligned-button"
on-click="onAddCreditCardTap_"
hidden$="[[!prefs.autofill.credit_card_enabled.value]]">
$i18n{add}
</paper-button>
</div>
<div class="settings-box two-line" id="migrateCreditCards"
hidden$="[[!checkIfMigratable_(syncStatus, creditCards,
prefs.autofill.credit_card_enabled.value)]]"
on-click="onMigrateCreditCardsClick_" actionable>
<div class="start">
$i18n{migrateCreditCardsLabel}
<div class="secondary">[[migratableCreditCardsInfo_]]</div>
</div>
<settings-credit-card-list id="serverCreditCardList" class="list-frame"
credit-cards="[[serverCreditCards]]">
</settings-credit-card-list>
</template>
<paper-icon-button-light id="migrateCreditCardsButton"
class="subpage-arrow">
<button aria-label="[[migrateCreditCardsLabel_]]"></button>
</paper-icon-button-light>
</div>
<settings-credit-card-list id="creditCardList" class="list-frame"
credit-cards="[[creditCards]]">
</settings-credit-card-list>
<cr-action-menu id="creditCardSharedMenu">
<button id="menuEditCreditCard" class="dropdown-item"
......
......@@ -18,54 +18,18 @@ class PaymentsManager {
*/
addCreditCardListChangedListener(listener) {}
/**
* Add an observer to the list of local credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} listener
*/
addLocalCreditCardListChangedListener(listener) {}
/**
* Add an observer to the list of server credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} listener
*/
addServerCreditCardListChangedListener(listener) {}
/**
* Remove an observer from the list of credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} listener
*/
removeCreditCardListChangedListener(listener) {}
/**
* Remove an observer from the list of local credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} listener
*/
removeLocalCreditCardListChangedListener(listener) {}
/**
* Remove an observer from the list of server credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} listener
*/
removeServerCreditCardListChangedListener(listener) {}
/**
* Request the list of credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} callback
*/
getCreditCardList(callback) {}
/**
* Request the list of local credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} callback
*/
getLocalCreditCardList(callback) {}
/**
* Request the list of server credit cards.
* @param {function(!Array<!PaymentsManager.CreditCardEntry>):void} callback
*/
getServerCreditCardList(callback) {}
/** @param {string} guid The GUID of the credit card to remove. */
removeCreditCard(guid) {}
......@@ -102,48 +66,16 @@ class PaymentsManagerImpl {
chrome.autofillPrivate.onCreditCardListChanged.addListener(listener);
}
/** @override */
addLocalCreditCardListChangedListener(listener) {
chrome.autofillPrivate.onLocalCreditCardListChanged.addListener(listener);
}
/** @override */
addServerCreditCardListChangedListener(listener) {
chrome.autofillPrivate.onServerCreditCardListChanged.addListener(listener);
}
/** @override */
removeCreditCardListChangedListener(listener) {
chrome.autofillPrivate.onCreditCardListChanged.removeListener(listener);
}
/** @override */
removeLocalCreditCardListChangedListener(listener) {
chrome.autofillPrivate.onLocalCreditCardListChanged.removeListener(
listener);
}
/** @override */
removeServerCreditCardListChangedListener(listener) {
chrome.autofillPrivate.onServerCreditCardListChanged.removeListener(
listener);
}
/** @override */
getCreditCardList(callback) {
chrome.autofillPrivate.getCreditCardList(callback);
}
/** @override */
getLocalCreditCardList(callback) {
chrome.autofillPrivate.getLocalCreditCardList(callback);
}
/** @override */
getServerCreditCardList(callback) {
chrome.autofillPrivate.getServerCreditCardList(callback);
}
/** @override */
removeCreditCard(guid) {
chrome.autofillPrivate.removeEntry(assert(guid));
......@@ -190,18 +122,6 @@ Polymer({
*/
creditCards: Array,
/**
* An array of saved locl credit cards.
* @type {!Array<!PaymentsManager.CreditCardEntry>}
*/
localCreditCards: Array,
/**
* An array of saved server credit cards.
* @type {!Array<!PaymentsManager.CreditCardEntry>}
*/
serverCreditCards: Array,
/**
* The model for any credit card related action menus or dialogs.
* @private {?chrome.autofillPrivate.CreditCardEntry}
......@@ -291,18 +211,6 @@ Polymer({
},
readOnly: true,
},
/**
* True when the cards list should be split in two..
* @private {boolean}
*/
splitCreditCardList_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('splitCreditCardList');
},
readOnly: true,
},
},
listeners: {
......@@ -330,18 +238,6 @@ Polymer({
*/
setCreditCardsListener_: null,
/**
* @type {?function(!Array<!PaymentsManager.CreditCardEntry>)}
* @private
*/
setLocalCreditCardsListener_: null,
/**
* @type {?function(!Array<!PaymentsManager.CreditCardEntry>)}
* @private
*/
setServerCreditCardsListener_: null,
/** @private {?settings.SyncBrowserProxy} */
syncBrowserProxy_: null,
......@@ -352,35 +248,19 @@ Polymer({
const setCreditCardsListener = list => {
this.creditCards = list;
};
/** @type {function(!Array<!PaymentsManager.CreditCardEntry>)} */
const setLocalCreditCardsListener = list => {
this.localCreditCards = list;
};
/** @type {function(!Array<!PaymentsManager.CreditCardEntry>)} */
const setServerCreditCardsListener = list => {
this.serverCreditCards = list;
};
// Remember the bound reference in order to detach.
this.setCreditCardsListener_ = setCreditCardsListener;
this.setLocalCreditCardsListener_ = setLocalCreditCardsListener;
this.setServerCreditCardsListener_ = setServerCreditCardsListener;
// Set the managers. These can be overridden by tests.
this.paymentsManager_ = PaymentsManagerImpl.getInstance();
// Request initial data.
this.paymentsManager_.getCreditCardList(setCreditCardsListener);
this.paymentsManager_.getLocalCreditCardList(setLocalCreditCardsListener);
this.paymentsManager_.getServerCreditCardList(setServerCreditCardsListener);
// Listen for changes.
this.paymentsManager_.addCreditCardListChangedListener(
setCreditCardsListener);
this.paymentsManager_.addLocalCreditCardListChangedListener(
setLocalCreditCardsListener);
this.paymentsManager_.addServerCreditCardListChangedListener(
setServerCreditCardsListener);
this.syncBrowserProxy_ = settings.SyncBrowserProxyImpl.getInstance();
this.syncBrowserProxy_.getSyncStatus().then(
......@@ -397,12 +277,6 @@ Polymer({
this.paymentsManager_.removeCreditCardListChangedListener(
/** @type {function(!Array<!PaymentsManager.CreditCardEntry>)} */ (
this.setCreditCardsListener_));
this.paymentsManager_.removeLocalCreditCardListChangedListener(
/** @type {function(!Array<!PaymentsManager.CreditCardEntry>)} */ (
this.setLocalCreditCardsListener_));
this.paymentsManager_.removeServerCreditCardListChangedListener(
/** @type {function(!Array<!PaymentsManager.CreditCardEntry>)} */ (
this.setServerCreditCardsListener_));
},
/**
......
......@@ -1467,8 +1467,6 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"autofillPageTitle", IDS_SETTINGS_AUTOFILL},
{"passwords", IDS_SETTINGS_PASSWORDS},
{"creditCards", IDS_AUTOFILL_PAYMENT_METHODS},
{"localCreditCardsSectionTitle", IDS_AUTOFILL_LOCAL_PAYMENT_METHODS},
{"serverCreditCardsSectionTitle", IDS_AUTOFILL_SERVER_PAYMENT_METHODS},
{"noCreditCardsFound", IDS_SETTINGS_PAYMENT_METHODS_NONE},
{"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS},
{"googlePaymentsCached", IDS_SETTINGS_GOOGLE_PAYMENTS_CACHED},
......@@ -1952,11 +1950,6 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
html_source->AddBoolean("isAccountManagerEnabled",
chromeos::IsAccountManagerAvailable(profile));
#endif
html_source->AddBoolean(
"splitCreditCardList",
base::FeatureList::IsEnabled(
autofill::features::kAutofillSettingsCardTypeSplit));
}
void AddPrintingStrings(content::WebUIDataSource* html_source) {
......
......@@ -124,10 +124,6 @@ cr.define('settings_autofill_page', function() {
const expected = new PaymentsManagerExpectations();
expected.requestedCreditCards = 1;
expected.listeningCreditCards = 1;
expected.requestedLocalCreditCards = 1;
expected.listeningLocalCreditCards = 1;
expected.requestedServerCreditCards = 1;
expected.listeningServerCreditCards = 1;
return expected;
}
......@@ -176,8 +172,6 @@ cr.define('settings_autofill_page', function() {
autofillManager.assertExpectations(autofillExpectations);
paymentsExpectations.listeningCreditCards = 0;
paymentsExpectations.listeningLocalCreditCards = 0;
paymentsExpectations.listeningServerCreditCards = 0;
paymentsManager.assertExpectations(paymentsExpectations);
destroyPrefs(prefs);
......
......@@ -220,11 +220,7 @@ TestAutofillManager.prototype = {
class PaymentsManagerExpectations {
constructor() {
this.requestedCreditCards = 0;
this.requestedLocalCreditCards = 0;
this.requestedServerCreditCards = 0;
this.listeningCreditCards = 0;
this.listeningLocalCreditCards = 0;
this.listeningServerCreditCards = 0;
}
}
......@@ -239,15 +235,11 @@ function TestPaymentsManager() {
// Set these to have non-empty data.
this.data = {
creditCards: [],
localCreditCards: [],
serverCreditCards: [],
};
// Holds the last callbacks so they can be called when needed.
this.lastCallback = {
addCreditCardListChangedListener: null,
addLocalCreditCardListChangedListener: null,
addServerCreditCardListChangedListener: null,
};
}
......@@ -258,51 +250,17 @@ TestPaymentsManager.prototype = {
this.lastCallback.addCreditCardListChangedListener = listener;
},
/** @override */
addLocalCreditCardListChangedListener: function(listener) {
this.actual_.listeningLocalCreditCards++;
this.lastCallback.addLocalCreditCardListChangedListener = listener;
},
/** @override */
addServerCreditCardListChangedListener: function(listener) {
this.actual_.listeningServerCreditCards++;
this.lastCallback.addServerCreditCardListChangedListener = listener;
},
/** @override */
removeCreditCardListChangedListener: function(listener) {
this.actual_.listeningCreditCards--;
},
/** @override */
removeLocalCreditCardListChangedListener: function(listener) {
this.actual_.listeningLocalCreditCards--;
},
/** @override */
removeServerCreditCardListChangedListener: function(listener) {
this.actual_.listeningServerCreditCards--;
},
/** @override */
getCreditCardList: function(callback) {
this.actual_.requestedCreditCards++;
callback(this.data.creditCards);
},
/** @override */
getLocalCreditCardList: function(callback) {
this.actual_.requestedLocalCreditCards++;
callback(this.data.localCreditCards);
},
/** @override */
getServerCreditCardList: function(callback) {
this.actual_.requestedServerCreditCards++;
callback(this.data.serverCreditCards);
},
/**
* Verifies expectations.
* @param {!PaymentsManagerExpectations} expected
......@@ -310,14 +268,6 @@ TestPaymentsManager.prototype = {
assertExpectations: function(expected) {
const actual = this.actual_;
assertEquals(expected.requestedCreditCards, actual.requestedCreditCards);
assertEquals(
expected.requestedLocalCreditCards, actual.requestedLocalCreditCards);
assertEquals(
expected.requestedServerCreditCards, actual.requestedServerCreditCards);
assertEquals(expected.listeningCreditCards, actual.listeningCreditCards);
assertEquals(
expected.listeningLocalCreditCards, actual.listeningLocalCreditCards);
assertEquals(
expected.listeningServerCreditCards, actual.listeningServerCreditCards);
},
};
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