Commit 8bc152e6 authored by Sujie Zhu's avatar Sujie Zhu Committed by Commit Bot

[Settings Autofill Card Migration] Add syncStatus in the payments_section

Since we only offer local cards migration to signed-in and synced user, we have to get the syncStatus in the payments_section in order to check the migration requirements in the payments_section.js.

We use the similar code from the people_page.js to add the syncStatus property from SyncBrowserProxy in the payments_section.

Please refer to the design doc for more details: https://docs.google.com/document/d/1J7YyBeKZZaBhjAHnMEezvuBa5x1pk_XCh_yZvV_HMmc/edit#heading=h.1wm3blr98d8i

Bug: 852904
Change-Id: I9786fd491780a6daf71d19da94da4b048ad59ed2
Reviewed-on: https://chromium-review.googlesource.com/1168386Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Sujie Zhu <sujiezhu@google.com>
Cr-Commit-Position: refs/heads/master@{#582229}
parent 27c03b44
...@@ -50,9 +50,11 @@ js_library("autofill_section") { ...@@ -50,9 +50,11 @@ js_library("autofill_section") {
js_library("payments_section") { js_library("payments_section") {
deps = [ deps = [
":credit_card_edit_dialog", ":credit_card_edit_dialog",
"../people_page:sync_browser_proxy",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu", "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
"//ui/webui/resources/js:assert", "//ui/webui/resources/js:assert",
"//ui/webui/resources/js:load_time_data", "//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:web_ui_listener_behavior",
"//ui/webui/resources/js/cr/ui:focus_without_ink", "//ui/webui/resources/js/cr/ui:focus_without_ink",
] ]
externs_list = [ "$externs_path/autofill_private.js" ] externs_list = [ "$externs_path/autofill_private.js" ]
......
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> <link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../i18n_setup.html"> <link rel="import" href="../i18n_setup.html">
<link rel="import" href="../settings_shared_css.html"> <link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../controls/settings_toggle_button.html"> <link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="../prefs/prefs.html"> <link rel="import" href="../prefs/prefs.html">
<link rel="import" href="../people_page/sync_browser_proxy.html">
<link rel="import" href="credit_card_edit_dialog.html"> <link rel="import" href="credit_card_edit_dialog.html">
<link rel="import" href="passwords_shared_css.html"> <link rel="import" href="passwords_shared_css.html">
......
...@@ -90,6 +90,10 @@ cr.addSingletonGetter(PaymentsManagerImpl); ...@@ -90,6 +90,10 @@ cr.addSingletonGetter(PaymentsManagerImpl);
Polymer({ Polymer({
is: 'settings-payments-section', is: 'settings-payments-section',
behaviors: [
WebUIListenerBehavior,
],
properties: { properties: {
/** /**
* An array of saved credit cards. * An array of saved credit cards.
...@@ -105,6 +109,14 @@ Polymer({ ...@@ -105,6 +109,14 @@ Polymer({
/** @private */ /** @private */
showCreditCardDialog_: Boolean, showCreditCardDialog_: Boolean,
/**
* The current sync status, supplied by SyncBrowserProxy.
* TODO(sujiezhu): Use this to check migration requirements when all
* information is ready. (https://crbug.com/852904).
* @type {?settings.SyncStatus}
*/
syncStatus: Object,
}, },
listeners: { listeners: {
...@@ -130,6 +142,9 @@ Polymer({ ...@@ -130,6 +142,9 @@ Polymer({
*/ */
setCreditCardsListener_: null, setCreditCardsListener_: null,
/** @private {?settings.SyncBrowserProxy} */
syncBrowserProxy_: null,
/** @override */ /** @override */
attached: function() { attached: function() {
// Create listener function. // Create listener function.
...@@ -150,6 +165,12 @@ Polymer({ ...@@ -150,6 +165,12 @@ Polymer({
// Listen for changes. // Listen for changes.
this.paymentsManager_.addCreditCardListChangedListener( this.paymentsManager_.addCreditCardListChangedListener(
setCreditCardsListener); setCreditCardsListener);
this.syncBrowserProxy_ = settings.SyncBrowserProxyImpl.getInstance();
this.syncBrowserProxy_.getSyncStatus().then(
this.handleSyncStatus_.bind(this));
this.addWebUIListener(
'sync-status-changed', this.handleSyncStatus_.bind(this));
}, },
/** @override */ /** @override */
...@@ -302,5 +323,14 @@ Polymer({ ...@@ -302,5 +323,14 @@ Polymer({
saveCreditCard_: function(event) { saveCreditCard_: function(event) {
this.paymentsManager_.saveCreditCard(event.detail); this.paymentsManager_.saveCreditCard(event.detail);
}, },
/**
* Handler for when the sync state is pushed from the browser.
* @param {?settings.SyncStatus} syncStatus
* @private
*/
handleSyncStatus_: function(syncStatus) {
this.syncStatus = syncStatus;
},
}); });
})(); })();
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