Commit 54f8bbea authored by James Vecore's avatar James Vecore Committed by Commit Bot

[Nearby] Add stubs for high visibility and confirm

Adds stub pages for high visibility and confirm to the receive dialog.
Future CLs will flesh these out and wire up a mojo to communicate with
the share service.

Screenshots:
http://screen/6QvnCB5NppKzGpC.png
http://screen/32LmeXBLxmDvayD.png

Bug: b:163148440, b:163147818
Change-Id: I68e248d54000ddd580ae8dc6a9ddc076b1ceddb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2384790
Commit-Queue: James Vecore <vecore@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803392}
parent ff1e284e
......@@ -130,6 +130,20 @@
{COUNT, plural, =1 {1 item} other {# items}}
</message>
<!-- High Visibility Page Strings -->
<message name="IDS_NEARBY_HIGH_VISIBILITY_SUB_TITLE" desc="Describes to the user that their device is visible to nearby devices with a specific device name. This is used on the sub-title of the of high visibility receive dialog for the Nearby Share feature.">
Visible to nearby devices as <ph name="DEVICE_NAME">$1<ex>Rea’s Chromebook</ex></ph>
</message>
<message name="IDS_NEARBY_HIGH_VISIBILITY_HELP_TEXT" desc="Describes to the user that their device is visible to nearby devices with a specific device name. This is used on the sub-title of the of high visibility receive dialog for the Nearby Share feature.">
Make sure both devices are unlocked, close together, and have Bluetooth turned on. <ph name="LINK_BEGIN">&lt;a&gt;</ph>Learn more<ph name="LINK_END">&lt;/a&gt;</ph>
</message>
<!-- Receive Confirmation Page Strings -->
<message name="IDS_NEARBY_RECEIVE_CONFIRM_PAGE_TITLE" desc="The title of the recieve confirmation page which askign the user to confirm receving a share from a specific device.">
Receive from this device?
</message>
<!-- Settings Strings -->
<message name="IDS_NEARBY_VISIBLITY_ALL_CONTACTS" desc="Describes the user preference state for the user to be visibile to all their contacts in the Nearby Share feature.">
All contacts
......
2a6af27a9d1ec791612fb9d5ef5f16d015af4c6f
\ No newline at end of file
990300ebf0e21130325911e5d749b4896da5e9df
\ No newline at end of file
ef732c3e100c138b4170dc4e7356fbb238d3d4d4
\ No newline at end of file
......@@ -18,6 +18,9 @@
<path d="M15 6H17V8H19V10H17V12H15V10H13V8H15V6Z"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 11C9.60583 11 13.7789 12.0336 13.9916 14.0859L14 14.25V17H1V14.25C1 12.0887 5.33875 11 7.5 11ZM11.9947 14.3433C11.9867 14.3476 11.9693 14.3346 11.9329 14.3011L11.8432 14.2246C11.6159 14.0441 11.2636 13.85 10.8172 13.6713C9.79154 13.2607 8.42752 13 7.5 13C6.57248 13 5.20846 13.2607 4.18279 13.6713C3.73641 13.85 3.38414 14.0441 3.15679 14.2246L3.0671 14.3011C3.01855 14.3458 3.00384 14.3539 3 14.3335V15H12V14.3335L11.9947 14.3433Z"></path>
</g>
<g id="info">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 14H11V10H9V14ZM10 2C5.584 2 2 5.584 2 10C2 14.416 5.584 18 10 18C14.416 18 18 14.416 18 10C18 5.584 14.416 2 10 2ZM10 16C6.6925 16 4 13.3075 4 10C4 6.6925 6.6925 4 10 4C13.3075 4 16 6.6925 16 10C16 13.3075 13.3075 16 10 16ZM9 8H11V6H9V8Z"></path>
</g>
<g id="radar">
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.0353 15.096C12.9268 15.975 11.5247 16.5 10 16.5C6.41015 16.5 3.5 13.5899 3.5 10C3.5 6.41015 6.41015 3.5 10 3.5C13.5899 3.5 16.5 6.41015 16.5 10C16.5 11.5247 15.975 12.9268 15.096 14.0354L14.0261 12.9654C14.6382 12.1358 15 11.1101 15 10C15 7.23858 12.7614 5 10 5C7.23858 5 5 7.23858 5 10C5 12.7614 7.23858 15 10 15C11.1101 15 12.1358 14.6382 12.9654 14.0261L14.0353 15.096ZM12.948 11.8874C13.2974 11.3428 13.5 10.6951 13.5 10C13.5 8.067 11.933 6.5 10 6.5C8.067 6.5 6.5 8.067 6.5 10C6.5 11.933 8.067 13.5 10 13.5C10.6951 13.5 11.3428 13.2974 11.8874 12.948L10.3885 11.4492C10.2646 11.4823 10.1344 11.5 10 11.5C9.17157 11.5 8.5 10.8284 8.5 10C8.5 9.17157 9.17157 8.5 10 8.5C10.8284 8.5 11.5 9.17157 11.5 10C11.5 10.1344 11.4823 10.2646 11.4492 10.3885L12.948 11.8874ZM18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2C14.4183 2 18 5.58172 18 10Z"></path>
</g>
......
......@@ -10,15 +10,22 @@ import("../os_settings.gni")
js_type_check("closure_compile") {
deps = [
":nearby_share_confirm_page",
":nearby_share_contact_visibility_dialog",
":nearby_share_data_usage_dialog",
":nearby_share_device_name_dialog",
":nearby_share_high_visibility_page",
":nearby_share_receive_dialog",
":nearby_share_subpage",
":types",
]
}
js_library("nearby_share_confirm_page") {
deps =
[ "//chrome/browser/resources/nearby_share/shared:nearby_page_template" ]
}
js_library("nearby_share_contact_visibility_dialog") {
deps = [
"//chrome/browser/resources/nearby_share/shared:nearby_contact_visibility",
......@@ -54,8 +61,19 @@ js_library("nearby_share_device_name_dialog") {
]
}
js_library("nearby_share_high_visibility_page") {
deps = [
"../localized_link:localized_link",
"//chrome/browser/resources/nearby_share/shared:nearby_page_template",
"//ui/webui/resources/js:i18n_behavior",
]
}
js_library("nearby_share_receive_dialog") {
deps = [
":nearby_share_confirm_page",
":nearby_share_high_visibility_page",
"//chrome/browser/resources/nearby_share/shared:nearby_share_settings_behavior",
"//ui/webui/resources/cr_elements/cr_button:cr_button",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager",
......@@ -88,9 +106,11 @@ js_library("types") {
group("polymer3_elements") {
public_deps = [
":modulize",
":nearby_share_confirm_page_module",
":nearby_share_contact_visibility_dialog_module",
":nearby_share_data_usage_dialog_module",
":nearby_share_device_name_dialog_module",
":nearby_share_high_visibility_page_module",
":nearby_share_receive_dialog_module",
":nearby_share_subpage_module",
"../../controls:polymer3_elements",
......@@ -106,14 +126,24 @@ js_type_check("closure_compile_module") {
# purposes.
closure_flags = default_closure_args + [ "browser_resolver_prefix_replacements=\"../../shared/=../../../nearby_share/shared/\"" ]
deps = [
":nearby_share_confirm_page.m",
":nearby_share_contact_visibility_dialog.m",
":nearby_share_data_usage_dialog.m",
":nearby_share_device_name_dialog.m",
":nearby_share_high_visibility_page.m",
":nearby_share_receive_dialog.m",
":nearby_share_subpage.m",
]
}
js_library("nearby_share_confirm_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_confirm_page.m.js" ]
deps = [
"//chrome/browser/resources/nearby_share/shared:nearby_page_template.m",
]
extra_deps = [ ":nearby_share_confirm_page_module" ]
}
js_library("nearby_share_contact_visibility_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_contact_visibility_dialog.m.js" ]
deps = [
......@@ -155,9 +185,22 @@ js_library("nearby_share_device_name_dialog.m") {
extra_deps = [ ":nearby_share_device_name_dialog_module" ]
}
js_library("nearby_share_high_visibility_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_high_visibility_page.m.js" ]
deps = [
"../localized_link:localized_link.m",
"//chrome/browser/resources/nearby_share/shared:nearby_page_template.m",
"//ui/webui/resources/js:i18n_behavior.m",
]
extra_deps = [ ":nearby_share_high_visibility_page_module" ]
}
js_library("nearby_share_receive_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_receive_dialog.m.js" ]
deps = [
":nearby_share_confirm_page.m",
":nearby_share_high_visibility_page.m",
"//chrome/browser/resources/nearby_share/shared:nearby_share_settings_behavior.m",
"//ui/webui/resources/cr_elements/cr_button:cr_button.m",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager.m",
......@@ -210,6 +253,14 @@ nearby_shared_auto_imports_closure_fix = [
"chrome/browser/resources/settings/shared/nearby_share_settings_behavior.html|NearbyShareSettingsBehavior,NearbySettings",
]
polymer_modulizer("nearby_share_confirm_page") {
js_file = "nearby_share_confirm_page.js"
html_file = "nearby_share_confirm_page.html"
html_type = "dom-module"
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
polymer_modulizer("nearby_share_contact_visibility_dialog") {
js_file = "nearby_share_contact_visibility_dialog.js"
html_file = "nearby_share_contact_visibility_dialog.html"
......@@ -236,12 +287,22 @@ polymer_modulizer("nearby_share_device_name_dialog") {
auto_imports = os_settings_auto_imports
}
polymer_modulizer("nearby_share_high_visibility_page") {
js_file = "nearby_share_high_visibility_page.js"
html_file = "nearby_share_high_visibility_page.html"
html_type = "dom-module"
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
polymer_modulizer("nearby_share_receive_dialog") {
js_file = "nearby_share_receive_dialog.js"
html_file = "nearby_share_receive_dialog.html"
html_type = "dom-module"
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
namespace_rewrites =
os_settings_namespace_rewrites + nearby_shared_namespace_rewrites
auto_imports =
os_settings_auto_imports + nearby_shared_auto_imports_closure_fix
}
polymer_modulizer("nearby_share_subpage") {
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="../../shared/nearby_page_template.html">
<dom-module id="nearby-share-confirm-page">
<template>
<nearby-page-template title="$i18n{nearbyShareReceiveConfirmPageTitle}"
action-button-label="$i18n{confirm}"
action-button-event-name="confirm"
cancel-button-label="$i18n{cancel}"
cancel-button-event-name="reject">
<div slot="content">
<!-- TODO(vecore): add page body -->
</div>
</nearby-page-template>
</template>
<script src="nearby_share_confirm_page.js"></script>
</dom-module>
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview The 'nearby-share-confirm-page' component show the user the
* details of an incoming share request and allows the user to confirm or
* reject the request
*/
Polymer({
is: 'nearby-share-confirm-page',
});
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="../../shared/nearby_page_template.html">
<link rel="import" href="../../shared/nearby_shared_icons.html">
<dom-module id="nearby-share-high-visibility-page">
<template>
<style>
#content {
background: radial-gradient(160% 50% at 0 100%,
rgba(138, 180, 248, 0.25),rgba(255, 255, 255, 0));
display: flex;
flex-direction: column-reverse;
height: 100%;
width: 100%;
}
#help {
align-items: center;
color: var(--google-gray-500);
display: flex;
flex-direction: row;
margin-inline-end: 24px;
margin-inline-start: 24px;
padding: 8px;
}
#helpText {
font-size: .8rem;
line-height: .8rem;
margin: auto;
}
#infoIcon {
height: 20px;
margin-inline-end: 12px;
width: 20px;
}
</style>
<nearby-page-template title="$i18n{nearbyShareFeatureName}"
sub-title="[[getSubTitle_(deviceName)]]"
cancel-button-label="$i18n{cancel}">
<div id="content" slot="content">
<div id="help">
<iron-icon id="infoIcon" icon="nearby20:info"></iron-icon>
<div id="helpText">
<!-- TODO(vecore): add correct url for learn more link -->
<settings-localized-link
localized-string="$i18n{nearbyShareHighVisibilityHelpText}"
link-url="https://google.com">
</settings-localized-link>
</div>
</div>
</div>
</nearby-page-template>
</template>
<script src="nearby_share_high_visibility_page.js"></script>
</dom-module>
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview The 'nearby-high-visibility-page' component is opened when the
* user is broadcast in high-visibility mode. The user may cancel to stop high
* visibility mode at any time.
*/
Polymer({
is: 'nearby-share-high-visibility-page',
behaviors: [I18nBehavior],
properties: {
/**
* @type {string}
*/
deviceName: {
notify: true,
type: String,
value: 'DEVICE_NAME_NOT_SET',
}
},
/**
* @return {string} localized string
* @private
*/
getSubTitle_() {
return this.i18n('nearbyShareHighVisibilitySubTitle', this.deviceName);
},
});
......@@ -3,11 +3,9 @@
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_view_manager/cr_view_manager.html">
<link rel="import" href="../../shared/nearby_page_template.html">
<!-- NOTE: The above import is just so this file gets included in the bundle
for testing purposes. It will be removed when the actual pages are
added in a follow up CL.
-->
<link rel="import" href="../../shared/nearby_share_settings_behavior.html">
<link rel="import" href="nearby_share_confirm_page.html">
<link rel="import" href="nearby_share_high_visibility_page.html">
<dom-module id="nearby-share-receive-dialog">
<template>
......@@ -19,6 +17,11 @@
<cr-dialog id="dialog" show-on-attach>
<div id="content" slot="body">
<cr-view-manager id="viewManager">
<nearby-share-high-visibility-page id="[[Page.HIGH_VISIBILITY]]"
slot="view" device-name="[[settings.deviceName]]">
</nearby-share-high-visibility-page>
<nearby-share-confirm-page id="[[Page.CONFIRM]]" slot="view">
</nearby-share-confirm-page>
</cr-view-manager>
</div>
</cr-dialog>
......
......@@ -9,9 +9,36 @@
* 2) Non-contact confirm page (contacts are confirmed w/ a notification)
*/
/** @enum {string} */
const Page = {
HIGH_VISIBILITY: 'high-visibility',
CONFIRM: 'confirm',
};
Polymer({
is: 'nearby-share-receive-dialog',
properties: {
/** Mirroring the enum so that it can be used from HTML bindings. */
Page: {
type: Object,
value: Page,
},
/** @type {nearby_share.NearbySettings} */
settings: {
type: Object,
value: {},
},
},
listeners: {
'change-page': 'onChangePage_',
'cancel': 'onCancel_',
'confirm': 'onConfirm_',
'reject': 'onReject_',
},
/**
* @return {!CrViewManagerElement} the view manager
* @private
......@@ -28,4 +55,47 @@ Polymer({
dialog.close();
}
},
/**
* Call to show the high visibility page
*/
showHighVisibilityPage() {
// TODO(vecore): Register foreground receiver.
this.getViewManager_().switchView(Page.HIGH_VISIBILITY);
},
/**
* Call to show the share target configuration page
*/
showConfirmPage() {
// TODO (vecore): Extract share target state or pass in.
this.getViewManager_().switchView(Page.CONFIRM);
},
/**
* Child views can fire a 'change-page' event to trigger a page change
* @param {!CustomEvent<!{page: Page}>} event
* @private
*/
onChangePage_(event) {
this.getViewManager_().switchView(event.detail.page);
},
/** @private */
onCancel_() {
// TODO(vecore): exit high-visibility mode
this.close_();
},
/** @private */
onConfirm_() {
// TODO(vecore): accept share target
this.close_();
},
/** @private */
onReject_() {
// TODO(vecore): reject share target
this.close_();
},
});
......@@ -90,7 +90,7 @@
</template>
<template is="dom-if" if="[[showReceiveDialog_]]" restamp>
<nearby-share-receive-dialog id="receiveDialog"
on-close="onReceiveDialogClose_">
on-close="onReceiveDialogClose_" settings="{{settings}}">
</nearby-share-receive-dialog>
</template>
</template>
......
......@@ -235,6 +235,14 @@ Polymer({
if (queryParams.has('receive')) {
this.showReceiveDialog_ = true;
Polymer.dom.flush();
this.$$('#receiveDialog').showHighVisibilityPage();
}
if (queryParams.has('confirm')) {
this.showReceiveDialog_ = true;
Polymer.dom.flush();
this.$$('#receiveDialog').showConfirmPage();
}
}
},
......
......@@ -648,6 +648,11 @@
use_base_dir="false"
compress="false"
type="BINDATA"/>
<include name="IDR_OS_SETTINGS_NEARBY_SHARE_CONFIRM_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_confirm_page.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_NEARBY_SHARE_SUBPAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_subpage.m.js"
use_base_dir="false"
......@@ -663,6 +668,11 @@
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_NEARBY_SHARE_HIGH_VISIBILITY_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_high_visibility_page.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_NEARBY_SHARE_RECEIVE_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/nearby_share_page/nearby_share_receive_dialog.m.js"
use_base_dir="false"
......
......@@ -1316,6 +1316,12 @@
<structure name="IDR_OS_SETTINGS_MULTIDEVICE_TETHER_ITEM_JS"
file="chromeos/multidevice_page/multidevice_tether_item.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_CONFIRM_PAGE_HTML"
file="chromeos/nearby_share_page/nearby_share_confirm_page.html"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_CONFIRM_PAGE_JS"
file="chromeos/nearby_share_page/nearby_share_confirm_page.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_CONTACT_VISIBILITY_DIALOG_HTML"
file="chromeos/nearby_share_page/nearby_share_contact_visibility_dialog.html"
compress="false" type="chrome_html" />
......@@ -1328,6 +1334,12 @@
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_DIALOG_JS"
file="chromeos/nearby_share_page/nearby_share_device_name_dialog.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_HIGH_VISIBILITY_PAGE_HTML"
file="chromeos/nearby_share_page/nearby_share_high_visibility_page.html"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_HIGH_VISIBILITY_PAGE_JS"
file="chromeos/nearby_share_page/nearby_share_high_visibility_page.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_RECEIVE_DIALOG_HTML"
file="chromeos/nearby_share_page/nearby_share_receive_dialog.html"
compress="false" type="chrome_html" />
......
......@@ -122,6 +122,11 @@ void RegisterNearbySharedStrings(content::WebUIDataSource* data_source) {
{"nearbyShareVisibilityPageSubtitle",
IDS_NEARBY_VISIBILITY_PAGE_SUBTITLE},
{"nearbyShareVisibilityPageTitle", IDS_NEARBY_VISIBILITY_PAGE_TITLE},
};
{"nearbyShareHighVisibilitySubTitle",
IDS_NEARBY_HIGH_VISIBILITY_SUB_TITLE},
{"nearbyShareHighVisibilityHelpText",
IDS_NEARBY_HIGH_VISIBILITY_HELP_TEXT},
{"nearbyShareReceiveConfirmPageTitle",
IDS_NEARBY_RECEIVE_CONFIRM_PAGE_TITLE}};
webui::AddLocalizedStringsBulk(data_source, kLocalizedStrings);
}
......@@ -33,7 +33,17 @@ suite('NearbyShare', function() {
return test_util.isChildVisible(dialog, selector, false);
}
test('dialog resolves to a polymer element', function() {
assertTrue('attached' in dialog);
test('show high visibility page', function() {
dialog.showHighVisibilityPage();
Polymer.dom.flush();
assertTrue(isVisible('nearby-share-high-visibility-page'));
assertFalse(isVisible('nearby-share-confirm-page'));
});
test('show confirm page', function() {
dialog.showConfirmPage();
Polymer.dom.flush();
assertFalse(isVisible('nearby-share-high-visibility-page'));
assertTrue(isVisible('nearby-share-confirm-page'));
});
});
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