Commit 0d6b6355 authored by Curt Clemens's avatar Curt Clemens Committed by Commit Bot

[Nearby] Show filename on send confirmation page

Add some polymer bindings to share the discovery page's SendPreview
with the confirmation page. This allows showing the correct filename
on the confirmation page, and also paves the way for using the
appropriate icon depending on the file type.

Bug: 1123942
Change-Id: Iff779c2fa681f85ff3fd7435cce3a38706ff5c57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493376
Commit-Queue: Curt Clemens <cclem@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820385}
parent 88018d88
......@@ -2,12 +2,14 @@
<nearby-confirmation-page id="[[Page.CONFIRMATION]]" slot="view"
confirmation-manager="[[confirmationManager_]]"
transfer-update-listener="[[transferUpdateListener_]]"
share-target="[[selectedShareTarget_]]">
share-target="[[selectedShareTarget_]]"
send-preview="[[sendPreview_]]">
</nearby-confirmation-page>
<nearby-discovery-page id="[[Page.DISCOVERY]]" slot="view"
confirmation-manager="{{confirmationManager_}}"
transfer-update-listener="{{transferUpdateListener_}}"
selected-share-target="{{selectedShareTarget_}}">
selected-share-target="{{selectedShareTarget_}}"
send-preview="{{sendPreview_}}">
</nearby-discovery-page>
<nearby-onboarding-page id="[[Page.ONBOARDING]]" settings="{{settings}}"
slot="view">
......
......@@ -42,8 +42,7 @@ Polymer({
/**
* Set by the nearby-discovery-page component when switching to the
* nearby-confirmation-page.
* @type {?nearbyShare.mojom.ConfirmationManagerInterface}
* @private
* @private {?nearbyShare.mojom.ConfirmationManagerInterface}
*/
confirmationManager_: {
type: Object,
......@@ -53,8 +52,7 @@ Polymer({
/**
* Set by the nearby-discovery-page component when switching to the
* nearby-confirmation-page.
* @type {?nearbyShare.mojom.TransferUpdateListenerPendingReceiver}
* @private
* @private {?nearbyShare.mojom.TransferUpdateListenerPendingReceiver}
*/
transferUpdateListener_: {
type: Object,
......@@ -64,13 +62,21 @@ Polymer({
/**
* The currently selected share target set by the nearby-discovery-page
* component when the user selects a device.
* @type {?nearbyShare.mojom.ShareTarget}
* @private
* @private {?nearbyShare.mojom.ShareTarget}
*/
selectedShareTarget_: {
type: Object,
value: null,
},
/**
* Preview info of attachment to be sent, set by the nearby-discovery-page.
* @private {?nearbyShare.mojom.SendPreview}
*/
sendPreview_: {
type: Object,
value: null,
},
},
listeners: {
......
......@@ -57,7 +57,8 @@
cancel-button-event-name="[[getCancelEventName_(needsConfirmation_)]]">
<div id="centerContent" slot="content">
<div id="processRow">
<nearby-preview title="[[attachmentTitle_()]]"></nearby-preview>
<nearby-preview title="[[attachmentTitle_(sendPreview)]]">
</nearby-preview>
<div id="confirmationToken">
<template is="dom-if" if="[[confirmationToken_]]">
[[i18n('nearbyShareSecureConnectionId', confirmationToken_)]]
......
......@@ -89,6 +89,16 @@ Polymer({
value: null,
},
/**
* Preview info for the file(s) to send. Expected to start
* as null, then change to a valid object before this component is shown.
* @type {?nearbyShare.mojom.SendPreview}
*/
sendPreview: {
type: Object,
value: null,
},
/**
* Token to show to the user to confirm the selected share target. Expected
* to start as null, then change to a valid object via updates from the
......@@ -223,7 +233,8 @@ Polymer({
* @private
*/
attachmentTitle_() {
// TODO(crbug.com/1123942): Pass attachments to UI.
return 'Unknown file';
return this.sendPreview && this.sendPreview.description ?
this.sendPreview.description :
'Unknown file';
},
});
......@@ -73,7 +73,7 @@
cancel-button-event-name="close">
<div id="centerContent" slot="content">
<div id="process-row">
<nearby-preview title="[[attachmentsDescription]]"></nearby-preview>
<nearby-preview title="[[sendPreview.description]]"></nearby-preview>
<iron-list items="[[shareTargets_]]" id="deviceList"
selected-item="{{selectedShareTarget}}"
on-selected-item-changed="onSelectedShareTargetChanged_"
......
......@@ -51,11 +51,12 @@ Polymer({
properties: {
/**
* The description of the attachments
* @type {?string}
* Preview info for the file(s) to be shared.
* @type {?nearbyShare.mojom.SendPreview}
*/
attachmentsDescription: {
type: String,
sendPreview: {
notify: true,
type: Object,
value: null,
},
......@@ -177,7 +178,7 @@ Polymer({
];
getDiscoveryManager().getSendPreview().then(result => {
this.attachmentsDescription = result.sendPreview.description;
this.sendPreview = result.sendPreview;
// TODO (vecore): Setup icon and handle case of more than one attachment.
});
......
......@@ -98,4 +98,16 @@ suite('ConfirmatonPageTest', function() {
.textContent;
assertEquals(name, renderedName);
});
test('renders attachment title', function() {
const title = 'Filename';
confirmationPageElement.sendPreview = {
description: title,
fileCount: 1,
shareType: nearbyShare.mojom.ShareType.kUnknownFile
};
const renderedTitle =
confirmationPageElement.$$('nearby-preview').$$('#title').textContent;
assertEquals(title, renderedTitle);
});
});
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