Commit 5c7c81eb authored by Michael Hansen's avatar Michael Hansen Committed by Commit Bot

[Nearby] Add data usage setting.

This adds a row in the Nearby Settings subpage for the "Data usage"
setting, as well as the dialog which appears when the user clicks the
edit button on the row. The dialog saves the selected option to prefs,
but in a future CL this will be updated to use a mojo.

Screenshot of the row in the subpage:
  https://screenshot.googleplex.com/5BGciifsy8m
Screenshot of the dialog:
  https://screenshot.googleplex.com/2cVEQtz9yVx

Specs in Carbon: https://goto.google.com/orazy

Bug: b:154866240
Change-Id: I25749a71a3b78ebf4b75350a60ab2ede744b3927
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311050
Commit-Queue: Michael Hansen <hansenmichael@google.com>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794276}
parent 532fbae3
......@@ -108,9 +108,45 @@
<message name="IDS_SETTINGS_NEARBY_SHARE_EDIT_DEVICE_NAME" desc="Label for the button that opens the dialog which allows a user to set the name of their device which is shown to other devices for the Nearby Share feature.">
Change name
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ARIA_DESCRIPTION" desc="Description for screen readers, not displayed in UI, specifying the current device name which is shown to other devices for the Nearby Share feature.">
<message name="IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ARIA_DESCRIPTION" desc="Description for screen readers, not displayed in UI, specifying the current device name which is shown to other devices for the Nearby Share feature." is_accessibility_with_no_ui="true">
Current device name is <ph name="DEVICE_NAME">$1<ex>Michael's Chromebook</ex></ph>
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_EDIT_DATA_USAGE" desc="Label for the button that brings up a dialog to allow a user to edit the data usage setting for the Nearby Share feature.">
Edit
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_UPDATE_DATA_USAGE" desc="Label for the button that allows a user to confirm their choice of data usage setting for the Nearby Share feature.">
Update
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DIALOG_TITLE" desc="Title for the dialog where a user can select the data usage setting for the Nearby Share feature.">
Data usage
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_WIFI_ONLY_LABEL" desc="Label for the data usage setting where only Wi-Fi is to be used for transfers for the Nearby Share feature.">
Wi-Fi only
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_WIFI_ONLY_DESCRIPTION" desc="Description of the data usage setting where only Wi-Fi is to be used for transfers for the Nearby Share feature.">
Never use data to transfer
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DATA_LABEL" desc="Label for the data usage setting where Wi-Fi or cell data may be used for transfers for the Nearby Share feature.">
Data
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DATA_DESCRIPTION" desc="Description of the data usage setting where Wi-Fi or cell data may be used for transfers for the Nearby Share feature.">
May incur data charges
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_OFFLINE_LABEL" desc="Label for the data usage setting where transfers will only take place offline for the Nearby Share feature.">
Without internet
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_OFFLINE_DESCRIPTION" desc="Description of the data usage setting where transfers will only take place offline for the Nearby Share feature.">
Files will always be shared offline
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_DATA_DESCRIPTION" desc="Description for scren readers, not displayed in UI, specifying the current data usage setting where Wi-Fi or cell data may be used for transfers for the Nearby Share feature." is_accessibility_with_no_ui="true">
Current data usage setting is Data
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_WIFI_ONLY_DESCRIPTION" desc="Description for screen readers, not displayed in UI, specifying the current data usage setting where only Wi-Fi is to be used for transfers for the Nearby Share feature." is_accessibility_with_no_ui="true">
Current data usage setting is Wi-Fi only
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_OFFLINE_DESCRIPTION" desc="Description for scren readers, not displayed in UI, specifying the current data usage setting where transfers will only take place offline for the Nearby Share feature." is_accessibility_with_no_ui="true">
Current data usage setting is Without internet
</message>
<!-- Personalization Options SubPage (strings used by the <settings-personalization-options> element) -->
<message name="IDS_SETTINGS_ENABLE_URL_KEYED_ANONYMIZED_DATA_COLLECTION" desc="The label of the checkbox to enable/disable url keyed anonymized data collection.">
......
b4d934df09874220ecec60b0a4a4ae7d2adc2842
\ No newline at end of file
1f2fa3cd2911458ea45ba78531c659552ca04117
\ No newline at end of file
690d352fcbf93dff02fed0274f47f58be8190ecd
\ No newline at end of file
ae1b70c839e49eecb528a4ef35246acb6ff7a5ea
\ No newline at end of file
3989dd9c90c1742c7c9aa9c14d603ca3ae5bab12
\ No newline at end of file
......@@ -312,6 +312,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[::prefs::kNearbySharingDeviceNamePrefName] =
settings_api::PrefType::PREF_TYPE_STRING;
(*s_whitelist)[::prefs::kNearbySharingDataUsageName] =
settings_api::PrefType::PREF_TYPE_NUMBER;
// Search page.
(*s_whitelist)[DefaultSearchManager::kDefaultSearchProviderDataPrefName] =
......
......@@ -20,6 +20,7 @@ import './parental_controls_page/parental_controls_page.m.js';
import './os_people_page/os_people_page.m.js';
export {LifetimeBrowserProxy, LifetimeBrowserProxyImpl} from '../lifetime_browser_proxy.m.js';
export {dataUsageStringToEnum, NearbyShareDataUsage} from '../nearby_share_page/types.m.js';
export {AccountManagerBrowserProxy, AccountManagerBrowserProxyImpl} from '../people_page/account_manager_browser_proxy.m.js';
export {ParentalControlsBrowserProxyImpl, ParentalControlsBrowserProxy} from './parental_controls_page/parental_controls_browser_proxy.m.js';
export {CrSettingsPrefs} from '../prefs/prefs_types.m.js';
......
......@@ -407,6 +407,16 @@
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/nearby_share_page/nearby_share_data_usage_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_NEARBY_SHARE_TYPES_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/nearby_share_page/types.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_ROUTER_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/router.m.js"
use_base_dir="false"
......
......@@ -4,12 +4,29 @@
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/polymer/polymer.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
import("../settings.gni")
js_type_check("closure_compile") {
deps = [
":nearby_share_data_usage_dialog",
":nearby_share_device_name_dialog",
":nearby_share_subpage",
":types",
]
}
js_library("nearby_share_data_usage_dialog") {
deps = [
":types",
"../prefs",
"../prefs:prefs_behavior",
"../prefs:prefs_types",
"//ui/webui/resources/cr_elements/cr_button:cr_button",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/cr_elements/cr_radio_button:cr_radio_button",
"//ui/webui/resources/cr_elements/cr_radio_group:cr_radio_group",
"//ui/webui/resources/js:i18n_behavior",
]
}
......@@ -27,7 +44,9 @@ js_library("nearby_share_device_name_dialog") {
js_library("nearby_share_subpage") {
deps = [
":nearby_share_data_usage_dialog",
":nearby_share_device_name_dialog",
":types",
"../prefs",
"../prefs:prefs_behavior",
"../prefs:prefs_types",
......@@ -37,8 +56,13 @@ js_library("nearby_share_subpage") {
]
}
js_library("types") {
}
group("polymer3_elements") {
public_deps = [
":modulize",
":nearby_share_data_usage_dialog_module",
":nearby_share_device_name_dialog_module",
":nearby_share_subpage_module",
"../controls:polymer3_elements",
......@@ -49,11 +73,28 @@ group("polymer3_elements") {
js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [
":nearby_share_data_usage_dialog.m",
":nearby_share_device_name_dialog.m",
":nearby_share_subpage.m",
]
}
js_library("nearby_share_data_usage_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/nearby_share_page/nearby_share_data_usage_dialog.m.js" ]
deps = [
":types.m",
"../prefs:prefs.m",
"../prefs:prefs_behavior.m",
"../prefs:prefs_types.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_radio_button:cr_radio_button.m",
"//ui/webui/resources/cr_elements/cr_radio_group:cr_radio_group.m",
"//ui/webui/resources/js:i18n_behavior.m",
]
extra_deps = [ ":nearby_share_data_usage_dialog_module" ]
}
js_library("nearby_share_device_name_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/nearby_share_page/nearby_share_device_name_dialog.m.js" ]
deps = [
......@@ -71,7 +112,9 @@ js_library("nearby_share_device_name_dialog.m") {
js_library("nearby_share_subpage.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/nearby_share_page/nearby_share_subpage.m.js" ]
deps = [
":nearby_share_data_usage_dialog.m",
":nearby_share_device_name_dialog.m",
":types.m",
"../prefs:prefs.m",
"../prefs:prefs_behavior.m",
"../prefs:prefs_types.m",
......@@ -82,6 +125,24 @@ js_library("nearby_share_subpage.m") {
extra_deps = [ ":nearby_share_subpage_module" ]
}
js_library("types.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/nearby_share_page/types.m.js" ]
extra_deps = [ ":modulize" ]
}
js_modulizer("modulize") {
input_files = [ "types.js" ]
namespace_rewrites = settings_namespace_rewrites
}
polymer_modulizer("nearby_share_data_usage_dialog") {
js_file = "nearby_share_data_usage_dialog.js"
html_file = "nearby_share_data_usage_dialog.html"
html_type = "dom-module"
namespace_rewrites = settings_namespace_rewrites
auto_imports = settings_auto_imports
}
polymer_modulizer("nearby_share_device_name_dialog") {
js_file = "nearby_share_device_name_dialog.js"
html_file = "nearby_share_device_name_dialog.html"
......
<link rel="import" href="chrome://resources/html/polymer.html">
<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_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="../prefs/prefs.html">
<link rel="import" href="../prefs/prefs_behavior.html">
<link rel="import" href="types.html">
<dom-module id="nearby-share-data-usage-dialog">
<template>
<style>
.data-usage-name {
font-weight: 600;
}
</style>
<cr-dialog id="dialog">
<div slot="title">
$i18n{nearbyShareDataUsageDialogTitle}
</div>
<div slot="body">
<cr-radio-group selected="[[selectedDataUsage_(
prefs.nearby_sharing.data_usage.value)]]">
<cr-radio-button id="dataUsageWifiOnlyButton"
name="[[NearbyShareDataUsage.WIFI_ONLY]]"
aria-labelledby="dataUsageWifiOnlyLabel"
aria-describedby="dataUsageWifiOnlyDescription">
<div id="dataUsageWifiOnlyLabel" class="data-usage-name"
aria-hidden="true">
$i18n{nearbyShareDataUsageWifiOnlyLabel}
</div>
<div id="dataUsageWifiOnlyDescription" aria-hidden="true">
$i18n{nearbyShareDataUsageWifiOnlyDescription}
</div>
</cr-radio-button>
<cr-radio-button id="dataUsageDataButton"
name="[[NearbyShareDataUsage.ONLINE]]"
aria-labelledby="dataUsageDataLabel"
aria-describedby="dataUsageDataDescription">
<div id="dataUsageDataLabel" class="data-usage-name"
aria-hidden="true">
$i18n{nearbyShareDataUsageDataLabel}
</div>
<div id="dataUsageDataDescription" aria-hidden="true">
$i18n{nearbyShareDataUsageDataDescription}
</div>
</cr-radio-button>
<cr-radio-button id="dataUsageOfflineButton"
name="[[NearbyShareDataUsage.OFFLINE]]"
aria-labelledby="dataUsageOfflineLabel"
aria-describedby="dataUsageOfflineDescription">
<div id="dataUsageOfflineLabel" class="data-usage-name"
aria-hidden="true">
$i18n{nearbyShareDataUsageOfflineLabel}
</div>
<div id="dataUsageOfflineDescription" aria-hidden="true">
$i18n{nearbyShareDataUsageOfflineDescription}
</div>
</cr-radio-button>
</cr-radio-group>
</div>
<div class="layout horizontal center" slot="button-container">
<cr-button class="cancel-button" on-click="onCancelTap_">
$i18n{cancel}
</cr-button>
<cr-button class="action-button" on-click="onUpdateTap_">
$i18n{updateDataUsage}
</cr-button>
</cr-dialog>
</template>
<script src="nearby_share_data_usage_dialog.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
* 'nearby-share-data-usage-dialog' allows editing of the data usage setting
* when using Nearby Share.
*/
Polymer({
is: 'nearby-share-data-usage-dialog',
behaviors: [
I18nBehavior,
PrefsBehavior,
],
properties: {
/** Preferences state. */
prefs: {
type: Object,
notify: true,
},
/** @type {!Object<string, number>} */
NearbyShareDataUsage: {
type: Object,
value: NearbyShareDataUsage,
},
},
/** @override */
attached() {
const dialog = /** @type {!CrDialogElement} */ (this.$.dialog);
if (!dialog.open) {
dialog.showModal();
}
},
/** @private */
close() {
const dialog = /** @type {!CrDialogElement} */ (this.$.dialog);
if (dialog.open) {
dialog.close();
}
},
/** @private */
onCancelTap_() {
this.close();
},
/** @private */
onUpdateTap_() {
this.setPrefValue(
'nearby_sharing.data_usage',
dataUsageStringToEnum(this.$$('cr-radio-group').selected));
this.close();
},
/** @private */
selectedDataUsage_(dataUsageValue) {
if (dataUsageValue === NearbyShareDataUsage.UNKNOWN) {
return NearbyShareDataUsage.WIFI_ONLY;
}
return dataUsageValue;
},
});
......@@ -8,6 +8,8 @@
<link rel="import" href="../prefs/prefs_behavior.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="nearby_share_device_name_dialog.html">
<link rel="import" href="nearby_share_data_usage_dialog.html">
<link rel="import" href="types.html">
<dom-module id="settings-nearby-share-subpage">
<template>
......@@ -32,7 +34,6 @@
[[prefs.nearby_sharing.device_name.value]]
</div>
</div>
<div class="separator"></div>
<cr-button id="editDeviceNameButton" on-click="onDeviceNameTap_"
aria-description="[[getEditNameButtonAriaDescription_(
prefs.nearby_sharing.device_name.value)]]">
......@@ -44,6 +45,26 @@
on-close="onDeviceNameDialogClose_">
</nearby-share-device-name-dialog>
</template>
<div class="settings-box two-line">
<div class="start">
<div aria-hidden="true">
[[getDataUsageLabel_(prefs.nearby_sharing.data_usage.value)]]
</div>
<div aria-hidden="true" class="secondary">
[[getDataUsageSubLabel_(prefs.nearby_sharing.data_usage.value)]]
</div>
</div>
<cr-button id="editDataUsageButton" on-click="onDataUsageTap_"
aria-description="[[getEditDataUsageButtonAriaDescription_(
prefs.nearby_sharing.data_usage.value)]]">
$i18n{editDataUsage}
</cr-button>
</div>
<template is="dom-if" if="[[showDataUsageDialog_]]" restamp>
<nearby-share-data-usage-dialog prefs="{{prefs}}" id="dataUsageDialog"
on-close="onDataUsageDialogClose_">
</nearby-share-data-usage-dialog>
</template>
</template>
<script src="nearby_share_subpage.js"></script>
</dom-module>
......@@ -7,7 +7,6 @@
* 'settings-nearby-share-subpage' is the settings subpage for managing the
* Nearby Share feature.
*/
Polymer({
is: 'settings-nearby-share-subpage',
......@@ -28,6 +27,12 @@ Polymer({
type: Boolean,
value: false,
},
/** @private {boolean} */
showDataUsageDialog_: {
type: Boolean,
value: false,
},
},
/**
......@@ -41,9 +46,7 @@ Polymer({
event.stopPropagation();
},
/**
* @private
*/
/** @private */
onDeviceNameTap_() {
if (this.showDeviceNameDialog_) {
return;
......@@ -51,6 +54,11 @@ Polymer({
this.showDeviceNameDialog_ = true;
},
/** @private */
onDataUsageTap_() {
this.showDataUsageDialog_ = true;
},
/**
* @param {!Event} event
* @private
......@@ -59,6 +67,14 @@ Polymer({
this.showDeviceNameDialog_ = false;
},
/**
* @param {!Event} event
* @private
*/
onDataUsageDialogClose_(event) {
this.showDataUsageDialog_ = false;
},
/**
* @param {boolean} state boolean state that determines which string to show
* @param {string} onstr string to show when state is true
......@@ -78,4 +94,55 @@ Polymer({
getEditNameButtonAriaDescription_(name) {
return this.i18n('nearbyShareDeviceNameAriaDescription', name);
},
/**
* * @param {string} dataUsageValue enum value of data usage setting.
* * @return {string} localized string
* * @private
* */
getDataUsageLabel_(dataUsageValue) {
if (dataUsageStringToEnum(dataUsageValue) === NearbyShareDataUsage.ONLINE) {
return this.i18n('nearbyShareDataUsageDataLabel');
} else if (
dataUsageStringToEnum(dataUsageValue) ===
NearbyShareDataUsage.OFFLINE) {
return this.i18n('nearbyShareDataUsageOfflineLabel');
} else {
return this.i18n('nearbyShareDataUsageWifiOnlyLabel');
}
},
/**
* * @param {string} dataUsageValue enum value of data usage setting.
* * @return {string} localized string
* * @private
* */
getDataUsageSubLabel_(dataUsageValue) {
if (dataUsageStringToEnum(dataUsageValue) === NearbyShareDataUsage.ONLINE) {
return this.i18n('nearbyShareDataUsageDataDescription');
} else if (
dataUsageStringToEnum(dataUsageValue) ===
NearbyShareDataUsage.OFFLINE) {
return this.i18n('nearbyShareDataUsageOfflineDescription');
} else {
return this.i18n('nearbyShareDataUsageWifiOnlyDescription');
}
},
/**
* * @param {string} dataUsageValue enum value of data usage setting.
* * @return {string} localized string
* * @private
* */
getEditDataUsageButtonAriaDescription_(dataUsageValue) {
if (dataUsageStringToEnum(dataUsageValue) === NearbyShareDataUsage.ONLINE) {
return this.i18n('nearbyShareDataUsageDataEditButtonDescription');
} else if (
dataUsageStringToEnum(dataUsageValue) ===
NearbyShareDataUsage.OFFLINE) {
return this.i18n('nearbyShareDataUsageOfflineEditButtonDescription');
} else {
return this.i18n('nearbyShareDataUsageWifiOnlyEditButtonDescription');
}
},
});
// 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.
/**
* Enumeration of all possible data usage options for Nearby Share.
* Note: This must be kept in sync with DataUsage in
* chrome/browser/nearby_sharing/nearby_constants.h
* @enum {number}
*/
/* #export */ const NearbyShareDataUsage = {
UNKNOWN: 0,
OFFLINE: 1,
ONLINE: 2,
WIFI_ONLY: 3,
};
/**
* Takes a string and returns a value of the NearbyShareDataUsage enum.
* @param {string} s string representation of the data usage value
* @return {!NearbyShareDataUsage} enum value
*/
/* #export */ function dataUsageStringToEnum(s) {
switch (/** @type {!NearbyShareDataUsage} */ (parseInt(s, 10))) {
case NearbyShareDataUsage.OFFLINE:
return NearbyShareDataUsage.OFFLINE;
case NearbyShareDataUsage.ONLINE:
return NearbyShareDataUsage.ONLINE;
case NearbyShareDataUsage.WIFI_ONLY:
return NearbyShareDataUsage.WIFI_ONLY;
default:
return NearbyShareDataUsage.UNKNOWN;
}
}
......@@ -1280,6 +1280,18 @@
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_DIALOG_JS"
file="nearby_share_page/nearby_share_device_name_dialog.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DIALOG_HTML"
file="nearby_share_page/nearby_share_data_usage_dialog.html"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DIALOG_JS"
file="nearby_share_page/nearby_share_data_usage_dialog.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_TYPES_HTML"
file="nearby_share_page/types.html"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_TYPES_JS"
file="nearby_share_page/types.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_NEARBY_SHARE_SUBPAGE_HTML"
file="nearby_share_page/nearby_share_subpage.html"
compress="false" type="chrome_html" />
......
......@@ -133,6 +133,7 @@ settings_auto_imports = [
"chrome/browser/resources/settings/extension_control_browser_proxy.html|ExtensionControlBrowserProxyImpl,ExtensionControlBrowserProxy",
"chrome/browser/resources/settings/global_scroll_target_behavior.html|GlobalScrollTargetBehavior",
"chrome/browser/resources/settings/i18n_setup.html|loadTimeData",
"chrome/browser/resources/settings/nearby_share_page/types.html|NearbyShareDataUsage,dataUsageStringToEnum",
"chrome/browser/resources/settings/prefs/prefs_behavior.html|PrefsBehavior",
"chrome/browser/resources/settings/prefs/prefs_types.html|CrSettingsPrefs",
"chrome/browser/resources/settings/printing_page/printing_browser_proxy.html|PrintingBrowserProxyImpl",
......
......@@ -256,7 +256,29 @@ void AddNearbyShareData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_INPUT_LABEL},
{"nearbyShareEditDeviceName", IDS_SETTINGS_NEARBY_SHARE_EDIT_DEVICE_NAME},
{"nearbyShareDeviceNameAriaDescription",
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ARIA_DESCRIPTION}};
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ARIA_DESCRIPTION},
{"editDataUsage", IDS_SETTINGS_NEARBY_SHARE_EDIT_DATA_USAGE},
{"updateDataUsage", IDS_SETTINGS_NEARBY_SHARE_UPDATE_DATA_USAGE},
{"nearbyShareDataUsageDialogTitle",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DIALOG_TITLE},
{"nearbyShareDataUsageWifiOnlyLabel",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_WIFI_ONLY_LABEL},
{"nearbyShareDataUsageWifiOnlyDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_WIFI_ONLY_DESCRIPTION},
{"nearbyShareDataUsageDataLabel",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DATA_LABEL},
{"nearbyShareDataUsageDataDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DATA_DESCRIPTION},
{"nearbyShareDataUsageOfflineLabel",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_OFFLINE_LABEL},
{"nearbyShareDataUsageOfflineDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_OFFLINE_DESCRIPTION},
{"nearbyShareDataUsageDataEditButtonDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_DATA_DESCRIPTION},
{"nearbyShareDataUsageWifiOnlyEditButtonDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_WIFI_ONLY_DESCRIPTION},
{"nearbyShareDataUsageOfflineEditButtonDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_OFFLINE_DESCRIPTION}};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
html_source->AddBoolean(
......
......@@ -26,6 +26,9 @@ suite('NearbyShare', function() {
'enabled': {
value: true,
},
'data_usage': {
value: 3,
},
'device_name': {
value: '',
}
......@@ -81,4 +84,17 @@ suite('NearbyShare', function() {
assertEquals(newName, subpage.prefs.nearby_sharing.device_name.value);
});
test('update data usage preference', function() {
assertEquals(3, subpage.prefs.nearby_sharing.data_usage.value);
subpage.$$('#editDataUsageButton').click();
Polymer.dom.flush();
const dialog = subpage.$$('nearby-share-data-usage-dialog');
dialog.$$('#dataUsageDataButton').click();
dialog.$$('.action-button').click();
assertEquals(2, subpage.prefs.nearby_sharing.data_usage.value);
});
});
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